How to prevent change header id in content macro?

Hello, i type in content macro some markdown (1.2) text with headers.
For example

    ## setEvent
    some text about events

and i supose header id link will: "#setevent", but Xwiki append liter H before my header (id="Hsetevent"). How can i prevent it?

Auto-generated heading anchors are prefixed with Hindeed. If you want to control the anchor you need to use the {{id}} macro: https://extensions.xwiki.org/xwiki/bin/view/Extension/Id%20Macro

Thanks, but it’s not good enough solution if i will automatically get text (.md) from other resources (such as GitHub), because it broke original structure of .md file

It’s currently quite difficult to overwrite the default id generation when rendering to (X)HTML. It’s done here FYI: xwiki-rendering/DefaultXWikiGeneratorListener.java at 1ec9ee195884a7b057da4211aca950d52cdd8b12 · xwiki/xwiki-rendering · GitHub

Could you explain the problem (i.e. why Hsetevent is a problem)?

For example i clone repository with jgit and place text from readme.md into xwiki page via {{content}} macro. If orirginal readme.md has TOC it will be broken because all orirgin headers will change to “H+header text

You mean something like:

= TOC =

{{toc/}}

Hello world.

{{content syntax="markdown/1.2"}}
Description
===========

Custom Docker images for the XWiki project, used to spawn Jenkins Agents for https://ci.xwiki.org.

Two images are available:
  * [`xwiki/build`](./build) Minimum configuration to build XWiki Platform.
  * [`xwiki/build-android`](./build-android) Based on the previous one, also contains an Android SDK to build XWiki Android applications.
  * [`xwiki/build-oracle`](./build-oracle) Custom Oracle Database 19.3.0 Standard Edition image to test XWiki on Oracle.
{{/content}}

?

Viewable at VMA (Main.VMA.WebHome) - XWiki till tonight.

1 Like

(Note that this is working)

thanks, but i mean situation when a original readme.md has manually made links (see bellow). This links will broken when you put it into content macro

    {{content syntax="markdown/1.2"}}

*  [header1](#header1)
*  [header2](#header2)

# Header 1
something text

# Header 2
something text

    {{/content}}

ok, this is a known bug of the Markdown Parser in XWiki. It should honor anchors. See http://jira.xwiki.org/browse/MARKDOWN-59

1 Like