Fail to render simple code in Auto-render Extension
See original GitHub issueBefore reporting a bug
- Check common issues.
- Check the bug is reproducible in the demo. If not, check KaTeX is up-to-date and installed correctly.
- Search for existing issues.
Describe the bug: I am a freshman in front-end techniques, I write a simple code to test KateX but it still failed to render on Chrome. This must be my fault, but I couldn’t find anyway, could you help me to figure it out? Thank you in advance!
To Reproduce:
- Simple html code as follows:
<head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.0-beta/dist/katex.min.css" integrity="sha384-9tPv11A+glH/on/wEu99NVwDPwkMQESOocs/ZGXPoIiLE8MU/qkqUcZ3zzL+6DuH" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/katex@0.10.0-beta/dist/katex.min.js" integrity="sha384-U8Vrjwb8fuHMt6ewaCy8uqeUXv4oitYACKdB0VziCerzt011iQ/0TqlSlv8MReCm" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/katex@0.10.0-beta/dist/contrib/auto-render.min.js" integrity="sha384-aGfk5kvhIq5x1x5YdvCp4upKZYnA8ckafviDpmWEKp4afOZEqOli7gqSnh8I6enH" crossorigin="anonymous"></script>
<script>
renderMathInElement(document.body,
{
delimiters: [
{left: "$$", right: "$$", display: true},
{left: "$", right: "$", display: false}
]
}
);
</script>
</head>
<body>
$$ K_{2} $$
</body>
</html>
- run it and then fail…😭
There is no error in console, and all js/css loaded successfully.
Environment (please complete the following information):
- KaTeX Version: detail in code
- Device: Desktop
- OS: Windows10
- Browser: Chrome
- Version: latest maybe
Additional context:
Before testing this code, I intend to use KaTeX on my jekyll-based personal website, but I failed to render the formula by appending the scripts in head.html of include directory in my jekyll project)
It is not a bug indeed, but how can I change the label of this issue? Appreciate your help.
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Auto-render Extension - KaTeX
This is an extension to automatically render all of the math inside of text. It searches all of the text nodes within a...
Read more >KaTeX does not render - Stack Overflow
The method renderMathInElement() is used in KaTeX's autorender documentation: katex.org/docs/autorender.html. I was able to work with katex.
Read more >koa-views - npm
Example. var views = require('koa-views'); const render ... const render = views(__dirname, { autoRender: false, extension: 'pug' }) ...
Read more >Publishing Extensions - Visual Studio Code
I get 403 Forbidden (or 401 Unauthorized) error when I try to publish my extension? One easy mistake to make when creating the...
Read more >Visualforce in Practice - Salesforce Developers
Basic Extension and Custom Controller Anatomy. ... All of this related metadata is used by the standard controller engine to auto-render a basic....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

You need to wait for the content in document.body to finish loading before running
renderMathInElement. This can be accomplished by moving thescripttag to the end ofbodyor by adding an event listener forDOMContentLoaded. See https://developer.mozilla.org/en-US/docs/Web/API/Window/DOMContentLoaded_event for the details on the latter approach.@Harrypotterrrr Looking at various pages about Jekyll + KaTeX, it looks like
math_engineis designed for MathJax, but you could then use mathtex-script-type to render the<script type="math/tex">tags.Alternatively, jekyll-katex suggests you can wrap your entire page in
{% katexmm %} ... {% endkatexmm %}and then use$...$as in LaTeX.