Pandoc markdown and notes #637

Chiuso
aperto 5 anni fa da framatophe · 4 commenti
framatophe 5 anni fa ha commentato (Migrato da github.com)

The markdown syntax used in Plume is quite satisfactory, but there should be at least one small correction: adapt the syntax of the notes to the pandoc flavor.

Usually, when writing markdown, most editors use the following syntax to create note calls and references:

Lorem ipsum[^note] partibus quidem

[^note]: This is a note.

However, with Plume, you have to use:

Lorem ipsum[^note] partibus quidem

[^note] This is a note.

The absence of the colon prevents you from writing in markdown in a classic editor, then importing the text into Plume without adjusting the notes. The opposite is also true.

The markdown syntax used in Plume is quite satisfactory, but there should be at least one small correction: adapt the syntax of the notes to the pandoc flavor. Usually, when writing markdown, most editors use the following syntax to create note calls and references: ``` Lorem ipsum[^note] partibus quidem [^note]: This is a note. ``` However, with Plume, you have to use: ``` Lorem ipsum[^note] partibus quidem [^note] This is a note. ``` The absence of the colon prevents you from writing in markdown in a classic editor, then importing the text into Plume without adjusting the notes. The opposite is also true.
papey 5 anni fa ha commentato (Migrato da github.com)

Working on it. Adding some pointers if anyone else is interested. All the render is made in the md_to_html function.

Here is an idea proposed by @AnaGelez :

the best solution would be to look for pandoc-style notes in md at the beginning of the function (iterating over its lines, and keeping those that are in the good format) and just remove the first :

Working on it. Adding some pointers if anyone else is interested. All the render is made in the `md_to_html` [function](https://github.com/Plume-org/Plume/blob/master/plume-common/src/utils.rs#L155). Here is an idea proposed by @AnaGelez : > the best solution would be to look for pandoc-style notes in md at the beginning of the function (iterating over its lines, and keeping those that are in the good format) and just remove the first :
papey 4 anni fa ha commentato (Migrato da github.com)

Since cpull-markdown is used in Plume to translate md to html, I looked at https://github.com/raphlinus/pulldown-cmark/blob/master/tests/suite/footnotes.rs and things looks good on this side. There is no closed issue about a bug like this, in the upstream package, any ideas ?

Since cpull-markdown is used in Plume to translate md to html, I looked at https://github.com/raphlinus/pulldown-cmark/blob/master/tests/suite/footnotes.rs and things looks good on this side. There is no closed issue about a bug like this, in the upstream package, any ideas ?
papey 4 anni fa ha commentato (Migrato da github.com)

Ok, here is an update of what i've found so far :

md_to_html function output LGTM, here is a test example :

Code :

    #[test]
    fn test_markdown_notes() {
        let md = r##"Awesome[^1]

[^1]: here is the note definition !
"##;

        let (s, _, _) = md_to_html(md, None, false, None);

        println!("{}", s)

    }

Output :

<p>Awesome<sup class="footnote-reference"><a href="#1">1</a></sup></p>
<div class="footnote-definition" id="1"><sup class="footnote-definition-label">1</sup>
<p>here is the note definition</p>
</div>

Here is the result I get on the final page generated by Plume :

With [^n]:

<article class="e-content" dir="auto">
<p>Awesome<sup><a href="#postcontent-1" rel="noopener noreferrer">1</a></sup></p>
<p><br></p>
<div id="postcontent-1"><sup>1</sup>
<p>here is the note definition !</p>
</div>
</article>

With [^n] 

<article class="e-content" dir="auto">
<p>Awesome<sup><a href="#postcontent-1" rel="noopener noreferrer">1</a></sup></p>
<p><br></p>
<p><sup><a href="#postcontent-1" rel="noopener noreferrer">1</a></sup> here is the note definition !</p>
</article>

Now, i'm having hard times finding where the page get translated from md_to_html output to final page. Looks like this where he can find the root cause of this bug. If you have some ideas, let me know.

Ok, here is an update of what i've found so far : `md_to_html` function output LGTM, here is a test example : Code : ```rust #[test] fn test_markdown_notes() { let md = r##"Awesome[^1] [^1]: here is the note definition ! "##; let (s, _, _) = md_to_html(md, None, false, None); println!("{}", s) } ``` Output : ```html <p>Awesome<sup class="footnote-reference"><a href="#1">1</a></sup></p> <div class="footnote-definition" id="1"><sup class="footnote-definition-label">1</sup> <p>here is the note definition</p> </div> ``` Here is the result I get on the final page generated by Plume : With **[^n]:** ```html <article class="e-content" dir="auto"> <p>Awesome<sup><a href="#postcontent-1" rel="noopener noreferrer">1</a></sup></p> <p><br></p> <div id="postcontent-1"><sup>1</sup> <p>here is the note definition !</p> </div> </article> ``` With **[^n]**  ```html <article class="e-content" dir="auto"> <p>Awesome<sup><a href="#postcontent-1" rel="noopener noreferrer">1</a></sup></p> <p><br></p> <p><sup><a href="#postcontent-1" rel="noopener noreferrer">1</a></sup> here is the note definition !</p> </article> ``` Now, i'm having hard times finding where the page get translated from `md_to_html` output to final page. Looks like this where he can find the root cause of this bug. If you have some ideas, let me know.
papey 4 anni fa ha commentato (Migrato da github.com)

Still digging on this, here is a test of SafeString related functions.

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_html_note_to_safe_string() {
        let html = r##"<p>Awesome<sup class="footnote-reference"><a href="#1">1</a></sup>
<sup class="footnote-reference"><a href="#1">1</a></sup>: here is the note definition !</p>"##;

        let s = SafeString::new(html);

        println!("{}", s);
    }
}

Output :

<p>Awesome<sup><a href="#postcontent-1" rel="noopener noreferrer">1</a></sup>
<sup><a href="#postcontent-1" rel="noopener noreferrer">1</a></sup>: here is the note definition !</p>
Still digging on this, here is a test of `SafeString` related functions. ```rust #[cfg(test)] mod tests { use super::*; #[test] fn test_html_note_to_safe_string() { let html = r##"<p>Awesome<sup class="footnote-reference"><a href="#1">1</a></sup> <sup class="footnote-reference"><a href="#1">1</a></sup>: here is the note definition !</p>"##; let s = SafeString::new(html); println!("{}", s); } } ``` Output : ```html <p>Awesome<sup><a href="#postcontent-1" rel="noopener noreferrer">1</a></sup> <sup><a href="#postcontent-1" rel="noopener noreferrer">1</a></sup>: here is the note definition !</p> ```
Effettua l'accesso per partecipare alla conversazione.
Nessuna milestone
Nessuna assegnatario
1 Partecipanti
Notifiche
Data di scadenza
La data di scadenza non è valida o fuori intervallo. Si prega di utilizzare il formato 'aaaa-mm-dd'.

Nessuna data di scadenza impostata.

Dipendenze

Nessuna dipendenza impostata.

Riferimento: Plume/Plume#637
Caricamento…
Non ci sono ancora contenuti.