-
-
Notifications
You must be signed in to change notification settings - Fork 16.6k
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
Syntax highlighting adds unwanted HTML code comments #2744
Comments
I'm having a similar issue, when displaying React code. Seems to a problem in the parsing somewhere. Problem does not happen in older versions of reveal.js, so this is new for sure. |
This comment has been minimized.
This comment has been minimized.
@FrancoSpeziali do you know the older version that is working fine? I'm considering downgrade to fix it. |
@greg-witczak I haven't tried all the versions, but I checked out tag |
The extra characters are being inserted by the web browser because the unescaped The easiest fix is to swap <pre><code class="php"><script type="text/template">
<?php
function myFunc(){
echo 'test';
}
$name = 'myFunc';
$name();
</script></code></pre> Multiple people have reported that this worked in prior releases. While the issues has always been there for code added via HTML, I think the change in 4.0 is that it somehow started affecting external Markdown as well. I'm leaving this issue open until that par has been debugged further, if anyone has any ideas as to what change caused this I'm all ears. |
@hakimel Thanks, I figured it was something like that. I also tried swapping out the |
It affects inline markdown as well. I didn't have an issue with 3.x and have it with 4.x. I've narrowed it down to the markdown plugin, but wasn't able to solve it. Since I use a static website generator, my "solution" was to basically add a pre-processor that targets the ``` blocks and changes all the |
I've fixed this in the dev branch—if you're using Markdown, please try the latest version from there and let me know if it works. The issue was that as of 4.0 we started overriding the markdown parser's code renderer (https://github.com/hakimel/reveal.js/blob/dev/plugin/markdown/plugin.js#L429-L450) in order to support line numbers and line highlights. The built-in code renderer automatically escaped HTML entities in code, but our overridden version didn't. I've added HTML escapes to our own code renderer now too so it should continue to work just like it did pre 4.0. |
Cool, thanks for fixing that! Unfortunately, I'm not able to check the fix, since I'm using reveal-md - so I'll let you know once it gets to regular release and reveal-md gets updated. |
## Changelog for reveal.js: Commits: [hakimel/reveal.js@15815efe...e09437f4](hakimel/reveal.js@15815ef...e09437f) * [`942304d8`](hakimel/reveal.js@942304d) add --slide-width/height css variables * [`cd5c9c5b`](hakimel/reveal.js@cd5c9c5) build js * [`61624aea`](hakimel/reveal.js@61624ae) 🤦 * [`7ebade72`](hakimel/reveal.js@7ebade7) remove 20px vertical padding on slide sections * [`c9107476`](hakimel/reveal.js@c910747) don't write '#/' to url on first slide, remove history api feature detection * [`d272628f`](hakimel/reveal.js@d272628) add support for data-visibility=hidden * [`ac79c7cd`](hakimel/reveal.js@ac79c7c) leave the progress bar empty if there's < 2 slides * [`166af893`](hakimel/reveal.js@166af89) all themes now have contrasting text colors based on slide bg * [`37d83374`](hakimel/reveal.js@37d8337) add support for wrapping code in script tempalte to avoid html parser hakimel/reveal.js#2684 * [`66cbd66f`](hakimel/reveal.js@66cbd66) fix slide numbering issue with uncounted horizontal slides (fixes hakimel/reveal.js#2675) * [`1b6a3b1e`](hakimel/reveal.js@1b6a3b1) add support for auto-sized big text via r-fit-text * [`aa667791`](hakimel/reveal.js@aa66779) fit-text helper now triggers lazyily when slide enters view distance * [`be460814`](hakimel/reveal.js@be46081) correct scope for fit-text selector * [`cd2a7924`](hakimel/reveal.js@cd2a792) allow images inside of h/vstacks to be proportionally downsized * [`2fccb774`](hakimel/reveal.js@2fccb77) add 'playsinline' to all inline videos, dont mute background videos on mobile * [`9ff27cfb`](hakimel/reveal.js@9ff27cf) bg videos remain muted on mobile, otherwise broken when navigating with swipe gestures * [`2bfe705e`](hakimel/reveal.js@2bfe705) include /css and /js in npm package hakimel/reveal.js#2712 * [`b05e530f`](hakimel/reveal.js@b05e530) Fix URL to pdf-export documentation * [`3a99a7b7`](hakimel/reveal.js@3a99a7b) shuffle now applies to vertical slides as well * [`a150d0c5`](hakimel/reveal.js@a150d0c) Start relative paths in CSS with ./ * [`80d96b4f`](hakimel/reveal.js@80d96b4) upgrade rollup-plugin-terser to fix npm warning hakimel/reveal.js#2751 * [`faa8b56e`](hakimel/reveal.js@faa8b56) dependency upgrades * [`aa62bd42`](hakimel/reveal.js@aa62bd4) Update README.md * [`2c121d22`](hakimel/reveal.js@2c121d2) docs: Fix simple typo, transiition -> transition * [`676936e3`](hakimel/reveal.js@676936e) revert debug change to index.html * [`e09437f4`](hakimel/reveal.js@e09437f) escape HTML entities in code parsed from markdown, fixes hakimel/reveal.js#2744
## Changelog for reveal.js: Commits: [hakimel/reveal.js@15815efe...e09437f4](hakimel/reveal.js@15815ef...e09437f) * [`942304d8`](hakimel/reveal.js@942304d) add --slide-width/height css variables * [`cd5c9c5b`](hakimel/reveal.js@cd5c9c5) build js * [`61624aea`](hakimel/reveal.js@61624ae) 🤦 * [`7ebade72`](hakimel/reveal.js@7ebade7) remove 20px vertical padding on slide sections * [`c9107476`](hakimel/reveal.js@c910747) don't write '#/' to url on first slide, remove history api feature detection * [`d272628f`](hakimel/reveal.js@d272628) add support for data-visibility=hidden * [`ac79c7cd`](hakimel/reveal.js@ac79c7c) leave the progress bar empty if there's < 2 slides * [`166af893`](hakimel/reveal.js@166af89) all themes now have contrasting text colors based on slide bg * [`37d83374`](hakimel/reveal.js@37d8337) add support for wrapping code in script tempalte to avoid html parser hakimel/reveal.js#2684 * [`66cbd66f`](hakimel/reveal.js@66cbd66) fix slide numbering issue with uncounted horizontal slides (fixes hakimel/reveal.js#2675) * [`1b6a3b1e`](hakimel/reveal.js@1b6a3b1) add support for auto-sized big text via r-fit-text * [`aa667791`](hakimel/reveal.js@aa66779) fit-text helper now triggers lazyily when slide enters view distance * [`be460814`](hakimel/reveal.js@be46081) correct scope for fit-text selector * [`cd2a7924`](hakimel/reveal.js@cd2a792) allow images inside of h/vstacks to be proportionally downsized * [`2fccb774`](hakimel/reveal.js@2fccb77) add 'playsinline' to all inline videos, dont mute background videos on mobile * [`9ff27cfb`](hakimel/reveal.js@9ff27cf) bg videos remain muted on mobile, otherwise broken when navigating with swipe gestures * [`2bfe705e`](hakimel/reveal.js@2bfe705) include /css and /js in npm package hakimel/reveal.js#2712 * [`b05e530f`](hakimel/reveal.js@b05e530) Fix URL to pdf-export documentation * [`3a99a7b7`](hakimel/reveal.js@3a99a7b) shuffle now applies to vertical slides as well * [`a150d0c5`](hakimel/reveal.js@a150d0c) Start relative paths in CSS with ./ * [`80d96b4f`](hakimel/reveal.js@80d96b4) upgrade rollup-plugin-terser to fix npm warning hakimel/reveal.js#2751 * [`faa8b56e`](hakimel/reveal.js@faa8b56) dependency upgrades * [`aa62bd42`](hakimel/reveal.js@aa62bd4) Update README.md * [`2c121d22`](hakimel/reveal.js@2c121d2) docs: Fix simple typo, transiition -> transition * [`676936e3`](hakimel/reveal.js@676936e) revert debug change to index.html * [`e09437f4`](hakimel/reveal.js@e09437f) escape HTML entities in code parsed from markdown, fixes hakimel/reveal.js#2744
## Changelog for reveal.js: Commits: [hakimel/reveal.js@15815efe...e09437f4](hakimel/reveal.js@15815ef...e09437f) * [`942304d8`](hakimel/reveal.js@942304d) add --slide-width/height css variables * [`cd5c9c5b`](hakimel/reveal.js@cd5c9c5) build js * [`61624aea`](hakimel/reveal.js@61624ae) 🤦 * [`7ebade72`](hakimel/reveal.js@7ebade7) remove 20px vertical padding on slide sections * [`c9107476`](hakimel/reveal.js@c910747) don't write '#/' to url on first slide, remove history api feature detection * [`d272628f`](hakimel/reveal.js@d272628) add support for data-visibility=hidden * [`ac79c7cd`](hakimel/reveal.js@ac79c7c) leave the progress bar empty if there's < 2 slides * [`166af893`](hakimel/reveal.js@166af89) all themes now have contrasting text colors based on slide bg * [`37d83374`](hakimel/reveal.js@37d8337) add support for wrapping code in script tempalte to avoid html parser hakimel/reveal.js#2684 * [`66cbd66f`](hakimel/reveal.js@66cbd66) fix slide numbering issue with uncounted horizontal slides (fixes hakimel/reveal.js#2675) * [`1b6a3b1e`](hakimel/reveal.js@1b6a3b1) add support for auto-sized big text via r-fit-text * [`aa667791`](hakimel/reveal.js@aa66779) fit-text helper now triggers lazyily when slide enters view distance * [`be460814`](hakimel/reveal.js@be46081) correct scope for fit-text selector * [`cd2a7924`](hakimel/reveal.js@cd2a792) allow images inside of h/vstacks to be proportionally downsized * [`2fccb774`](hakimel/reveal.js@2fccb77) add 'playsinline' to all inline videos, dont mute background videos on mobile * [`9ff27cfb`](hakimel/reveal.js@9ff27cf) bg videos remain muted on mobile, otherwise broken when navigating with swipe gestures * [`2bfe705e`](hakimel/reveal.js@2bfe705) include /css and /js in npm package hakimel/reveal.js#2712 * [`b05e530f`](hakimel/reveal.js@b05e530) Fix URL to pdf-export documentation * [`3a99a7b7`](hakimel/reveal.js@3a99a7b) shuffle now applies to vertical slides as well * [`a150d0c5`](hakimel/reveal.js@a150d0c) Start relative paths in CSS with ./ * [`80d96b4f`](hakimel/reveal.js@80d96b4) upgrade rollup-plugin-terser to fix npm warning hakimel/reveal.js#2751 * [`faa8b56e`](hakimel/reveal.js@faa8b56) dependency upgrades * [`aa62bd42`](hakimel/reveal.js@aa62bd4) Update README.md * [`2c121d22`](hakimel/reveal.js@2c121d2) docs: Fix simple typo, transiition -> transition * [`676936e3`](hakimel/reveal.js@676936e) revert debug change to index.html * [`e09437f4`](hakimel/reveal.js@e09437f) escape HTML entities in code parsed from markdown, fixes hakimel/reveal.js#2744
README.md |
Reveal code with php syntax highlight:
Renders like this:
Generated HTML code:
I can't see any errors/warnings during build process.
This bug seems to be similar to #2741 and #2732 - reveal is adding something strange, trying to make code better. Is there a way to disable it?
The text was updated successfully, but these errors were encountered: