-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Problem
Remaining \texttt{} macros in markdown output, primarily in math contexts. Analysis shows:
- n4950: 23 instances
- trunk: 39 instances
- Total: 62 instances
Root Cause
\tcode{} macros preserved in math mode by Pandoc, appearing as \texttt{} in output.
Solution
Extended cpp-math.lua to handle display math contexts:
-
Display Math Handler: Added
elseif elem.mathtype == "DisplayMath"branch- Converts
\tcode{}/\texttt{}to backticks before Unicode conversion - Applies preprocessing (strips
\placeholder{},\ensuremath{}, text macros) - Uses all-or-nothing approach: fully convert to Unicode or revert to preprocessed LaTeX
- Converts
-
Test Coverage: Added 4 new tests in
test_math.py:test_texttt_in_display_math()- Basic display math blockstest_tcode_in_display_math()- XOR operator handlingtest_multiple_texttt_in_display_math()- Multiple macrostest_texttt_in_complex_display_math()- Multi-line\begin{align*}
Results
- n4950: 23 → 14 instances (39% reduction, 9 fixed)
- Test suite: 483 → 487 tests, all passing
Remaining Edge Cases (14 instances)
- Nested
\texttt{\textit{}}(containers.md) - Escaped special chars
\texttt{\}(lex.md) - Complex inline math (ranges.md)
- Escaped underscores (utilities.md)
These harder edge cases require more sophisticated handling and can be addressed in future work.
Files Changed
src/cpp_std_converter/filters/cpp-math.lua- Display math handlingtests/test_filters/test_math.py- 4 new tests
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request