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

Prism formating issue on JS code that create formatter #523

Closed
jcubic opened this issue Sep 9, 2019 · 3 comments
Closed

Prism formating issue on JS code that create formatter #523

jcubic opened this issue Sep 9, 2019 · 3 comments
Labels
Bug resolved if issue is resolved, it will be open until merge with master

Comments

@jcubic
Copy link
Owner

jcubic commented Sep 9, 2019

Expected behavior

JS code should be highlighted properly

Actual behavior

JS code is brokan

Steps to reproduce

Try to format this javascript with prism:

    $.terminal.defaults.formatters.push(function(string) {
        return string.replace(/([^`]|^)`([^`]+)`([^`]|$)/g, '$1[[b;#fff;]$2]$3');
    });

it's part of chat.js on terminal website. (formatting of text inside back ticks).

You can see this with less command with this demo https://codepen.io/jcubic/pen/zEyxjJ

and type:

less https://terminal.jcubic.pl/js/chat.js

@jcubic
Copy link
Owner Author

jcubic commented Sep 9, 2019

The problem is in Prism

this works:

term.echo($.terminal.prism('javascript', '/xxx`xx`yyy/'))

but this is broken:

$.get('https://terminal.jcubic.pl/js/chat.js').then((text) => {
   term.echo($.terminal.prism('javascript', text));
});

@jcubic jcubic added the Bug label Sep 9, 2019
@jcubic
Copy link
Owner Author

jcubic commented Sep 9, 2019

This is also broken, (this should be tested):

$.get('https://terminal.jcubic.pl/js/chat.js').then((text) => {
   term.echo($.terminal.prism('javascript', $.terminal.escape_brackets(text)));
});

Not sure if you can make formatters in source code work with prism (such meta).

@jcubic
Copy link
Owner Author

jcubic commented Sep 14, 2019

fixed in #410 by 17d903f

There is one not related issue with wrapping though.

@jcubic jcubic added the resolved if issue is resolved, it will be open until merge with master label Sep 14, 2019
@jcubic jcubic closed this as completed Nov 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug resolved if issue is resolved, it will be open until merge with master
Projects
None yet
Development

No branches or pull requests

1 participant