Skip to content

Commit

Permalink
Fix generation of header IDs (#566)
Browse files Browse the repository at this point in the history
* Stop creating HTML ID generator if generateHeaderId = false (and renderHeaderID = true)

* Ensure header ID is not empty
  • Loading branch information
travkin79 authored Apr 30, 2023
1 parent d58e370 commit 421354a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ public void dispose() {
this.myLinkResolvers = new LinkResolver[linkResolverFactories.size()];
this.doNotRenderLinksNesting = htmlOptions.doNotRenderLinksInDocument ? 0 : 1;
this.htmlIdGenerator = htmlIdGeneratorFactory != null ? htmlIdGeneratorFactory.create(this)
: (!(htmlOptions.renderHeaderId || htmlOptions.generateHeaderIds) ? HtmlIdGenerator.NULL : new HeaderIdGenerator.Factory().create(this));
: (!(htmlOptions.generateHeaderIds) ? HtmlIdGenerator.NULL : new HeaderIdGenerator.Factory().create(this));

htmlWriter.setContext(this);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void render(Document node, NodeRendererContext context, HtmlWriter html) {
void render(Heading node, NodeRendererContext context, HtmlWriter html) {
if (context.getHtmlOptions().renderHeaderId) {
String id = context.getNodeId(node);
if (id != null) {
if (id != null && id.length() > 0) {
html.attr("id", id);
}
}
Expand Down

0 comments on commit 421354a

Please sign in to comment.