{% for post in site.posts %}
{% if post.title == page.title and post.author == page.author and post.date == page.date %}
{% assign text = post.content | newline_to_br | split:"#" %}
{% endif %}
{% endfor %}
{% assign subcount = text | size | minus:1 %}
{% capture MermaidBlock %}
{% assign bigheadercount = 0 %}
{% assign smallheadercount = 0 %}
graph TB
{% for sub in (1..subcount) %}
{% assign headercount = text[sub] | size %}
{% if headercount == 0 %}
{% assign subcheck = 0 %}
{% endif %}
{% if headercount != 0 and subcheck != 0 %}
{% if bigheadercount == 0 %}
{% assign bigheader = text[sub] | newline_to_br | split:"
" | first %}
subgraph {{ bigheader }}
{% assign bigheadercount = bigheadercount | plus:1 %}
{% else %}
end
{% assign bigheader = text[sub] | newline_to_br | split:"
" | first %}
subgraph {{ bigheader }}
{% endif %}
{% assign subcheck = 1 %}
{% endif %}
{% if headercount != 0 and subcheck == 0 %}
{% if smallheadercount == 0 %}
{% assign currentheader = text[sub] | newline_to_br | split:"
" | first %}
{% assign currentsub = sub %}
{% assign smallheadercount = smallheadercount | plus:1 %}
node{{ sub }}({{ currentheader }})
click node{{ sub }} "{{ currentheader | strip | downcase | replace:' ','-' | prepend:'#' }}"
{% else %}
{% assign prevheader = currentheader %}
{% assign prevsub = currentsub %}
{% assign currentheader = text[sub] | newline_to_br | split:"
" | first %}
{% assign currentsub = sub %}
node{{ prevsub }}({{ prevheader }}) --> node{{ sub }}({{ currentheader }})
click node{{ sub }} "{{ currentheader | strip | downcase | replace:' ','-' | prepend:'#' }}"
{% endif %}
{% assign subcheck = 2 %}
{% endif %}
{% endfor %}
end
{% endcapture %}