June 4, 20251 yr I obviously spent too much time using Mattermost. To my shock the HTML inside <code> tags is rendered. Is there any nice script that get rids of rendering and adds proper indentation, or do all instructor websites really make their code blocks manually? Thanks for your help!
June 4, 20251 yr Not quite sure what you mean. Can you give an example. There are a number or alternatives you can use, I prefer <pre>. But in all cases if you want it to look pretty on the page it needs formatting. Have you looked at the specification for <code>? https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/code
January 8Jan 8 You’re not alone—many platforms handle <code> blocks differently. In most modern websites, code blocks are not written manually. They use tools or libraries that prevent HTML rendering and add formatting automatically, such as: Markdown parsers (Markdown escapes HTML inside code blocks by default) Syntax highlighters like Prism.js or Highlight.js Server-side escaping (<, >, &) to stop HTML rendering If your platform renders HTML inside <code> tags, it likely isn’t escaping content properly. A common fix is to wrap code in pre + code and escape HTML, or use a Markdown-based editor. For instructors/sites, the best practice is using Markdown + a syntax highlighting library, not manual formatting. This keeps code readable, safe, and consistently indented.
January 8Jan 8 Read the specification for <code>: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/code If the content between the code tags is being rendered something else is the cause not the HTML
Create an account or sign in to comment