From 9d42f9eb735f2039c9c3b11fc96199075f07c175 Mon Sep 17 00:00:00 2001 From: Mimi <1119186082@qq.com> Date: Thu, 2 Jan 2025 16:38:45 +0800 Subject: [PATCH] release: v7.0.0 (#308) --- README.md | 17 +++++++++-------- package.json | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 4a1b6d4..880f380 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # hexo-renderer-marked -[![Build Status](https://github.com/hexojs/hexo-renderer-marked/workflows/Tester/badge.svg?branch=master)](https://github.com/hexojs/hexo-renderer-marked/actions?query=workflow%3ATester) +[![Tester](https://github.com/hexojs/hexo-renderer-marked/actions/workflows/tester.yml/badge.svg?branch=master)](https://github.com/hexojs/hexo-renderer-marked/actions/workflows/tester.yml) [![NPM version](https://badge.fury.io/js/hexo-renderer-marked.svg)](https://www.npmjs.com/package/hexo-renderer-marked) [![Coverage Status](https://img.shields.io/coveralls/hexojs/hexo-renderer-marked.svg)](https://coveralls.io/r/hexojs/hexo-renderer-marked?branch=master) [![NPM Dependencies](https://img.shields.io/librariesio/release/npm/hexo-renderer-marked.svg)](https://libraries.io/npm/hexo-renderer-marked) @@ -20,7 +20,7 @@ There are two solutions to avoid those issues: ## Installation -``` bash +```bash $ npm install hexo-renderer-marked --save ``` @@ -32,7 +32,7 @@ $ npm install hexo-renderer-marked --save You can configure this plugin in `_config.yml`. -``` yaml +```yml marked: gfm: true pedantic: false @@ -83,7 +83,7 @@ marked: - **figcaption** - Append `figcaption` element after each image. - **prependRoot** - Prepend root value to (internal) image path. * Example `_config.yml`: - ``` yml + ```yml root: /blog/ ``` * `![text](/path/to/image.jpg)` becomes `text` @@ -112,7 +112,7 @@ For more options, see [Marked](https://marked.js.org/using_advanced#options). Du To enable it, pass an object containing the DOMPurify options: -```json +```yml dompurify: true ``` @@ -173,10 +173,11 @@ This plugin overrides some default behaviours of how [marked] plugin renders the For example, to override how heading like `# heading text` is rendered: -``` js +```js hexo.extend.filter.register('marked:renderer', function(renderer) { const { config } = this; // Skip this line if you don't need user config from _config.yml - renderer.heading = function(text, level) { + renderer.heading = function({ tokens, depth: level }) { + const text = this.parser.parseInline(tokens); // Default behaviour // return `${text}`; // outputs

heading text

@@ -196,7 +197,7 @@ Notice `renderer.heading = function (text, level) {` corresponds to [this line]( It is also possible to customize the [tokenizer](https://marked.js.org/using_pro#tokenizer). -``` js +```js const { escapeHTML: escape } = require('hexo-util'); // https://github.com/markedjs/marked/blob/b6773fca412c339e0cedd56b63f9fa1583cfd372/src/Lexer.js#L8-L24 diff --git a/package.json b/package.json index ebb924a..a64a9d6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hexo-renderer-marked", - "version": "6.3.0", + "version": "7.0.0", "description": "Markdown renderer plugin for Hexo", "main": "index", "scripts": {