-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Labels
enhancementNew feature or requestNew feature or requestminorMinor priority issueMinor priority issue
Description
Problem
BNF grammar blocks contain unconverted \textit{} LaTeX commands, reducing readability of grammar productions. The content is preserved (no data loss), but the formatting artifact makes the output less clean.
Affected Files
43 instances across 8 files:
- diagnostics.md: 1
- time.md: 6
- ranges.md: 3
- utilities.md: 25
- containers.md: 5
- compatibility.md: 1
- thread.md: 1
- input.md: 1
Examples
diagnostics.md (line 1685):
``` bnf
\textit{stacktrace-entry-format-spec}
fill-and-alignₒₚₜ widthₒₚₜ
**Expected:**
```markdown
``` bnf
stacktrace-entry-format-spec
fill-and-alignₒₚₜ widthₒₚₜ
**time.md (lines 7400, 7405, 7412, 7417, 7422, 7427):**
```markdown
``` bnf
\textit{chrono-format-spec}
fill-and-alignₒₚₜ widthₒₚₜ precisionₒₚₜ 'L'ₒₚₜ chrono-specsₒₚₜ
**Expected:**
```markdown
``` bnf
chrono-format-spec
fill-and-alignₒₚₜ widthₒₚₜ precisionₒₚₜ 'L'ₒₚₜ chrono-specsₒₚₜ
## Root Cause
1. LaTeX source uses `\fmtnontermdef{...}` for BNF non-terminal definitions
2. `simplified_macros.tex` converts this to `\textit{...}` (line 182)
3. `cpp-grammar.lua` filter does NOT handle `\textit{}` commands
4. Result: `\textit{}` wrapper appears in output
## Impact
- **Severity**: MINOR
- No data loss (content is preserved)
- Purely a presentation/readability issue
- Does not affect functionality of the specification
## Proposed Fix
Add `\textit{}` handler to `cpp-grammar.lua`:
```lua
-- Strip \textit{} wrapper in BNF blocks (from \fmtnontermdef conversion)
grammar = process_macro_with_replacement(grammar, "textit", function(content)
return content -- Remove wrapper, keep content
end)
Insert this after existing macro processing (around line 170).
Alternative Fix
Simpler approach - add to simplified_macros.tex:
\renewcommand{\textit}[1]{#1} % Remove italic formatting, keep contentThis would handle it globally, not just in BNF blocks.
Testing
-
Add unit test in
tests/test_filters/test_grammar.py:def test_textit_in_bnf(): r"""Test that \textit{} is stripped from BNF blocks""" latex = r""" \begin{ncbnf} \textit{format-spec}\br fill-and-align\opt{width} \end{ncbnf} """ result = run_pandoc_with_filter(latex, "cpp-grammar") assert r"\textit{" not in result assert "format-spec" in result
-
Run test suite
-
Spot-check affected files after regeneration
Priority
Low - cosmetic issue only, all data is intact.
Related
Discovered during investigation of Issue #23, which reported missing/broken tables but was found to be incorrect.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestminorMinor priority issueMinor priority issue