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

Issue with code highlighting using highlightjs #339

Open
derberg opened this issue Jul 25, 2014 · 2 comments
Open

Issue with code highlighting using highlightjs #339

derberg opened this issue Jul 25, 2014 · 2 comments

Comments

@derberg
Copy link

derberg commented Jul 25, 2014

added usage for highlight.js

var editor = new EpicEditor(opts).load();
editor.on('update', function () {
document.querySelector('#epiceditor-preview').innerHTML = this.exportFile(null, 'html');
$(document).ready(function() {
  $('pre code').each(function(i, e) {hljs.highlightBlock(e)});
});
}).emit('update');

almost all if fine except of "no-highlight" usage
it just doesn't work because of the problem with one regex in epiceditor.js

I had to add/change the following to accept "-" as well:

block.gfm = merge({}, block.normal, {
  fences: /^ *(`{3,}|~{3,}) *(\w+|\w+\-\w+)? *\n([\s\S]+?)\s*\1 *(?:\n+|$)/,
  paragraph: /^/
});

It is still some kind of workaround because epiceditor.js is adding languages reference in the following way:
lang-no-highlight hljs css

  • css is random, it sometimes it is ruby or json
  • lang-no-highlight should not be there

correct generated class should be:

  • hljs no-highlight
@zethussuen
Copy link
Collaborator

Should probably look into some of the async vs sync highlighting suggestions on https://github.com/chjj/marked#highlight

@paulocheque
Copy link

Is this fixed?

I tested with your code and it worked perfectly.

      editor.on('update', function () {
        document.querySelector('#epiceditor-preview').innerHTML = this.exportFile(null, 'html');
        $(document).ready(function() {
          $('pre code').each(function(i, e) {hljs.highlightBlock(e)});
        });
      }).emit('update');

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

3 participants