Make slug for each headings and assign to id
attribute
#338
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Marp Core now makes a compatible slug with GitHub for each headings, and assign to
id
attribute.# Hello, world!
It has got to be compatible with Markdown Language Server to improve IDE integrations.
Customization
When integrating Marp Core with Web app, the user-generated
id
may conflict with exist ids using in the app. So the developer can tweak slug generation throughslug
constructor option.slug
:boolean
|function
|object
true
(default): Enable GitHub-compatible slugify to each headings.false
: Disable slugify. It's helpful when showing unpredictable Markdown input on the web page.Function
: Define custom slugifier.Object
:slugifier
: Define custom slugifier.postSlugify
: Define custom post process that would be invoked before assigning the slug toid
attribute. It is useful for appending prefix or suffix to avoid duplicated IDs.Combination with Marpit's
anchor
optionMarpit framework also has an
anchor
option to assignid
to each slides. If a generated slug was conflicted with already generated anchors by Marpit, Marp Core will add a number suffix to avoid duplicated IDs by the defaultpostSlugify
function.# 1
ToDo
Close #299.