Skip to content

[Repo Assist] test+fix: add Markdown.ToLatex unit tests; fix level-6 heading bug#1170

Merged
dsyme merged 2 commits intomainfrom
repo-assist/improve-tolatex-tests-2026-04-15-2ee6c6130d0dfb23
Apr 17, 2026
Merged

[Repo Assist] test+fix: add Markdown.ToLatex unit tests; fix level-6 heading bug#1170
dsyme merged 2 commits intomainfrom
repo-assist/improve-tolatex-tests-2026-04-15-2ee6c6130d0dfb23

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

🤖 This is an automated pull request from Repo Assist.

Summary

Two related improvements to Markdown.ToLatex:

  1. Testing (Task 9): Add 29 direct unit tests for Markdown.ToLatex — this output format previously had zero unit test coverage (only obsolete file-comparison tests in TestFiles.fs and two indirect Literate tests).

  2. Bug fix (Task 3): Fix a bug where level-6 headings (######) produced invalid LaTeX output.


Bug Fix: Level-6 Headings in ToLatex

Root cause: LatexFormatting.fs matched heading levels 1–5 to LaTeX commands, but had | _ -> "" as the catch-all. For a level-6 heading, level = "", producing {content} — braces without any command prefix, which is invalid LaTeX.

Fix: Replace | _ -> "" with | _ -> @"\subparagraph". Since \subparagraph is the deepest LaTeX sectioning command, all headings at level 5 and above correctly map to it.

Example:

Before: {Level Six}   ← invalid LaTeX
After:  \subparagraph{Level Six}   ← valid

New Test Coverage

29 tests added to tests/FSharp.Markdown.Tests/Markdown.fs covering:

Feature LaTeX command
Heading level 1 \section*{...}
Heading level 2 \subsection*{...}
Heading level 3 \subsubsection*{...}
Heading level 4 \paragraph{...}
Heading level 5 \subparagraph{...}
Heading level 6 (new fix) \subparagraph{...}
Bold \textbf{...}
Italic \emph{...}
Inline code \texttt{...}
Link \href{url}{text}
Unordered list \begin{itemize}...\item...\end{itemize}
Ordered list \begin{enumerate}...\item...\end{enumerate}
Code block \begin{lstlisting}...\end{lstlisting}
Blockquote \begin{quote}...\end{quote}
Horizontal rule \noindent\makebox...
Table \begin{tabular} with bold headers
Image with alt \begin{figure}...\caption{...}...\end{figure}
Image without alt \includegraphics{...}
Special char escaping \#, \%, \&, \_
Inline math $E = mc^2$
Display math ($$) \begin{equation}...\end{equation}
EmbedParagraphs delegates to Render()
Empty document no error

Test Status

  • 346 markdown tests pass (up from 317 before this PR)
  • 143 literate tests pass — no regressions
  • Build: 0 warnings, 0 errors

Generated by 🌈 Repo Assist, see workflow run. Learn more.

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@97143ac59cb3a13ef2a77581f929f06719c7402a

github-actions Bot and others added 2 commits April 15, 2026 11:11
Previously Markdown.ToLatex had no direct unit test coverage — only
file-based comparisons in the obsolete TestFiles.fs and two indirect
tests through Literate.ToLatex.

Add 28 tests covering:
- Headings (all six levels: section*/subsection*/subsubsection*/paragraph/subparagraph)
- Inline formatting: bold (\textbf), italic (\emph), inline code (\texttt)
- Links (\href{url}{text})
- Images (\includegraphics) and images with alt text (figure + caption)
- Unordered list (\begin{itemize}) and ordered list (\begin{enumerate})
- Code blocks (\begin{lstlisting})
- Blockquotes (\begin{quote})
- Horizontal rule (\noindent\makebox...)
- Tables (\begin{tabular}) with bold headers
- LaTeX special character escaping (#, %, &, _)
- Inline math ($...$)
- Display math (5042...5042 parsed as LatexBlock → \begin{equation}...\end{equation})
- EmbedParagraphs delegation to Render()
- Empty document handling

All 345 markdown tests pass.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Level-6 headings (######) were mapped to an empty string in the LaTeX
sectioning command match, producing bare '{content}' without any command
prefix — invalid LaTeX. LaTeX has five sectioning levels:
\section*, \subsection*, \subsubsection*, \paragraph, \subparagraph.

Fix by treating any heading level > 5 as \subparagraph (the deepest
available LaTeX sectioning command), matching what most LaTeX documents
expect.

Also removes the now-dead case for level 5 (merged into the catch-all).

Test status: 346 markdown tests pass, 143 literate tests pass.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dsyme dsyme marked this pull request as ready for review April 17, 2026 10:38
@dsyme dsyme merged commit 741e912 into main Apr 17, 2026
@dsyme dsyme deleted the repo-assist/improve-tolatex-tests-2026-04-15-2ee6c6130d0dfb23 branch April 17, 2026 10:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant