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

Plugins loaded but now working #71

Closed
alphamodel opened this issue Jun 9, 2020 · 1 comment
Closed

Plugins loaded but now working #71

alphamodel opened this issue Jun 9, 2020 · 1 comment

Comments

@alphamodel
Copy link

Following is the input js file:

const prism = require('markdown-it-prism');
const options = {
	plugins: ["line-highlight","show-language"]
};
md.use(prism, options);

console.log(md.render(`
\`\`\`python {3,5}
import os
import sys
\`\`\`
`
)); 

output file is following:

<pre class="language-python"><code class="language-python"><span class="token keyword">import</span> os
<span class="token keyword">import</span> sys

</code></pre>

It looks like the two plugins do not has any effects.

@jGleitz
Copy link
Owner

jGleitz commented Jun 11, 2020

Hi and thanks for reporting this bug!

Both line-highlight and show-language are plugins that rely on the DOM being present (although they would not need to do that). They are programmed to not do anything if there is no DOM (see line-highlight.js#3 and prism-show-language.js#3). There is no DOM when rendering markdown with markdown-it because markdown-it, like any Markdown parser, operates on text tokens. So, unfortunately, this is nothing we can fix in this plugin. The Prism plugins need to be re-written in order to make them work.

In this sense, this bug is a duplicate of #1, for which there already is a warning in the README:

Please note that some prism plugins (notably line-numbers) rely on the DOM being present and can thus not be used with this package (see #1).

Thus, I am going to close this bug. Sorry that we cannot be more helpful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants