8000 Option to turn off header anchor generation · Issue #373 · gjtorikian/commonmarker · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Option to turn off header anchor generation #373

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
satoryu opened this issue May 14, 2025 · 3 comments
Closed

Option to turn off header anchor generation #373

satoryu opened this issue May 14, 2025 · 3 comments

Comments

@satoryu
Copy link
satoryu commented May 14, 2025

Commonmarker automatically inserts an tag in front of every header.

Given the Markdown

## title

calling to_html produces:

<h2><a href="#title" aria-hidden="true" class="anchor" id="title"></a>title</h2>

I’d like to stop Commonmarker from adding these anchor links when converting Markdown.

Is there an option to disable this behavior?

@kivikakk
Copy link
Collaborator

Yes! This is the header_ids extension option. See:

> Commonmarker.to_html("## abc", options: {extension: {header_ids: ""}})  # default
=> "<h2><a href=\"#abc\" aria-hidden=\"true\" class=\"anchor\" id=\"abc\"></a>abc</h2>\n"
> Commonmarker.to_html("## abc", options: {extension: {header_ids: nil}})
=> "<h2>abc</h2>\n"

@satoryu
Copy link
Author
satoryu commented May 14, 2025

Thank you @kivikakk !

@kivikakk
Copy link
Collaborator

My pleasure! 😸 🧡

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0