Git Product home page Git Product logo

hexo-tag-ghcode's Introduction

hexo-tag-github-code

Taken over from hexo-tag-github-code, as the author nkmk has stopped maintaining the repository.

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,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

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

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} %}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.