{# This document uses jinja2 templating markup. Please refer to the Jinja2 template documentation for further information. http://jinja.pocoo.org/docs/dev/templates/ This file contains jinja2 macros that are used by the README.textile file to differentiate between, and generate, textile and plaintext output. We can use indenting because we set lstrip_blocks=True when we setup the jinja2 environment in the python scripts that process this file. #}. {# This is the default width of plain text paragraphs. #} {% set tw = 70 %} {# Macro to use for 'headers' #} {% macro header(depth, text) %} {% if announce != "yes" -%}h{{depth}}. {% endif -%}{{text}} {% if announce == "yes" -%}{% for n in text -%} ={% endfor -%}={% endif -%} {% endmacro -%} {# Url-ize urls in textile, plaintext just leave them be. #} {%- macro url(text) -%} {%- if announce != "yes" -%} "{{ text }}":{{ text }} {%- else -%} {{ text }} {%- endif -%} {%- endmacro -%} {# urlize email addresses in textile, plaintext just leave them be. #} {%- macro email(text) -%} {%- if announce != "yes" -%} "{{ text }}":mailto:{{ text }} {%- else -%} {{ text }} {%- endif -%} {%- endmacro -%} {# An indented URL. #} {% macro urlind(ind,text) %} {% if announce != "yes" -%} p {%- for i in range(0, ind // 2) -%} ( {%- endfor -%} . "{{ text }}":{{ text }} {% else -%} {{ text|indent(ind, true) }} {%- endif -%} {% endmacro %} {# An indented URL with a label (for text). #} {% macro urlindlabel(ind,label,text) %} {% if announce != "yes" -%} p {%- for i in range(0, ind // 2) -%} ( {%- endfor -%} . ({{label}}) "{{ text }}":{{ text }} {% else -%} {% set labeltext=['(',label,')',text] -%} {{ labeltext|join|indent(ind, true) }} {%- endif -%} {% endmacro %} {# Format a 'NEWS' section item. if it is news we use '* ' and don't indent the first line. if it is newscont we don't use '* ' and we do indent the first line. if it is para we don't indent and don't use '* ' #} {% macro format(mode) -%} {%- for line in caller().splitlines() -%} {%- if announce == "yes" -%} {%- if mode == "news" -%} {%- if loop.index0 == 0 -%} * {{ line|customwordwrap(tw, False)|indent(2, False) }} {% else -%} {{ line|customwordwrap(tw, False)|indent(2, True) }} {% endif %} {% elif mode == "newscont" -%} {{ line|customwordwrap(tw, False)|indent(2, True) }} {% elif mode == "para" -%} {{ line|customwordwrap(tw, False) }} {% endif %} {# else this is textile mode #} {%- else -%} {%- if mode == "news" -%} {%- if loop.index0 == 0 -%} * {{ line }} {% elif loop.index0 == 1 -%} p {%- for i in range(0, 3) -%} ( {%- endfor -%}. {{ line }} {% else -%} {{ line }} {% endif %} {% elif mode == "newscont" -%} {%- if loop.index0 == 0 -%} p {%- for i in range(0, 3) -%} ( {%- endfor -%}. {{ line }} {% else -%} {{ line }} {% endif -%} {% elif mode == "para" -%} {{ line }} {% endif %} {%- endif -%} {%- endfor -%} {%- endmacro -%}