Comments (6)
Hmm, I just tested the following:
equal(
md({ html: true }).use(anchor).render('#### <code>options</code>'),
'<h4 id="options"><code>options</code></h4>\n'
)
And it actually passes. What versions of markdown-it and markdown-it-anchor are you using?
Edit: ha, the following indeed have empty ID, I need to fix this.
equal(
md().use(anchor).render('#### `options`'),
'<h4 id="options"><code>options</code></h4>\n'
)
from markdown-it-anchor.
I fixed both issues; the inline code is now also used to generate the ID, and you can pass an array of header levels to select in the level
option.
It's published as of 4.0.0.
Note that I also dropped Babel support in 4.0.0 so this module only works with a Node version with ES6 support.
from markdown-it-anchor.
Makes sense. Initially my thought was mostly to exclude h1
because the page I was working on had only one h1
and I didn't want give it an anchor, that's why it works this way.
But it think it would be a good idea to make level
more flexible, supporting something like level: [1, 3]
in your case.
I'll give it a shot over the week-end.
from markdown-it-anchor.
Thats great, an array with the levels where you want to have ids/anchors.
My issue is because i have headings like:
<h4><code>options</code></h4>
<ul>
<li>active: true</li>
<li>...</li>
</ul>
And because my heading doesn't contain text, it's generated like <h4 id=""><code>...</code></h4>
, which is invalid. So i want to disable this functionality in <h4>
headings, where i usually put code tags.
from markdown-it-anchor.
Oh, interesting, I'd also consider this as a bug, the ID should be a slugified version of the code too. I'm looking into this.
from markdown-it-anchor.
Works great, thanks!
from markdown-it-anchor.
Related Issues (20)
- Add container around heading and anchor HOT 3
- Expose custom options regardless of permalink styles HOT 4
- Headings containing a hashtag yield invalid hrefs HOT 2
- Headers in html_block Tokens aren't given slugs HOT 11
- Add <span> inside permalink.headerLink style until safari reader more is fixed HOT 1
- incorrect type for permalink.headerLink() HOT 2
- Feature request: container option for linkAfterHeader HOT 5
- KaTeX Expressions aren't Included in Headings HOT 4
- Should return type for `PermalinkGenerator` be `void` instead of `string`? HOT 1
- Missing `wrapper` property in `LinkAfterHeaderPermalinkOptions` type HOT 1
- Add brief description of what plugin does to top of readme. HOT 1
- Types invalid with `"type": "module"` and `"moduleResolution": "Node16"` HOT 7
- @types in peerDeps HOT 2
- TypeError: c.attrGet is not a function HOT 1
- Missing #todo-anchor-or-file header in README HOT 1
- Exception 'plugin.apply is not a function' HOT 2
- Colon in header doesn't work HOT 6
- Upgrade markdown-it types to v14 HOT 1
- more icons for "symbol" HOT 3
- Query: How do I attach a class to the header element? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from markdown-it-anchor.