Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<br> `false`: no caption | `true` |
| re| `true`: the first line number restart from 1<br> `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

Expand Down Expand Up @@ -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} %}
```
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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']){
Expand Down