Only create ToC for headings with links

What does this MR do and why?

Only create ToC for headings with links

If a heading in a file exists without a link inside it, creating items for the table of contents will through an error. A filter on headers ensures that only those elements that do have an ancore tag are added to the array. Affecting rich viewer render of AsciiDoc, reStructuredText.

Changelog: fixed

References

Screenshots or screen recordings

Before After
Screenshot_2025-08-19_at_17.45.20 Screenshot_2025-08-19_at_17.30.13
Screenshot_2025-08-19_at_17.45.20 dropdown not even rendered Screenshot_2025-08-19_at_17.42.09

How to set up and validate locally

  1. Go to a Project/Repository
  2. Click plus sign in the header and choose New file
  3. Create an example AsciiDoc file
  4. Go to a file and make sure that a dropdown for table of contents renders correctly.

Example file:

// Test.adoc
= Test Code
Jane Smith <jane@example.com>
:description: test article
:doctype:  article
:revdate:  12025-08-19
:doctype:  article
:hardbreaks-option:


// ================================================================================
== title 1
// ================================================================================
* here is some content




// ================================================================================
== title 2
// ================================================================================
* first list item

* second list item
	** with nested item




// ================================================================================
== title 3
// ================================================================================
* some extra text

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #539276 (closed)

Edited by Paulina Sedlak-Jakubowska

Merge request reports

Loading