subroutinemarkdown_to_htmlrecursive
recursive subroutine markdown_to_html(source, options, html)
Convert Markdown source to HTML.
Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| source | character(len=*) | in | the Markdown | |
| options | type(markdown_options_t) | in | what rendering depends on | |
| html | character(len=:) | out | allocatable | the HTML |
Calls
- split_lines
- normalize_lines
- expand_file_includes
- admonition_lines
- substitute_aliases
- stash_fenced_code
- stash_html_blocks
- collect_definitions
- join
- split_chunks
- parse_chunks
- render_children
- render_footnotes
- take
- insert_toc
- unstash
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