Pandoc markdown and notes #637

Slēgta
framatophe atvēra pirms 5 gadiem · 4 komentāri
framatophe " komentēja pirms 5 gadiem" (Migrēts no 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 " komentēja pirms 5 gadiem" (Migrēts no 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 " komentēja pirms 4 gadiem" (Migrēts no 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 " komentēja pirms 4 gadiem" (Migrēts no 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 " komentēja pirms 4 gadiem" (Migrēts no 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> ```
Pierakstieties, lai pievienotos šai sarunai.
Nav atskaites punktu
Nav atbildīgo
1 dalībnieki
Paziņojumi
Izpildes termiņš
Datums līdz nav korekts. Izmantojiet formātu 'gggg-mm-dd'.

Izpildes termiņš nav uzstādīts.

Atkarības

Nav atkarību.

Atsaucas uz: Plume/Plume#637
Notiek ielāde…
Vēl nav satura.