-
Notifications
You must be signed in to change notification settings - Fork 971
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 shortcode handling in code-fences #1720
Conversation
Can you add tests? It will need quite a few |
Sure, I will add some tests. |
3d6e131
to
fcf072f
Compare
Rebased. Code cleaned-up. Tests added. |
This is basically a hack, but I think this is also the minimal changes required for fixing this issue. There are three tests added to test the rendering behavior including a |
fcf072f
to
1db2bab
Compare
Is this good to merge? Or should I do something more than this? |
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.
Just a small nit, no need to change it. Looks good, thanks!
@@ -242,7 +242,32 @@ pub fn markdown_to_html( | |||
match event { | |||
Event::Text(text) => { | |||
if let Some(ref mut code_block) = code_block { | |||
let html = code_block.highlight(&text); | |||
let html; | |||
if contains_shortcode(text.as_ref()) { |
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.
very small style neat but let html = if { .. } else { .. }
is a bit nicer imo
* rendering/markdown: fix shortcode handling in codefences * rendering/tests: add a bunch of tests for codefence + shortcode usages
* rendering/markdown: fix shortcode handling in codefences * rendering/tests: add a bunch of tests for codefence + shortcode usages
* rendering/markdown: fix shortcode handling in codefences * rendering/tests: add a bunch of tests for codefence + shortcode usages
IMPORTANT: Please do not create a Pull Request adding a new feature without discussing it first.
The place to discuss new features is the forum: https://zola.discourse.group/
If you want to add a new feature, please open a thread there first in the feature requests section.
Sanity check:
Code changes
(Delete or ignore this section for documentation changes)
next
branch?If the change is a new feature or adding to/changing an existing one:
This should fix #1708.
The fix is actually a workaround: by applying and capturing shortcode rendering output and then re-render them inside the code-fence context.