Skip to content
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

support for header custom anchor ids #519

Open
lila opened this issue Oct 17, 2024 · 3 comments
Open

support for header custom anchor ids #519

lila opened this issue Oct 17, 2024 · 3 comments

Comments

@lila
Copy link

lila commented Oct 17, 2024

Is your feature request related to a problem? Please describe.

if the markdown contains custom header anchor ids, then the cross referencing links that are produced by mark don't respect the custom ids. in fact, the custom ids become visible in the html as part of the header.

markdown custom header ids are pretty common: https://www.markdownguide.org/extended-syntax/#heading-ids

when using mark, my header is for example:

# Leveling Guide {#leveling-guide}

the html for this fragment becomes:

<h1 id="leveling-guide-leveling-guide">Leveling Guide {#leveling-guide}</h1>

see what it did there? it concatenated the custom id with the regular default header id.

but the references to that anchor are still

<p><a href="#leveling-guide"><strong>Leveling Guide     4</strong></a></p>

so perhaps this is a bug. at the end of the day, the anchor custom id shows up visible in the html and the links are broken.

Describe the solution you'd like

the custom anchor id should not be visible in the html, and the html anchor should exactly match the custom id if present.

<h1 id="leveling-guide">Leveling Guide</h1>

Describe alternatives you've considered

given that my markdown is being exported from google docs, i don't have any options execept to manually remove the custom id specs.

Additional context

i think this is a bug not a feature request. cheers,

. k

@lila
Copy link
Author

lila commented Oct 17, 2024

i guess i can strip out the custom anchor ids with a sed script. then the html output is consistent.

however, confluence messes with the ids as well. when i push to confluence and look at the html, it comes out as:

<h1 id="InterviewGuidelines-LevelingGuide">Leveling Guide</h1>

where the first part is the pagename and the second is the header. while my references are still:

https://<stuff>#leveling-guide

:-(. oh well...

@mrueg
Copy link
Collaborator

mrueg commented Oct 17, 2024

anchors currently have some more issues, still something that needs to be looked at. If you have time to look into a fix, a PR is welcome!
See also:
#47
#492

@lila
Copy link
Author

lila commented Oct 18, 2024

i'll take a look...

but just as a workaround, my google docs had TOCs in them and those where the ones that were causing me issues. I removed the google doc TOC, exported to markdown and removed the custom ids sed 's/{.*}//g' input.md > input2.md and added the macro for toc in mark <!-- Include: ac:toc --> ... this pretty much works.

i think that any cross references in the google doc will fail. but i don't have them so far.

thanks for your quick reply.

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