如何在代码视图Swift中使用Highliter.js添加行号

时间:2018-02-19 08:11:40

标签: ios swift highlight.js

我正在使用follwing库创建代码检测器 https://github.com/Meniny/HighlightJS.swift

但它不是行号。他们是一个可以与highlight.js https://github.com/wcoder/highlightjs-line-numbers.js/集成的库。我正在努力将它与Highlighter.js集成但没有运气

bellow是代码段

jsContext = JSContext()
jsContext.evaluateScript("var window = {};")
bundle = Bundle(for: Highlightr.self)

guard let hgPath = bundle.path(forResource: "highlight.min", ofType: "js") else
{
    return nil
}

guard let ngPath = bundle.path(forResource: "highlightjs-line-numbers.min", ofType: "js") else
{
    return nil
}

let hgJs = try! String.init(contentsOfFile: hgPath)
let ngJs = try! String.init(contentsOfFile: ngPath)
var value = jsContext.evaluateScript(hgJs)
value = jsContext.evaluateScript(ngJs)
if !(value?.toBool())!
{
    return nil
}



guard setTheme(to: "pojoaque") else
{
    return nil
}

任何人都可以帮助我,谢谢

0 个答案:

没有答案