-
Couldn't load subscription status.
- Fork 1.1k
[#923] Fix mutton and nut substitution in notes #935
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
[#923] Fix mutton and nut substitution in notes #935
Conversation
| return Promise.resolve( | ||
| toMarkdown(content) | ||
| .replace('–', '--') | ||
| .replace('—', '---') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The values to be replaced look exactly the same but they are distinct: an em-dash (mutton) and an n-dash (nut).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh boy 😂
|
I just feel like this is an external issue, their docs claim it will not affect
We have run into issues with this previously, the order of the transformation of markdown to html, so maybe there is some better way to process tags within tags. Can the replacement of the dashes be done at not such a global level? Like, only do replacements within processed |
No. It was late and series 3 of Fargo was a-callin' me 😄 I'll create a reproducible gist and then open an issue later today; I'll post a link on the issue that Amir opened.
Totes; the current implementation will only do the replacement within the I'm happy, of course, for this PR to be closed: the investigation was the important bit and my tactical fix is... well, yeah 😂 |
| return Promise.resolve( | ||
| toMarkdown(content) | ||
| .replace('–', '--') | ||
| .replace('—', '---') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe let's actually add a comment in the code here about how this is a temp fix and maybe link to this issue. I can see our future selves looking at this code like 😳 wat...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😆
Yes, good suggestion Jennifer. I have done so.
I have now: markedjs/marked#1334 |

Right, I was sufficiently bugged by this to investigate it.
It looks to be a bug in the Markdown library that Hexo uses. (
marked)Even though the SmartyPants "spec" says that content inside a
<code>block is not to be SmartyPants-ed, I have tested a small file against the library directly and it does SmartyPants-ify content in such blocks:Input
Output
Code that is fenced in backticks doesn't exhibit the same behaviour:
Input (some Markdown)
Output
Right, onto the Cypress code. We have content with nested tags:
{% note info %} `--report` {% url `--report` foo.html %} {% endnote %}What happens is that the
urltag is processed first and it spits out HTML into the surrounding block:{% note info %} `--report` <a href="foo.html"><code>--report</code></a> {% endnote %}The entire content of the
noteblock is then rendered into Markdown... and as we saw with my wee example at the start of this comment the--inside the<code>block is SmartyPants-ed, resulting in:I'll have a shuftie at sorting the issue at source in the underlying
markedlibrary.In the interim, I submit a PR that addresses the issue tactically.