Skip to content

Commit

Permalink
Merge pull request #106 from NachoSoto/master
Browse files Browse the repository at this point in the history
Fallback to `highlightAuto` if highlighting fails
  • Loading branch information
raspu authored Jul 29, 2024
2 parents fa483d3 + b4f3b0c commit bcf2d05
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 bcf2d05

Please sign in to comment.