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

fix: don't escape markdown characters in code #281

Merged
merged 1 commit into from
Jul 18, 2021

Conversation

medmunds
Copy link
Contributor

Fixes extraneous backslashes introduced into code blocks.

Turndown tries to avoid escaping Markdown characters in code,
but doesn't recognize Evernote code blocks. This converts
some_var to some\_var, # comment to \# comment,
*ptr to \*ptr, etc. (likely breaking the code).

Since turndown applies its escape function before the content
arrives in yarle's code block rules, fix is to unescape it there.
(Note that turndown always escapes \ to \\, so unescaping
all backslash sequences will always result in the original code,
even if it contained backslashes.)

Copy link
Owner

@akosbalasko akosbalasko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @medmunds , looks nice and pretty!

Fixes extraneous backslashes introduced into code blocks.

Turndown tries to avoid escaping Markdown characters in code,
but doesn't recognize Evernote code blocks. This converts
`some_var` to `some\_var`, `# comment` to `\# comment`,
`*ptr` to `\*ptr`, etc. (likely breaking the code).

Since turndown applies its escape function before the content
arrives in yarle's code block rules, fix is to unescape it there.
(Note that turndown always escapes `\` to `\\`, so unescaping
all backslash sequences will always result in the original code,
even if it contained backslashes.)
@akosbalasko akosbalasko merged commit cae24b2 into akosbalasko:master Jul 18, 2021
@medmunds medmunds deleted the fix/code-escaping branch July 19, 2021 16:29
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

Successfully merging this pull request may close these issues.

2 participants