discourse/lib/tasks/highlight.rake
Sam a82530012a FEATURE: Allow selection of highlight js languages
PERF: stop loading highlight js on load

To get latest highlight js run bin/rake highlightjs:update
2015-03-13 16:18:59 +11:00

25 lines
918 B
Ruby

desc "download latest version of highlight and prepare it"
task "highlightjs:update" do
def run(cmd, opts={})
puts cmd
system(cmd, opts.merge(out: $stdout, err: :out))
end
run("cd tmp && rm -fr highlight.js && git clone --depth 1 https://github.com/isagalaev/highlight.js.git")
run("cd tmp && rm -fr highlight_distrib && mkdir -p highlight_distrib/lang")
run("cd tmp/highlight.js && npm install")
run("cd tmp/highlight.js && node tools/build.js -t cdn none")
run("mv tmp/highlight.js/build/highlight.min.js tmp/highlight_distrib/highlight.js")
run("cd tmp/highlight.js && npm install && node tools/build.js -t cdn")
Dir.glob("tmp/highlight.js/build/languages/*.min.js") do |path|
lang = File.basename(path)[0..-8]
run("mv #{path} tmp/highlight_distrib/lang/#{lang}.js")
end
run("rm -fr lib/highlight_js/assets")
run("mv tmp/highlight_distrib lib/highlight_js/assets")
end