fdoc

subroutinemarkdown_to_htmlrecursive

recursive subroutine markdown_to_html(source, options, html)

Convert Markdown source to HTML.

Arguments

NameTypeIntentAttributesDescription
sourcecharacter(len=*)in

the Markdown

optionstype(markdown_options_t)in

what rendering depends on

htmlcharacter(len=:)outallocatable

the HTML

Calls

Source

Show the code
recursive subroutine markdown_to_html(source, options, html)
    character(len=*), intent(in) :: source              !! the Markdown
    type(markdown_options_t), intent(in) :: options     !! what rendering depends on
    character(len=:), allocatable, intent(out) :: html  !! the HTML
    type(tree_t) :: t
    type(string_t), allocatable :: lines(:), chunks(:)
    character(len=:), allocatable :: text
    type(buffer_t) :: out

    allocate (t%nodes(32), t%stash(0), t%refs(0), t%notes(0), t%headings(0), t%ids(0))
    if (allocated(options%abbreviations)) then
        t%abbreviations = options%abbreviations
    else
        allocate (t%abbreviations(0))
    end if
    t%state = ''
    t%n = 1
    t%nodes(1)%tag = 'div'
    allocate (t%nodes(1)%kids(0))

    lines = split_lines(source)
    call normalize_lines(lines)
    call expand_file_includes(lines, options, 1)
    call admonition_lines(lines)
    if (allocated(options%aliases)) call substitute_aliases(lines, options%aliases)
    call stash_fenced_code(t, lines)
    call stash_html_blocks(t, lines, options)
    call collect_definitions(t, lines)
    text = join(lines, NL)
    call split_chunks(text, chunks)
    call parse_chunks(t, 1, chunks)
    call render_children(t, 1, options, out)
    call render_footnotes(t, options, out)
    call take(out, html)
    if (options%toc) call insert_toc(t, html)
    call unstash(t, html)
end subroutine markdown_to_html

Graphs

Calls

Called by