Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parser doesn't process markdown nested inside of HTML tags #28

Closed
charlottetan opened this issue Oct 3, 2021 · 11 comments
Closed

Parser doesn't process markdown nested inside of HTML tags #28

charlottetan opened this issue Oct 3, 2021 · 11 comments

Comments

@charlottetan
Copy link

charlottetan commented Oct 3, 2021

For the following code snippet:

<div dir="rtl">
## توافقنامه‌ی مجوز همکاری

مشارکت در این مخزن به معنی موافقت شما با مجوز [LICENSE](/blob/master/LICENSE) این مخزن است.
</div>

The expected HTML to be rendered is:

<div dir="rtl">
    <h2>توافقنامه‌ی مجوز همکاری</h2>
    <p>مشارکت در این مخزن به معنی موافقت شما با مجوز <a href="blob/master/LICENSE">LICENSE</a> این مخزن است.</p>
</div>

And GFM renders that perfectly:
https://github.com/EbookFoundation/free-programming-books/blob/e629db6b05a72fd64a6b33feeeebbe830641cf10/CONTRIBUTING-fa_IR.md

However kramdown-parser-gfm appears to stop processing any markdown once it is nested under an HTML tag
https://ebookfoundation.github.io/free-programming-books/CONTRIBUTING-fa_IR.html

See EbookFoundation/free-programming-books#5559 for more information

@ashmaroli
Copy link
Contributor

You need to add markdown="1" attribute to the HTML block tag:

<div markdown="1">
  ## Heading 2
</div>

@davorpa
Copy link

davorpa commented Oct 4, 2021

You need to add markdown="1" attribute to the HTML block tag:

<div markdown="1">
  ## Heading 2
</div>

Thanks for the tip 🤗. We tried it to see what happens.

@charlottetan
Copy link
Author

Thanks so much for the explanation! I tried adding markdown="1" and for the most part it worked fine, but it seems that standalone URLs aren't parsed, am I missing something?

For example, given code:

<div dir="rtl" markdown="1">
این مرامنامه از این جا گرفته شده است: [Contributor Covenant][homepage],
نسخه‌ی 1.3.0 در این جا در دسترس است: https://contributor-covenant.org/version/1/3/0/

[homepage]: https://contributor-covenant.org
</div>

Expected HTML:

<p dir="auto">این مرامنامه از این جا گرفته شده است: <a href="https://contributor-covenant.org" rel="nofollow">Contributor Covenant</a>,
نسخه‌ی 1.3.0 در این جا در دسترس است: <a href="https://contributor-covenant.org/version/1/3/0/" rel="nofollow">https://contributor-covenant.org/version/1/3/0/</a></p>

Expected screenshot:
image

Actual HTML:

<p>این مرامنامه از این جا گرفته شده است: <a href="https://contributor-covenant.org">Contributor Covenant</a>,
نسخه‌ی 1.3.0 در این جا در دسترس است: https://contributor-covenant.org/version/1/3/0/</p>

Actual screenshot:
image

@ashmaroli
Copy link
Contributor

@gettalong Please look into #28 (comment)
It's beyond my understanding of the codebase.
Thanks.

@gettalong
Copy link
Member

@ashmaroli @charlottetan If you don't use the <div> tag around, it also won't work. So I don't think using plain URLs is supported at all. I didn't find anything in the code, either.

Is there any example where using a plain URL without enclosing angle brackets works?

@charlottetan
Copy link
Author

charlottetan commented Jan 24, 2022

Expected HTML:

<p dir="auto">این مرامنامه از این جا گرفته شده است: <a href="https://contributor-covenant.org" rel="nofollow">Contributor Covenant</a>,
نسخه‌ی 1.3.0 در این جا در دسترس است: <a href="https://contributor-covenant.org/version/1/3/0/" rel="nofollow">https://contributor-covenant.org/version/1/3/0/</a></p>

Expected screenshot: image

Using plain URLs works in Github's default readme, for example, see this file on this branch:
https://github.com/charlottetan/free-programming-books/blob/main/docs/CODE_OF_CONDUCT-fa_IR.md

@gettalong
Copy link
Member

@charlottetan I meant an example where this works with kramdown and parser-gfm.

@charlottetan
Copy link
Author

I'm confused, plain URLs work in Github's readme pages, are plain URLs not expected to work with kramdown+parser-gfm?

@gettalong
Copy link
Member

parser-gfm doesn't use the parser from Github but a custom implementation. So it is not 100% compatible with GFM and this is a feature that is not yet implemented.

@ashmaroli
Copy link
Contributor

this is a feature that is not yet implemented.

Thank you @gettalong

@charlottetan Until this feature gets implemented, (maybe, maybe not..), you may instruct kramdown to parse your standalone URLs and render them as links by surrounding each URL in angle brackets (<, >).
For example:

نسخه‌ی 1.3.0 در این جا در دسترس است: <https://contributor-covenant.org/version/1/3/0/>

@charlottetan
Copy link
Author

charlottetan commented Jan 26, 2022

Looks like there's already a feature request for that with #17.
Thanks so much @gettalong and @ashmaroli!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants