Custom Parsers
Extending the Parser
ndgBook uses the Nim compiler's RST/Markdown parser, which can be extended with custom directives. To add a custom directive:
- Define the directive handler in a Nim module
- Register it with the RST parser's directive table
- Compile your extension into the Nim compiler
Example custom directive handler:
import packages/docutils/rst proc dirMyCustom(p: var RstParser): PRstNode = result = parseDirective(p, rnDirective, {hasArg}, parseSectionWrapper) # Register during initialization rst.customDirectives["my-custom"] = dirMyCustom
Warning:
Custom parsers modify the compiler's behavior globally. Test thoroughly before deploying to production documentation.