alpinelinux / turbo-paste

[MIRROR] Turbo paste
https://gitlab.alpinelinux.org/alpine/infra/turbo-paste
MIT License
13 stars 5 forks source link

turbo-paste, add get option format (feature request) #1

Open insteps opened 9 years ago

insteps commented 9 years ago

Pls have a look, https://gist.github.com/insteps/70315bcaeb4b28734138

This is just to let know some alternate option available in highlightjs. I am not still sure if adding highlight2.tpl would be needed. So not creating a pull request.

I would likely merge highlight2.tpl template to original highlight.tpl. i.e, without &format= set {{{format}}} is empty.

clandmeter commented 9 years ago

Yes, i was thinking of adding a specific format option to hl. Actually I think i prefer hl as it is shorter, and we can use it like hl=sh or hl=lua I have opened an issue to add the option to allow a empty argument here https://github.com/kernelsauce/turbo/issues/205 This would set the auto mode for highlight.js instead of using a boolean.

A single mustache template for hightlight should be enough. Check https://mustache.github.io/mustache.5.html how to use mustache.

P.S. Why did you use

var body = document.getElementById('body');
codes = body.getElementsByTagName('code');
for (c in codes) { codes[c].className='{{{format}}}'; hljs.highlightBlock(codes[c]); }

when you could simply set the class on the code tag like mentioned here https://highlightjs.org/usage

insteps commented 9 years ago

yes, true ! was thinkin something else while trying to learn lua ;)