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

'<' and '>' gets escaped twice when used with Prismjs #30

Open
uadarsh opened this issue Oct 8, 2020 · 1 comment
Open

'<' and '>' gets escaped twice when used with Prismjs #30

uadarsh opened this issue Oct 8, 2020 · 1 comment

Comments

@uadarsh
Copy link

uadarsh commented Oct 8, 2020

I am trying to use the library along with Prism highlighting to render a notebook's content. It seems like the notebookjs library html-escapes the '<' and '>' characters before passing it to the highlighter. The highlighter treats it as the actual code and renders it as such by tokenising < and >

Anyway to disable escaping or any recommended way to handle this situation?

I am using the code given on the site to use prism highlighting. ie

`var Prism = require('prismjs');

var highlighter = function(code, lang) {
if (typeof lang === 'undefined') lang = 'markup';

if (!Prism.languages.hasOwnProperty(lang)) {
    try {
        require('prismjs/components/prism-' + lang + '.js');
    } catch (e) {
        console.warn('** failed to load Prism lang: ' + lang);
        Prism.languages[lang] = false;
    }
}
return Prism.languages[lang] ? Prism.highlight(code, Prism.languages[lang]) : code;

};
var nb = require("notebookjs");
nb.highlighter = function(text, pre, code, lang) {
var language = lang || 'text';
pre.className = 'language-' + language;
if (typeof code != 'undefined') {
code.className = 'language-' + language;
}
return highlighter(text, language);
};`

@jsvine
Copy link
Owner

jsvine commented Nov 10, 2020

Hi @uadarsh and thanks for your interest in this repository. Could you provide a simple, reproducible example that demonstrates the issue you're encountering? That would include a specific notebook as well as the code to render it.

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

No branches or pull requests

2 participants