Skip to content

Preserve list paragraph IDs and shorten long bookmark names - #15

Open
PiotrCzapla wants to merge 12 commits into
mainfrom
board-consent-packet
Open

Preserve list paragraph IDs and shorten long bookmark names#15
PiotrCzapla wants to merge 12 commits into
mainfrom
board-consent-packet

Conversation

@PiotrCzapla

@PiotrCzapla PiotrCzapla commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

These are PRs handles longer reference ids and add ability to cross refrence list items.

The desc. below is LLM authored, but reads well:

The converter now preserves list-paragraph IDs as Word bookmarks. It also shortens long bookmark names to fit Word's limit.

Fixes

  • Preserve IDs on list paragraphs. The list renderer now wraps a paragraph's text in a Word bookmark when the paragraph has an id. Previously, it emitted the text but omitted the bookmark. Paragraphs without an id remain unchanged.
  • Shorten long bookmark names. Names longer than 38 characters become the first 27 characters, an underscore, and 10 hex characters from the original ID's SHA-256 hash. The hash accounts for the part that truncation would discard. Both bookmarks and references use the same mapping. The 38-character length reserves two characters for the _n suffix used for caption-number bookmarks within Word's 40-character limit.

For example, this list paragraph now supplies a bookmark for the reference:

<ol>
  <li><p id="sec-setup__mic">Connect the microphone.</p></li>
</ol>
<p>See <a href="#sec-setup__mic" data-ref="text"></a>.</p>

mdhtml #65 handles includes and appends scope suffixes before returning MDHTML. For example, scope="__mic" turns sec-setup into sec-setup__mic. The dependency minimum is mdhtml>=0.1.40. This converter consumes those IDs as supplied. The existing reference-type lookup and h1 numbering reset are unchanged.

Indentation and pagination fixes are separate in #17.

Rendered example

These recording guides demonstrate the include-to-DOCX workflow with suffixed IDs and references. Markdown and reproduction steps.

Two recording guides with correct section references

Validation

37 converter tests passed on this PR branch. Tests check list-paragraph bookmarks and grouped references to suffixed IDs. Generated documents passed schema validation and Pandoc readback. Combined with #17, 40 converter tests and 16 downstream integration tests passed.

Use a separate heading numbering instance for each included scheme.
Namespace bookmark targets and shorten long names within Word's limit.
Keep headings with following content, support keep-together groups and
keep-rows tables, and avoid empty pages after table page breaks.
Require mdhtml 0.1.39 for the shared include-scoping implementation.

Validated with the stock-plan packet and renderer suites: 73 tests passed;
2 checkout-asset tests deselected. LibreOffice rendering was inspected.
Actual Microsoft Word verification remains pending because the Mac was
locked and Word automation timed out.
@jph00

jph00 commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

I've removed the private links from this PR too.

@jph00

jph00 commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

When you have a draft PR, please include something at the top clearly stating what's needed to move it out of draft.

Also please try to avoid dense AI prose in PR descriptions where possible - I am not following what's happening here.

@PiotrCzapla PiotrCzapla changed the title Preserve exhibit numbering and paragraph pagination Preserve scoped references in included documents Sep 9, 2026
@PiotrCzapla

Copy link
Copy Markdown
Contributor Author

When you have a draft PR, please include something at the top clearly stating what's needed to move it out of draft.

Also please try to avoid dense AI prose in PR descriptions where possible - I am not following what's happening here.

I've used drafts to indicate that I haven't reviewed the PR yet, which include fixing prose or adding short summaries. I'll figure out a better way to do it locally, so that this issues don't happen again.

@PiotrCzapla PiotrCzapla changed the title Preserve scoped references in included documents Preserve list paragraph IDs and shorten long bookmark names Sep 9, 2026
@PiotrCzapla
PiotrCzapla marked this pull request as ready for review September 9, 2026 21:11
@PiotrCzapla
PiotrCzapla requested a review from jph00 September 9, 2026 21:11
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

Successfully merging this pull request may close these issues.

2 participants