See {@link org.commonmark.ext.heading.anchor.HeadingAnchorExtension} or use {@link org.commonmark.ext.heading.anchor.IdGenerator} directly.