1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
{# 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 -%}
|