Skip to content

Commit

Permalink
Added filter marked:use for direct access to the marked.use function (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
crycode-de committed Apr 1, 2024
1 parent 1b09354 commit b6ac346
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,17 @@ hexo.extend.filter.register('marked:extensions', function(extensions) {
});
```

You may also get access to `marked.use` function.
For example to use the [marked-alert](https://github.com/bent10/marked-extensions/tree/main/packages/alert) extention wich also provides a `walkTokens` functions:

```js
const markedAlert = require('marked-alert');

hexo.extend.filter.register('marked:use', function (markedUse) {
markedUse(markedAlert());
});
```

[Markdown]: https://daringfireball.net/projects/markdown/
[marked]: https://github.com/chjj/marked
[PHP Markdown Extra]: https://michelf.ca/projects/php-markdown/extra/#def-list
3 changes: 3 additions & 0 deletions lib/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@ module.exports = function(data, options) {
const { prependRoot, postAsset, dompurify } = markedCfg;
const { path, text } = data;

// exec filter to extend marked
this.execFilterSync('marked:use', marked.use, { context: this });

// exec filter to extend renderer.
const renderer = new Renderer(this);
this.execFilterSync('marked:renderer', renderer, { context: this });
Expand Down

0 comments on commit b6ac346

Please sign in to comment.