Skip to content

highlight.js generates no HTML class name when "wrap: false" and "hljs: false" #111

@seaoak

Description

@seaoak

This issue is the behavior of lib/highlight.js.

In case of wrap: false:
If hljs: true, an HTML class name hljs appears in the output.
If hljs: false, no HTML class name appears in the output.

It is a lack of consistency.

I think an HTML class name highlight should appear as well as when wrap: true.

And also, the output for hljs: false lacks a PRE element and a CODE element.
That is, no HTML element appears around the output.
It is a lack of consistency, too.

Expected behavior

The output of util.highlight('alert("foobar")', {wrap: false}) is:

<pre><code class="highlight">alert(&quot;foobar&quot;)</code></pre>

Actual behavior

alert(&quot;foobar&quot;)

How to reproduce?

$ node
> const util = require('.')
undefined
> util.highlight('alert("foobar")', {wrap: false})
'alert(&quot;foobar&quot;)'
> util.highlight('alert("foobar")', {wrap: false, hljs: true})
'<pre><code class="hljs undefined">alert(&quot;foobar&quot;)</code></pre>'
>

Environment & Settings

$ node -v
v8.16.2

$ npm -v
6.4.1

$ git log --oneline --decorate -1
b292332 (HEAD -> master, upstream/master, origin/master, origin/HEAD) Merge pull request #109 from curbengh/toc

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions