fdoc

modulefdoc_markdown

Markdown to HTML, in the dialect of Python-Markdown with the extensions FORD uses: fenced code, tables, footnotes, definition lists, abbreviations, attribute lists, Markdown inside HTML, math, file inclusion, and FORD's links, aliases and admonitions.

The block parser follows Python-Markdown: the text is split into chunks at blank lines, and a tree is built by processors tried in a fixed order, so that indentation and lists behave the same. Inline text is then read left to right.

Documentation is rendered in parallel, so nothing here calls a function returning a deferred-length string (see example/slen_race.f90).

Uses

Graphs

Uses

Used by

Variables

NameTypeAttributesDefaultDescription
BLOCK_TAGScharacter(len=*)privateparameter'addressarticleasideblockquotebodycenterdeldetailsdialogdirdivdlfieldsetfigcaptionfigurefooter'//'formh1h2h3h4h5h6headerhgrouphriframeinslimainmenunavnoscriptolppresectionsummarytable'//'tbodytdtfootththeadtrulcanvasmathobjectscriptstyle'
ESCAPEDcharacter(len=*)privateparameter'\`*_{}[]()>#+-.!'
ETXcharacter(len=1)privateparameterachar(3)

ends it

MAX_DEPTHintegerprivateparameter48
NLcharacter(len=1)privateparameterachar(10)
STXcharacter(len=1)privateparameterachar(2)

starts a placeholder for stashed HTML

WORD_CHARScharacter(len=*)privateparameter'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_'

Abstract interfaces

Types

footnote_tprivate

A footnote definition.

heading_tprivate

A heading, for the table of contents.

markdown_options_t

What rendering depends on.

node_tprivate

An element of the tree.

reference_tprivate

A link reference definition.

tree_tprivate

The state of one conversion.

Functions

adjustl_textpureprivate

pure character(len=len(text)-verify(text//'x','')+1) function adjustl_text(text) result(out)

text without leading blanks.

bracket_endpureprivate

pure integer function bracket_end(text, i)

The end of the [...] that opens at i, or 0.

count_newlinespureprivate

pure integer function count_newlines(text)

Number of line feeds in text.

fence_lengthpureprivate

pure integer function fence_length(line)

The length of the code fence that line starts with, or 0.

find_referenceprivate

integer function find_reference(t, id)

Find link reference id, returning its position or 0.

first_line_ofpureprivate

pure character(len=merge(len(text),index(text,NL)-1,index(text,NL)==0)) function first_line_of(text) result(line)

The first line of text.

first_wordpureprivate

pure character(len=merge(len(text),index(text,'')-1,index(text,'')==0)) function first_word(text) result(word)

The part of text before its first blank.

in_statepureprivate

pure logical function in_state(t, state)

True if the innermost parser state is state.

is_bullet_itempureprivate

pure logical function is_bullet_item(block)

True if block starts with a bullet list item.

is_listpureprivate

pure logical function is_list(tag)

True if tag is ul or ol.

is_ordered_itempureprivate

pure logical function is_ordered_item(block)

True if block starts with an ordered list item.

is_placeholderpureprivate

pure logical function is_placeholder(text)

True if text is one placeholder.

is_rulepureprivate

pure logical function is_rule(line)

True if line is a horizontal rule.

is_setextpureprivate

pure logical function is_setext(block)

True if the second line of block underlines the first.

is_tablepureprivate

pure logical function is_table(block)

True if block is a table: a header line with |, then a separator line.

item_textpureprivate

pure integer function item_text(line, ordered, bullet)

The position where the item text of a list line starts, or 0 if it is not one.

last_childpureprivate

pure integer function last_child(t, parent)

The last child of node parent, or 0.

trimmed_endpureprivate

pure character(len=max(0,verify(text,NL,back=.true.))) function trimmed_end(text) result(out)

text without trailing line feeds.

Subroutines

admonition_blockrecursiveprivate

recursive subroutine admonition_block(t, parent, block, stack, n)

An admonition: a line @note Type, then indented text.

admonition_linesprivate

subroutine admonition_lines(lines)

Turn @note blocks into a line @note Type followed by indented lines, ending at @endnote, a blank line, another admonition, or the end of the text.

admonition_startprivate

subroutine admonition_start(line, prefix, kind, rest)

The admonition type that starts at line, or '', with where it is and what follows it.

attribute_listprivate

subroutine attribute_list(text, attrs)

Turn the contents of an attribute list, #id .class key=value, into HTML attributes.

closing_markpureprivate

pure subroutine closing_mark(text, start, c, width, close)

Find where emphasis of width marks c opened before start closes.

code_blockprivate

subroutine code_block(t, parent, block, stack, n)

The code block processor.

code_block_htmlprivate

subroutine code_block_html(code, lang, html)

The HTML of a code block.

collect_definitionsprivate

subroutine collect_definitions(t, lines)

Remove link references, footnotes and abbreviations from lines and keep them.

dedentcommon

subroutine dedent(lines)

Remove the leading whitespace that all non-blank lines of lines share.

definition_blockrecursiveprivate

recursive subroutine definition_block(t, parent, block, at, stack, n)

The definition list processor.

element_endpureprivate

pure subroutine element_end(text, start, tag, stop_at)

The position of the end of the element starting at start, or 0.

encodedprivate

subroutine encoded(text, out)

Write text as numeric character references.

expand_file_includesrecursiveprivate

recursive subroutine expand_file_includes(lines, options, depth)

Replace file include directives by the contents of the file.

fence_languageprivate

subroutine fence_language(info, lang)

The language named after a code fence.

find_definitionpureprivate

pure subroutine find_definition(block, at)

Find a definition line in block.

find_hash_headerpureprivate

pure subroutine find_hash_header(block, at, stop_at)

Find the first # header line of block.

find_quotepureprivate

pure subroutine find_quote(block, at)

Find the first line of block that quotes.

find_rulepureprivate

pure subroutine find_rule(block, at, stop_at)

Find a line of block that is a horizontal rule.

hash_headerrecursiveprivate

recursive subroutine hash_header(t, parent, block, at, stop_at, stack, n)

The # header processor.

indent_levelprivate

subroutine indent_level(t, parent, block, level, node)

How deep block is in the lists of parent, and the node at that depth.

inlinerecursiveprivate

recursive subroutine inline(t, text, options, out, depth)

Write inline Markdown text as HTML.

inline_abbreviationprivate

subroutine inline_abbreviation(t, text, i, out, used)

Handle an abbreviation at i, if there is a whole word there.

inline_angleprivate

subroutine inline_angle(text, i, out, used)

Handle <: an automatic link or inline HTML.

inline_backslashprivate

subroutine inline_backslash(text, i, out, used)

Handle a backslash: math, or an escaped character.

inline_bracketrecursiveprivate

recursive subroutine inline_bracket(t, text, i, options, out, depth, used)

Handle [: a FORD link, a footnote reference or a link.

inline_codeprivate

subroutine inline_code(text, i, out, used)

Handle a code span.

inline_dollarprivate

subroutine inline_dollar(text, i, out, used)

Handle $: display math or an environment variable.

inline_emphasisrecursiveprivate

recursive subroutine inline_emphasis(t, text, i, options, out, depth, used)

Handle * and _.

inline_entityprivate

subroutine inline_entity(text, i, out, used)

Handle &: an entity stays as it is, anything else is escaped.

inline_imageprivate

subroutine inline_image(t, text, i, out, used)

Handle ![: an image.

inline_smartpureprivate

pure subroutine inline_smart(text, i, out, used)

Handle the punctuation that the smarty extension changes.

insert_tocprivate

subroutine insert_toc(t, html)

Replace the [TOC] marker by the table of contents.

list_blockrecursiveprivate

recursive subroutine list_block(t, parent, block, tag)

The list processors.

list_indentrecursiveprivate

recursive subroutine list_indent(t, parent, block)

The indented block processor: block continues a list.

list_itemsprivate

subroutine list_items(block, items)

The items of a list chunk.

loose_detabprivate

subroutine loose_detab(block, level, out)

Remove level indents from each line of block that has them.

markdown_to_htmlrecursive

recursive subroutine markdown_to_html(source, options, html)

Convert Markdown source to HTML.

mathprivate

subroutine math(tex, display, out)

Write math for MathJax.

name_and_entityprivate

subroutine name_and_entity(text, name, entity)

Split name(entity).

new_nodeprivate

subroutine new_node(t, parent, tag, id)

Add a child with tag tag to node parent, returning it.

normal_idprivate

subroutine normal_id(id, out)

id in lowercase, with runs of whitespace as single blanks.

normalize_linesprivate

subroutine normalize_lines(lines)

Expand tabs and blank lines of only spaces.

paragraphprivate

subroutine paragraph(t, parent, block)

The paragraph processor. In a tight list an item's text stays in the item.

parse_blockrecursiveprivate

recursive subroutine parse_block(t, parent, block, stack, n)

Find the block processor for block and run it.

parse_chunksrecursiveprivate

recursive subroutine parse_chunks(t, parent, chunks)

Parse chunks into node parent.

parse_onerecursiveprivate

recursive subroutine parse_one(t, parent, chunk)

Parse the single chunk chunk into node parent.

parse_textrecursiveprivate

recursive subroutine parse_text(t, parent, text)

Parse text that may hold several chunks into node parent.

push_backprivate

subroutine push_back(stack, n, text)

Put text back on the stack of chunks.

quote_blockrecursiveprivate

recursive subroutine quote_block(t, parent, block, at)

The block quote processor.

remove_markdown_attributeprivate

subroutine remove_markdown_attribute(open_tag)

Remove markdown="..." from an opening tag.

render_childrenrecursiveprivate

recursive subroutine render_children(t, id, options, out)

Write the children of node id.

render_codeprivate

subroutine render_code(text, html)

The HTML of an indented code block, whose first line may name its language.

render_footnotesrecursiveprivate

recursive subroutine render_footnotes(t, options, out)

Write the footnotes that were referred to.

render_headingrecursiveprivate

recursive subroutine render_heading(t, tag, attrs, text, options, out)

Write a heading or definition term. With the toc extension headings get ids.

render_noderecursiveprivate

recursive subroutine render_node(t, id, options, out)

Write node id.

render_tablerecursiveprivate

recursive subroutine render_table(t, block, options, out)

Write a table.

reset_statepureprivate

pure subroutine reset_state(t)

Leave the innermost parser state.

row_cellsprivate

subroutine row_cells(line, cells)

The cells of a table row, split at | outside code spans.

set_statepureprivate

pure subroutine set_state(t, state)

Enter parser state state.

setext_headerrecursiveprivate

recursive subroutine setext_header(t, parent, block, stack, n)

The underlined header processor.

split_chunksprivate

subroutine split_chunks(text, chunks)

Split text at blank lines, as text.split('\n\n') does.

stash_fenced_codeprivate

subroutine stash_fenced_code(t, lines)

Replace fenced code blocks by placeholders.

stash_htmlprivate

subroutine stash_html(t, html, placeholder)

Keep html aside, returning the placeholder for it.

stash_html_blocksrecursiveprivate

recursive subroutine stash_html_blocks(t, lines, options)

Replace block-level HTML by placeholders, rendering the contents of markdown="1" elements.

substitute_aliasesprivate

subroutine substitute_aliases(lines, aliases)

Replace |alias| by its value. |alias| gives the text without the backslash.

table_rowrecursiveprivate

recursive subroutine table_row(t, cells, tag, align, options, out)

Write a table row with exactly as many cells as align has.

tag_atpureprivate

pure subroutine tag_at(line, at, tag)

The tag at position at of line, in lowercase, or ''.

unique_idprivate

subroutine unique_id(t, html, id)

An id for a heading with text html, not used before. Like Python-Markdown's slugify, this drops punctuation and turns each run of blanks and hyphens into one hyphen.

unstashprivate

subroutine unstash(t, html)

Put stashed HTML back into html.