Skip to content

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

@iabw

Description

@iabw

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions