Skip to main content

render_ebnf_blocks

Function render_ebnf_blocks 

Source
pub(crate) fn render_ebnf_blocks(
    content_lines: &[String],
    nt_map: &HashMap<String, String>,
    current_source: Option<&Path>,
) -> Vec<String>
Expand description

Converts markdown ```ebnf ``` code fences into HTML <pre> blocks with linked nonterminals.

Within EBNF blocks:

  • PascalCase words that exist in nt_map become <a> links to their definition
  • Backtick-quoted terminals become <code class="ebnf-t"> spans

💡 Links are made relative to the current chapter. If the nonterminal is defined in a different chapter, we compute a relative path; if same chapter, just #anchor.