-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Labels
enhancementNew feature or requestNew feature or requestmacro-conversionLaTeX macro conversion issueLaTeX macro conversion issue
Description
Feature Request
Automatically link \\grammarterm{term} references to their \\nontermdef{term} definitions, similar to how section cross-references work.
Example
Current behavior:
\\grammarterm{statement}→*statement*(just italicized text)
Proposed behavior:
\\grammarterm{statement}→[*statement*][term.statement]with link to the section containing\\nontermdef{statement}
Benefits
- Easier navigation through grammar productions - readers can quickly jump to the definition of any grammar term
- Consistent behavior with existing section cross-reference system
- Better understanding of grammar structure and relationships
Implementation Considerations
Critical: Namespace Prefix
MUST use term. prefix, NOT gram.
The gram. namespace is already used by existing grammar summary sections:
gram.general- Grammar Summary General sectiongram.key- Keywords section- Historically:
gram.stmt,gram.expr,gram.dcl, etc.
Using gram. would cause namespace collision and break existing cross-file links.
Technical Requirements
- Handle malformed patterns gracefully: Must handle
\\grammarterm{}{text}(empty first arg) pattern in n3337/n4140 sources (see \\grammarterm{}{text} with empty first argument causes malformed output #78) - Use proper Pandoc AST: Use
pandoc.Link()elements, not RawInline markdown strings (which don't get re-parsed) - Build grammar term index: Similar to LabelIndexer, scan for
\\nontermdef{},\\fmtnontermdef{},\\renontermdef{}and map terms → sections - Generate link reference table: Add entries like
[term.statement]: basic.md#stmt.preat document end - Test across all versions: Must work correctly for n3337, n4140, n4659, n4861, n4950, and trunk
Example Index Mapping
translation-unit → basic.link
statement → stmt.pre
expression → expr.comma
class-name → class.pre
Related Issues
Cross-reference linking issues:
- Broken cross-references with REF: prefix #66 - Broken cross-references with REF: prefix
- Table reference labels missing ID anchors, causing broken links #19 - Table reference labels missing ID anchors
- Cross-file reference anchor mismatches #54 - Cross-file reference anchor mismatches
Priority
ENHANCEMENT - This is a feature request to improve navigation, not a bug fix.
Notes from Failed Implementation Attempt
A previous implementation attempt was reverted due to:
- Using
gram.prefix (namespace collision) - Using RawInline markdown (doesn't work with Pandoc's processing model)
- Not handling malformed
\\grammarterm{}{}patterns gracefully - Insufficient testing across standard versions
Any future implementation should address these issues.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestmacro-conversionLaTeX macro conversion issueLaTeX macro conversion issue