hexo-renderer-markdown-it-jzj

5.0.3 • Public • Published

hexo-renderer-markdown-it

This is a forked version of hexo-renderer-markdown-it

We can write markdown file using relative path to refer the images with markdown grammar.

When rendering images in markdown, the renderer will copy the images from source/_posts to public/blog-imgs and keep the same directory structure. And then fix the src attribute.

For example:

  1. Hexo source dir is /Users/xx/blog/source/
  2. Post path is /Users/xx/blog/source/_posts/dir/name.md
  3. Post refers an image with relative path img/pic.png
  4. The real image path is /Users/xx/blog/source/_posts/dir/img/pic.png
  5. Image will be copied to /Users/xx/blog/public/blog-imgs/dir/img/pic.png
  6. Rendered src attribute in html is /blog-imgs/dir/img/pic.png

It is tested on Mac, but not tested on Windows and Linux.


Build Status npm version npm dependencies Coverage Status

This renderer plugin uses Markdown-it as a render engine on Hexo. Adds support for Markdown and CommonMark.

Main Features

  • Support for Markdown, GFM and CommonMark
  • Extensive configuration
  • Faster than the default renderer | hexo-renderer-marked
  • Safe ID for headings
  • Anchors for headings with ID
  • Footnotes
  • <sub> H2O
  • <sup> x2
  • <ins> Inserted

Installation

Follow the installation guide.

Options

markdown:
  preset: 'default'
  render:
    html: true
    xhtmlOut: false
    breaks: true
    linkify: true
    typographer: true
    quotes: '“”‘’'
  enable_rules:
  disable_rules:
  plugins:
  anchors:
    level: 2
    collisionSuffix: ''
    permalink: false
    permalinkClass: 'header-anchor'
    permalinkSide: 'left'
    permalinkSymbol: ''
    case: 0
    separator: ''

Refer to the wiki for more details.

Extensibility

This plugin overrides some default behaviors of how markdown-it plugin renders the markdown into html, to integrate with the Hexo ecosystem. It is possible to override this plugin too, without resorting to forking the whole thing.

For example, to enable unsafe links (which is disabled by default):

hexo.extend.filter.register('markdown-it:renderer', function(md) {
  const { config } = this; // Skip this line if you don't need user config from _config.yml
  md.validateLink = function() { return true; };
});

Save the file in "scripts/" folder and run Hexo as usual.

Refer to markdown-it API documentation.

Requests and bug reports

If you have any feature requests or bugs to report, you're welcome to file an issue.

Package Sidebar

Install

npm i hexo-renderer-markdown-it-jzj

Weekly Downloads

0

Version

5.0.3

License

MIT

Unpacked Size

17.5 kB

Total Files

6

Last publish

Collaborators

  • jzj1993