-
Notifications
You must be signed in to change notification settings - Fork 14
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
GFM re-hrefs the href #8
Comments
Hmm, thanks. That seems like a rather yikes bug in GithubFlavoredMarkdownExtension? Inline HTML is valid markdown, so GFM shouldn't be doing that. I'll investigate. |
Also ran into this and made a quick naive plugin that goes over and removes the double hrefs. Posting incase it helps. def remove_double_hrefs(docs):
for doc in docs:
yield put(
Doc.content,
doc,
re.sub(r'<a href=\"http.+?<a href=\"(http.*?)\">\1</a>\"', r'<a href="\1"', doc.content)
) Just make sure to put it after the content_markdown plugin. |
Hey, does anyone know if there's a "proper" fix for this yet? I'm using the current HEAD version (f55fc63) following the directions for obsidian-lettersmith here and I'm seeing what looks like this issue. Any recommendations? Here's a repository with my (stub) site that's giving problems: twilightfades0/digital_garden (currently on rev 01da77e5). Thanks! |
@twilightfades0 - changing the order in which the markdown is processed solved the issue for me ( without resorting to @SinaKhalili's plugin) The change sadly is to the changing this:
to this
|
@tijptjik Thank you, I'll test your PR! I thought I had tried this and run into a different ordering issue, but my memory may be faulty here. In the meantime, anyone that wants to can compose their own function, rather than having to monkey-patch the core function. One of my design goals for Lettersmith is to compose all the features from smaller "lego bricks" so that others can disassemble and rebuild/extend the features. |
Thank you, @gordonbrander - for your response and your excellent tool!
It solved the issue for Indeed, the lego-like compositionality is really nice - I've used it to add support for image-links in the Wiki syntax which Obsidian also uses (e.g. Thanks again for being so responsive! |
Copying comment from #10 (comment) Tested locally. Unfortunately, #10 breaks transclusion. The reason is that Markdown runs first, so it wraps the wikilinks in a Will investigate another fix. |
The bug is in the py-gfm library, and it looks like this library may be abandonware soon zopieux/py-gfm#28. Investigate https://github.com/Zopieux/pycmarkgfm as possible replacement. |
Fixes #8. GFM doesn't ignore inline HTML when rendering, and will produce bugs, such as re-hrefing the href in a link tag. GFM has essentially been abandoned. This PR replaces it with commonmark, which implements Common Markdown (https://commonmark.org/). Pros: - Commonmark is maintained by readthedocs, so is a good bet in terms of code durability. - Edge-cases in CommonMark are well-specified. - The library generates an AST, which we could use for enhancements later. Cons: - No auto-linking of bare URLs. You need to wrap URLs in <brackets> - No br for soft linebreaks. you will need to add two spaces at the end of the line to create a BR.
Just a heads-up that PR #11 fixes this by replacing GFM with commonmark. Commonmark is a well-specified flavor of markdown, and the library seems to be well-mainted by ReadTheDocs.io. Note that commonmark does not have some of Github-flavored Markdown's enhancements, such as auto-linking bare URLs, and treating line breaks as BRs. If you use these features of GitHub-flavored markdown, upgrading will be a breaking change. However, I feel that CommonMark provides a number of benefits, foremost that it is well-specified, and well-maintained. The PR linked above goes into the pros and cons. See https://commonmark.org/ for more on the (minor) differences. |
Fixes #8. GFM doesn't ignore inline HTML when rendering, and will produce bugs, such as re-hrefing the href in a link tag. GFM has essentially been abandoned. This PR replaces it with commonmark, which implements Common Markdown (https://commonmark.org/). Pros: - Commonmark is maintained by readthedocs, so is a good bet in terms of code durability. - Edge-cases in CommonMark are well-specified. - The library generates an AST, which we could use for enhancements later. Cons: - No auto-linking of bare URLs. You need to wrap URLs in <brackets> - No br for soft linebreaks. you will need to add two spaces at the end of the line to create a BR.
Clumsy title but bear with me.
Using the 'blog' scaffold, you run the docs through wikidoc.py
content_markdown()
, which first (becausecompose()
runs right-to-left) makes wikilinks, and then converts markdown to HTML (using GFM). But because you have already made your wikilinks nicely formatted in HTML, GFM ends up re-hrefing your href, for example:However this doesn't happen on transclude links:
The text was updated successfully, but these errors were encountered: