+
Skip to content

highlightAuto does not produce any output if it can't find a suitable language #63

Open
@tmcw

Description

@tmcw

👋 Hey Titus!

I'm using lowlight and noticed something unusual - if I rely on highlightAuto, the behavior is that, if none of the listed languages have any relevance reported here:

if (

Then the fallback behavior is to output nothing:

lowlight/lib/index.js

Lines 174 to 180 in 0f36148

return (
result || {
type: 'root',
children: [],
data: {language: undefined, relevance}
}
)

This is pretty different behavior than highlight.js's automode, in which plaintext is always included as an option:

https://github.com/highlightjs/highlight.js/blob/main/src/highlight.js#L687

That behavior would be ideal - the 'empty' result here isn't all that easy to detect, and it's not super clean to generate the plaintext highlighted result myself.

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

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载