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

Unexpected Pygments Output in <v1.0.0 results in visible '----DIVIDER----' comments #107

Open
iabw opened this issue Nov 4, 2016 · 0 comments

Comments

@iabw
Copy link

iabw commented Nov 4, 2016

First, thanks for the library, been using it for a while. I just wanted to document this problem I ran into, even though it's for the last version and from what I can tell completely inapplicable to v1.

I was looking to add the Velocity templating language to the available languages in version 0.2.x

I figured I'd be able to easily add it, but it was breaking rather bizarrely due to the highlighted HTML that Pygments outputs not matching the regex used to split its output. As a result, the code was being output in a giant clump in the first section, with all the '----DIVIDER----' comments intact, and all the rest of the sections had 'undefined' for their code.

The html the regex expected (and was being generated for other languages) looked like
<span class="err">##</span><span class="x">----DIVIDER----</span>

and what I was getting was
<span class="cp">##</span><span class="c">----DIVIDER----</span><span class="x"></span>

I fixed this by changing that regex line at docker.js#L1061 to
var bits = out.split(/^<span[^>]*>[^<]+(?:<\/span><span[^>]*>)?----DIVIDER----[^<]*(?:<\/span><span[^>]*>)?<\/span>$/gm);

This just copies the same optional span detecting block after the DIVIDER block, and now it works.

iabw added a commit to iabw/docker that referenced this issue Nov 4, 2016
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

1 participant