-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Problem
Within C++ code blocks, \tcode{} macros inside comments are being stripped rather than having their formatting preserved, losing the semantic intent to mark certain text as code.
Location
File: n4950/stmt.md
Lines: 619, 726, 832, 838-839
Examples
Line 619:
// OK, lifetime of return value of g() extendedSource (statements.tex:726): Uses \tcode{g()} to mark the function name
Line 832:
// error: jump into scope of aSource (statements.tex:1018): Uses \tcode{a} to mark the variable name
Lines 838-839:
// OK, jump implies destructor call for a followed by
// construction again immediately following label lySource (statements.tex:1024-1025): Uses \tcode{a} and \tcode{ly} to mark identifiers
Current Behavior
The comments render as plain text with no special formatting for code elements that were marked with \tcode{} in the source.
Expected Behavior
While code comments can't typically contain inline code formatting in markdown, the semantic intent could be preserved by:
- Using backticks within comments:
// OK, lifetime of return value of `g()` extended - Using some other convention to distinguish code elements
- Or simply document that this limitation exists
Impact
- Severity: MINOR
- Comments remain readable and comprehensible
- The specific marking of code elements within comments is lost
- Semantic intent from the source is not preserved
- Low priority since the code blocks are already formatted and the comments make sense
Root Cause
The code block filter (cpp-code-blocks.lua) processes LaTeX code blocks and strips \tcode{} macros within comments. This is likely intentional since:
- Markdown code blocks don't support inline formatting within comments
- The comments are already in a code context
- Preserving the formatting would require special handling
Discussion
This may be a "won't fix" or "by design" issue, since:
- Markdown code blocks render as plain text
- Comments in code can't have inline formatting in most markdown renderers
- The loss of formatting doesn't significantly impact readability
However, if preserving semantic information is important, alternatives could be considered.
Reproduction
- Open
n4950/stmt.md - Look at any of the affected lines (619, 726, 832, 838-839)
- Compare with source in
statements.tex - Observe that
\tcode{}marked elements in comments are plain text
Related Files
src/cpp_std_converter/filters/cpp-code-blocks.lua- Code block processingsrc/cpp_std_converter/cpp-common.lua- Code cleaning utilities