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 section
gram.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.pre at 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:
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.
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
Implementation Considerations
Critical: Namespace Prefix
MUST use
term.prefix, NOTgram.The
gram.namespace is already used by existing grammar summary sections:gram.general- Grammar Summary General sectiongram.key- Keywords sectiongram.stmt,gram.expr,gram.dcl, etc.Using
gram.would cause namespace collision and break existing cross-file links.Technical Requirements
\\grammarterm{}{text}(empty first arg) pattern in n3337/n4140 sources (see \\grammarterm{}{text} with empty first argument causes malformed output #78)pandoc.Link()elements, not RawInline markdown strings (which don't get re-parsed)\\nontermdef{},\\fmtnontermdef{},\\renontermdef{}and map terms → sections[term.statement]: basic.md#stmt.preat document endExample Index Mapping
Related Issues
Cross-reference linking issues:
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:
gram.prefix (namespace collision)\\grammarterm{}{}patterns gracefullyAny future implementation should address these issues.