# hexo-tag-github-code

> insert github code

Latest version **0.1.0** (published 2017-08-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install hexo-tag-github-code
pnpm add hexo-tag-github-code
yarn add hexo-tag-github-code
bun add hexo-tag-github-code
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2017-08-11 |
| First published | 2017-08-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Author | nkmk |
| Maintainers | nkmk |

## Links

- npm: https://www.npmjs.com/package/hexo-tag-github-code
- Repository: https://github.com/nkmk/hexo-tag-github-code
- Homepage: https://github.com/nkmk/hexo-tag-github-code#readme
- Issues: https://github.com/nkmk/hexo-tag-github-code/issues
- npm.io page: https://npm.io/package/hexo-tag-github-code

## Dependencies (1)

- [lodash.assign](https://npm.io/package/lodash.assign.md) ^4.2.0

## Recent versions

- 0.1.0 (latest) — 2017-08-11
- 0.0.0 — 2017-08-11

## README

# hexo-tag-github-code

Insert code from [GitHub](https://github.com/) when static files are generated.

Not embed.

## Install

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

## Usage
```
{% ghcode URL [start_line stop_line] [options] %}
```

## Support URL
### GitHub / Gist
- URL of each file page as below
  - https://github.com/nkmk/hexo-tag-github-code/blob/master/index.js
  - https://gist.github.com/nkmk/d60cdbcffdb60d624ac01871543f79a2
  - https://gist.github.com/nkmk/d60cdbcffdb60d624ac01871543f79a2#file-sample-py
- URL links to raw file as below
  - https://raw.githubusercontent.com/nkmk/hexo-tag-github-code/master/index.js
  - https://gist.githubusercontent.com/nkmk/d60cdbcffdb60d624ac01871543f79a2/raw/e7528c00addcdd0b4d00cb9bbd8d225cc132fbfc/sample.py

### 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<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` |

### Config setting

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

```yml
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](https://i.gyazo.com/babfb9ad3851b5a3f4267636ccc8a70d.png)

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

![Without caption](https://i.gyazo.com/d1e0f94c5041371fc26e5bdc9033edf6.png)

### 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](https://i.gyazo.com/dc3611fc637352bbe5c57bf7d94f60f2.png)

---
_Source: https://npm.io/package/hexo-tag-github-code · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
