Pandoc markdown and notes #637

已關閉
opened 5 年之前 by framatophe · 4 條評論
framatophe " 評論 5 年之前" (Migrated from 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 年之前" (Migrated from 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 " 評論 5 年之前" (Migrated from 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 年之前" (Migrated from 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 年之前" (Migrated from 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> ```
登入 才能加入這對話。
未選擇里程碑
No Assignees
1 參與者
訊息
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: Plume/Plume#637
Loading…
尚未有任何內容