diff --git a/README.md b/README.md index da4a72f..955fa78 100644 --- a/README.md +++ b/README.md @@ -30,12 +30,13 @@ If URL links to raw file, it will work. ## Options -Set like as `{cap:false,re:true}`. Please do __NOT__ insert any spaces. +Set like as `{cap:false,re:true,lang:javascript}`. Please do __NOT__ insert any spaces. | option | description | default | | :--- | :--- | :--- | | cap| `true`: show caption
`false`: no caption | `true` | | re| `true`: the first line number restart from 1
`false`: the first line number start from original code number | `false` | +| lang| the language to use for highlighting | the extension of the file | ### Config setting @@ -76,3 +77,8 @@ Insert code from line 17 to line 22. ``` ![Restart the first line number from 1](https://i.gyazo.com/dc3611fc637352bbe5c57bf7d94f60f2.png) + +### Force the language highlighting to HTML for a JavaScript file +``` +{% ghcode https://github.com/nkmk/hexo-list-related-posts/blob/master/lib/index.js 17 22 {lang:html} %} +``` diff --git a/index.js b/index.js index 840773d..3d12cb1 100644 --- a/index.js +++ b/index.js @@ -33,7 +33,7 @@ function str2obj(s){ function get_result(data, url, raw_url, start, stop, options, codeTag){ var split_data = data.split(/\r\n|\r|\n/).slice(start - 1, stop).join('\n') - var ext = path.extname(raw_url).slice(1) + var ext = (options['lang'] || path.extname(raw_url).slice(1)) var basename = path.basename(raw_url) var arg if(options['cap']){