Skip to content

HamiltonHuaji/hexo-tag-github-code

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hexo-tag-github-code

Insert code from GitHub when static files are generated.

Not embed.

Install

$ npm install hexo-tag-github-code --save

Usage

{% ghcode URL [start_line stop_line] [options] %}

Support URL

GitHub / Gist

Other site

If URL links to raw file, it will work.

Options

Set like as {cap:false,re:true}. 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

Config setting

You can change default settings in _config.yml as below.

github_code:
  cap: false
  re: true

Examples

Full code

{% ghcode https://github.com/nkmk/hexo-list-related-posts/blob/master/lib/index.js %}

Selected lines

Insert code from line 17 to line 22.

{% ghcode https://github.com/nkmk/hexo-list-related-posts/blob/master/lib/index.js 17 22 %}

Selected lines

Without caption

{% ghcode https://github.com/nkmk/hexo-list-related-posts/blob/master/lib/index.js 17 22 {cap:false} %}

Without caption

Restart the first line number from 1

{% ghcode https://github.com/nkmk/hexo-list-related-posts/blob/master/lib/index.js 17 22 {re:true} %}

Restart the first line number from 1

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%