ford.md_admonition module#
Admonition Preprocessor#
Markdown preprocessor for dealing with FORD style admonitions. See Notes and Warning Boxes for details on using these in Ford docs.
A preprocessor, AdmonitionPreprocessor, converts Ford style
@note into something that the existing markdown admonition
extension can handle. This is mostly a matter of making sure the
note body is indented correctly. The conversion to HTML is done with a
customised processor, FordAdmonitionProcessor
- ford.md_admonition.ADMONITION_TYPE = {'bug': 'danger', 'history': 'history', 'note': 'info', 'todo': 'success', 'warning': 'warning'}#
Mapping of Ford note types to markdown’s admonition types
- class ford.md_admonition.AdmonitionExtension(**kwargs)#
Bases:
ExtensionAdmonition extension for Python-Markdown.
- extendMarkdown(md)#
Add Admonition to Markdown instance.
- class ford.md_admonition.AdmonitionPreprocessor(md=None)#
Bases:
PreprocessorMarkdown preprocessor for dealing with FORD style admonitions.
This preprocessor converts the FORD syntax for admonitions to the markdown admonition syntax.
A FORD admonition starts with
@<type>, where<type>is one of:note,warning,todo,bug, orhistory. An admonition ends at (in this order of preference):@end<type>, where<type>must match the start markeran empty line
a new note (
@<type>)the end of the documentation lines
The admonitions are converted to the markdown syntax, i.e.
@note Note, followed by an indented block. Possible end markers are removed, as well as empty lines if they mark the end of an admonition.- ADMONITION_RE: ClassVar[Pattern] = re.compile('(?P<indent>\\s*)\n @(?P<type>note|warning|todo|bug|history)\n (?P<posttxt>.*)\n ', re.IGNORECASE|re.VERBOSE)#
- END_RE: ClassVar[Pattern] = re.compile('\\s*@end(?P<type>note|warning|todo|bug|history)\n \\s*(?P<posttxt>.*)?', re.IGNORECASE|re.VERBOSE)#
- admonitions: List[Admonition] = []#
- class ford.md_admonition.FordAdmonitionProcessor(parser)#
Bases:
AdmonitionProcessorCustomised version of the Python markdown extension.
Uses our CSS class names for each specific note type.
- CLASSNAME = 'alert'#
- CLASSNAME_TITLE = 'alert-title h4'#
- RE = re.compile('(?:^|\\n)@note ?(?P<klass>[\\w\\-]+) *(?:\\n|$)')#
- get_class_and_title(match)#
Get the CSS class and title for this admonition
Title is the note class, while the CSS class is looked up in the list of note types (
ADMONITION_TYPE)
- exception ford.md_admonition.FordMarkdownError(message, line_number, lines, start, end, context=4)#
Bases:
RuntimeErrorFormat an error when processing markdown, giving some context