# run with last '\n' or nothing in buffer.
data modify storage markdown: line_backup set from storage markdown: str.0
scoreboard players operation #indent0 markdown = #indent1 markdown
scoreboard players set #indent1 markdown 0
function markdown:next_char
scoreboard players operation #tok_backup markdown = #tok1 markdown

execute if data storage markdown: str{1:"#"} run return run function markdown:document/header
execute if data storage markdown: str{1:">"} run return run function markdown:document/blockquote
execute if data storage markdown: str{1:" "} run return run function markdown:document/indent/

execute if data storage markdown: str{1:"-"} run return run function markdown:document/dash/
execute if data storage markdown: str{1:"*"} run return run function markdown:document/asterisk/
execute if data storage markdown: str{1:"_"} run return run function markdown:document/underline/
execute if data storage markdown: str{1:"="} run return run function markdown:document/equal

execute if data storage markdown: str{1:"0"} run return run function markdown:document/number/
execute if data storage markdown: str{1:"1"} run return run function markdown:document/number/
execute if data storage markdown: str{1:"2"} run return run function markdown:document/number/
execute if data storage markdown: str{1:"3"} run return run function markdown:document/number/
execute if data storage markdown: str{1:"4"} run return run function markdown:document/number/
execute if data storage markdown: str{1:"5"} run return run function markdown:document/number/
execute if data storage markdown: str{1:"6"} run return run function markdown:document/number/
execute if data storage markdown: str{1:"7"} run return run function markdown:document/number/
execute if data storage markdown: str{1:"8"} run return run function markdown:document/number/
execute if data storage markdown: str{1:"9"} run return run function markdown:document/number/

execute if data storage markdown: str{1:"\n"} run return run function markdown:document/next_paragraph
execute if data storage markdown: str.1 run return run function markdown:document/fallback

# EOF
return run function markdown:document/eof