Skip to content

Commit

Permalink
feat: Support markdown-it-attrs (#174)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cerallin authored Aug 30, 2022
1 parent 242bf09 commit 1af5036
Show file tree
Hide file tree
Showing 13 changed files with 27 additions and 2 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,9 @@ markdown:
# Minimum level for ID creation. (Ex. h2 to h6)
level: 2
# A suffix that is prepended to the number given if the ID is repeated.
collisionSuffix: ''
collisionSuffix: ''
# If `true`, creates an anchor tag with a permalink besides the heading.
permalink: false
permalink: false
# Class used for the permalink anchor tag.
permalinkClass: header-anchor
# Set to 'right' to add permalink after heading
Expand All @@ -267,6 +267,7 @@ markdown:
Included plugins:
- markdown-it-abbr
- markdown-it-attrs
- markdown-it-cjk-breaks
- markdown-it-container
- markdown-it-deflist
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"hexo-util": "^2.1.0",
"markdown-it": "^12.0.0",
"markdown-it-abbr": "^1.0.4",
"markdown-it-attrs": "^4.1.3",
"markdown-it-cjk-breaks": "^1.1.2",
"markdown-it-container": "^3.0.0",
"markdown-it-deflist": "^2.0.3",
Expand Down
4 changes: 4 additions & 0 deletions test/fixtures/markdownit.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,3 +221,7 @@ It converts "HTML", but keep intact partial entries like "xxxHTMLyyy" and so on.
::: warning
*here be dragons*
:::

### [Attributes](https://github.com/arve0/markdown-it-attrs) { data-attr=true }

This is an attribute example.
2 changes: 2 additions & 0 deletions test/fixtures/outputs/anchors.html
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,5 @@ <h3 id="Custom-containers"><a class="header-anchor" href="#Custom-containers">¶
<p>::: warning<br>
<em>here be dragons</em><br>
:::</p>
<h3 id="Attributes-data-attr-true"><a class="header-anchor" href="#Attributes-data-attr-true"></a><a href="https://github.com/arve0/markdown-it-attrs">Attributes</a> { data-attr=true }</h3>
<p>This is an attribute example.</p>
2 changes: 2 additions & 0 deletions test/fixtures/outputs/commonmark-deprecated.html
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,5 @@ <h3><a href="https://github.com/markdown-it/markdown-it-container">Custom contai
<p>::: warning
<em>here be dragons</em>
:::</p>
<h3><a href="https://github.com/arve0/markdown-it-attrs">Attributes</a> { data-attr=true }</h3>
<p>This is an attribute example.</p>
2 changes: 2 additions & 0 deletions test/fixtures/outputs/commonmark.html
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,5 @@ <h3 id="Custom-containers"><a href="https://github.com/markdown-it/markdown-it-c
<p>::: warning<br>
<em>here be dragons</em><br>
:::</p>
<h3 id="Attributes-data-attr-true"><a href="https://github.com/arve0/markdown-it-attrs">Attributes</a> { data-attr=true }</h3>
<p>This is an attribute example.</p>
2 changes: 2 additions & 0 deletions test/fixtures/outputs/custom.html
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,5 @@ <h3 id="Custom-containers"><a href="https://github.com/markdown-it/markdown-it-c
<p>::: warning<br />
<em>here be dragons</em><br />
:::</p>
<h3 id="Attributes-data-attr-true"><a href="https://github.com/arve0/markdown-it-attrs">Attributes</a> { data-attr=true }</h3>
<p>This is an attribute example.</p>
2 changes: 2 additions & 0 deletions test/fixtures/outputs/default-disable_rules.html
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,5 @@ <h3 id="Custom-containers-https-github-com-markdown-it-markdown-it-container">[C
<p>::: warning<br>
<em>here be dragons</em><br>
:::</p>
<h3 id="Attributes-https-github-com-arve0-markdown-it-attrs-data-attr-true">[Attributes](https://github.com/arve0/markdown-it-attrs) { data-attr=true }</h3>
<p>This is an attribute example.</p>
2 changes: 2 additions & 0 deletions test/fixtures/outputs/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,5 @@ <h3 id="Custom-containers"><a href="https://github.com/markdown-it/markdown-it-c
<p>::: warning<br>
<em>here be dragons</em><br>
:::</p>
<h3 id="Attributes-data-attr-true"><a href="https://github.com/arve0/markdown-it-attrs">Attributes</a> { data-attr=true }</h3>
<p>This is an attribute example.</p>
2 changes: 2 additions & 0 deletions test/fixtures/outputs/plugins.html
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ <h3 id="Custom-containers"><a href="https://github.com/markdown-it/markdown-it-c
<p>::: warning<br>
<em>here be dragons</em><br>
:::</p>
<h3 data-attr="true" id="Attributes"><a href="https://github.com/arve0/markdown-it-attrs">Attributes</a></h3>
<p>This is an attribute example.</p>
<hr class="footnotes-sep">
<section class="footnotes">
<ol class="footnotes-list">
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/outputs/zero-enable_rules.html
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,5 @@
<p>::: warning
*here be dragons*
:::</p>
<p>### <a href="https://github.com/arve0/markdown-it-attrs">Attributes</a> { data-attr=true }</p>
<p>This is an attribute example.</p>
2 changes: 2 additions & 0 deletions test/fixtures/outputs/zero.html
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,5 @@
<p>::: warning
*here be dragons*
:::</p>
<p>### [Attributes](https://github.com/arve0/markdown-it-attrs) { data-attr=true }</p>
<p>This is an attribute example.</p>
1 change: 1 addition & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ describe('Hexo Renderer Markdown-it', () => {
it('default', () => {
hexo.config.markdown.plugins = [
'markdown-it-abbr',
'markdown-it-attrs',
'markdown-it-container',
'markdown-it-deflist',
'markdown-it-emoji',
Expand Down

0 comments on commit 1af5036

Please sign in to comment.