Skip to content

Commit

Permalink
Fallback to highlightAuto if highlighting fails
Browse files Browse the repository at this point in the history
Same as raspu#96 but without the CSS changes.
Some change in 2.2.0 made this issue resurface.
  • Loading branch information
NachoSoto committed Jul 22, 2024
1 parent fa483d3 commit 17b2ed9
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Pod/Classes/Highlightr.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,13 @@ open class Highlightr
let ret: JSValue?
if let languageName = languageName
{
ret = hljs.invokeMethod("highlight", withArguments: [code, ["language": languageName, "ignoreIllegals": ignoreIllegals]])


let result: JSValue = hljs.invokeMethod("highlight", withArguments: [languageName, code, ignoreIllegals])
if result.isUndefined {
// If highlighting failed, use highlightAuto
ret = hljs.invokeMethod("highlightAuto", withArguments: [code])
} else {
ret = result
}
}else
{
// language auto detection
Expand Down

0 comments on commit 17b2ed9

Please sign in to comment.