Skip to content

Keep inline formatting in list items and table cells - #29

Closed
trsdn wants to merge 1 commit into
fix/17-nested-list-duplicationfrom
fix/15-inline-formatting-lists-tables
Closed

trsdn wants to merge 1 commit into
fix/17-nested-list-duplicationfrom
fix/15-inline-formatting-lists-tables

Conversation

@trsdn

@trsdn trsdn commented Aug 19, 2026

Copy link
Copy Markdown
Owner

Fixes #15.

Stacked on #28 — based on fix/17-nested-list-duplication, so review that one first. The diff shown here is only this change once #28 merges.

Problem

ConvertListItem and ConvertTable both read content via InnerText, which flattens all markup to plain text. The converter already handles <strong>, <em>, <code>, <a> and <s> properly — that pipeline was simply bypassed in the two places formatting appears most often.

Change

  • List items and table cells now go through ConvertChildren, the same path used everywhere else.
  • List items convert a copy of the <li> with nested lists detached, so nested content is still emitted separately as indented items rather than being inlined.
  • Item and cell text is collapsed onto a single line, so a cell containing <br> or block children can no longer break the pipe table across rows.
  • | inside a cell is escaped as \|, which previously split the cell into two columns.

Verification

Ran against the pinned HtmlAgilityPack 1.11.72.

Input Before After
<li>See <a href="…">docs</a> for <strong>details</strong></li> - See docs for details - See [docs](https://example.com) for **details**
<td><strong>Bold</strong></td> | Bold | | **Bold** |
<td>a|b</td> | a|b | (breaks the table) | a\\|b |

Nested-list output from #28 is unchanged, and existing task-list detection (☑/☐ prefix) still works because the prefix survives conversion.

dotnet build -c Release -r win-x64 succeeds with 0 warnings.

Scope

Text nodes are still emitted unescaped — tracked separately in #16.

Both list items and table cells pulled their content from InnerText, which
flattens markup to plain text. The converter already handles strong, em,
code, links and strikethrough correctly, but that pipeline was bypassed in
the two places formatting appears most often, so bold text and links were
silently dropped from every bullet and every cell.

Run both through ConvertChildren instead. List items convert a copy with
the nested lists detached, so nested content is still emitted separately as
indented items. Cell and item text is collapsed onto a single line, and
pipes inside cells are escaped so the table stays well formed.

Before:
    - See docs for details
    | Bold | see link |

After:
    - See [docs](https://example.com) for **details**
    | **Bold** | see [link](https://x.test) |

Fixes #15

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: b721ad5f-9add-4f55-b9c8-7e6d7b0fb3e7
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.

1 participant