source: tol/tolbase/lib/markupparser/README.txt @ 193c473

1941-docker-image-to-testdevel
Last change on this file since 193c473 was a680983, checked in by Jorge Pérez <josp.jorge@…>, 15 years ago

refs #1347, hipertext widget extracted from Notebook App

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@3878 be4846ae-f051-483a-831f-b64e7d08527f

  • Property mode set to 100644
File size: 6.7 KB
Line 
1markupparser 2.0
2-----------------------------------------------------------------
3
4markupparser parses Notebook markup into an intermediary form,
5a flat list of tag/value pairs.  The parsing proceeds by first
6breaking the input into chunk, where each chunk consists
7of one or more full lines of text.  There are (at present)
8four kinds of chunk:
9
10Directives
11    A directive is a line beginning with a hash "#" character;
12    the specific directive is determined by the text that follows
13    the hash character.  Unless otherwise indicated, any
14    subsequent text on the line is ignored.  Unrecognized
15    directives are permitted.  The existing directives are as
16    follows:
17
18    #---
19        Rendered as a horizontal line, e.g., <hr>.
20
21    #pre
22        Begins a chunk of preformatted text.
23
24    #unpre
25        Ends a chunk of preformatted text.
26
27    #Tcl
28        Begins a chunk of Tcl Code
29
30    #unTcl
31        Ends a chunk of Tcl Code
32
33    #meta <keyword> <value>
34        Defines a named value associated with the pages.  It will be
35        possible to query a page for its metadata.
36
37    #data <typename>
38        Begins a data chunk.  A data chunk is just like a Tcl Code or
39        preformatted text chunk in terms of how it's handled; however,
40        it will allow other code to easily extract data of a specific
41        type from a page.  Eventually, it might be possible to add
42        rendering plugins for specific data types.
43
44    #undata
45        Ends a data chunk.
46
47Preformatted
48    A preformatted chunk is to be rendered verbatim in a
49    fixed-width font.  Performatted chunks are found in two
50    ways: either a paragraph whose first line begins with
51    a whitespace character, or a group of lines beginning with
52    a "#pre" directive and ending with a "#unpre" directive
53    (or the end of the input).  (The directives are not
54    part of the chunk.)
55
56Tcl Code
57    A Tcl code chunk is usually rendered Preformatted; it is
58    a group of lines bracketed by "#Tcl" and "#unTcl".
59
60Wrapped Text
61    A wrapped text paragraph consists of one or more lines of
62    possibly styled text.  Wrapped text paragraphs can be
63    indented; if indented they can have a bullet.  Wrapped
64    text can also contain links, magic buttons, and embedded
65    macros.
66
67    Note: embedded macros are usually expanded *before* parsing
68    the markup, so usually there won't be any in the input.  If
69    there are any, they could be anywhere, in any kind of text.
70    However, the parser will only recognize them in wrapped text.
71
72Pass-through Text
73    Sometimes it's desirable to include text in a page that will be
74    passed through the parser unchanged, e.g., when using macros
75    to generate HTML in a page that will be exported as HTML. 
76    There are two ways to specify pass-through text.
77
78        #data thru
79        Text to be passed through.
80        #undata
81
82    Text wrapped by #data thru/#undata will go through the parser
83    unchanged, and will be handled by output processors as a single
84    paragraph.
85
86        This text has some <thru><tt>HTML</tt></thru> markup.
87
88    Within a paragraph of wrapped text, the <thru>...</thru>
89    tags can be used to quote a section of text to pass
90    through unchanged.  If the example above were exported
91    as HTML without the <thru>...</thru> tags, the angle
92    brackets on <tt> and </tt> would be escaped as
93    &lt; and &gt;.
94
95
96Intermediate Form
97-----------------------------------------------------------------
98
99The parser parses the input and produces the intermediate form,
100a flat list of tag/value pairs.  The tags and their values are
101defined as follows:
102
103
104META <dictionary>
105    The value of META is a dict of the #meta values defined in
106    this page.  If the same keyword appears multiple times, the
107    final value is retained.  If no #meta directives appear in
108    this page, META appears with an empty list as its value.
109
110    META is always the first tag in the list.
111
112HASH <directive>
113    One of these pairs is produced for each directive; the value is
114    the complete line of text, including the newline at the end.
115
116PRE <text>
117    This is usually Preformatted text, to be displayed verbatim.  The
118    value is the exact set of lines from the input.  If the chunk was
119    delimited by "#pre" and "#unpre" directives, then this tag/value
120    will be preceded and followed by the appropriate HASH tag/values.
121
122TCL <text>
123    The <text> is a chunk of Tcl code. This tag/value will be preceded
124    and followed by the "#Tcl" and "#unTcl" HASH tag/values.
125
126DATA {<name> <text>}
127    The value of DATA is a list of two elements; the data name from
128    the #data line and the chunk of data that appeared between the
129    #data and #undata.
130
131    When the <name> is "thru", the <text> is to be passed through
132    the parser unchanged.
133
134P {:|* <indent> <leading>}
135    Begins a paragraph of wrapped text.  The value is a list of three
136    items: the paragraph type (":" or "*"), the indent level (0 or
137    higher) and (for indented and bulleted paragraphs) the leading
138    string, which is the whitespace between the initial "*" or ":"
139    and the paragraph text.  (It's used to reconstruct a parsed page
140    just exactly as it was.)
141
142    A normal, non-indented non-bulleted paragraph will begin with
143
144        P {: 0 {}}
145
146    A paragraph with an indent level of 1 will begin with this
147    (where the length of the leading string depends on the actual
148    input):
149
150        P {: 1 { }}
151
152    A bulleted paragraph with an indent level of 1 will begin with
153    this:
154
155        P {* 1 { }}
156
157    For bulleted paragraphs, the indent level must be 1 or more.
158    Note that a normal paragraph is simply an indented paragraph
159    with an indent level of zero.
160
161/P
162    Terminates a paragraph of wrapped text, of whatever kind.
163
164The following tags represent components of a paragraph of wrapped
165text; they will always appear between P and /P.
166
167TXT <text>
168    The value is plain text to be wrapped and rendered.
169
170THRU <text>
171    The value is text in the current output format; it
172    was passed through the parser unchanged.
173
174STY {<style-code> <style-letter> <flag>}
175    Notebook markup defines a number of HTML-like style codes,
176    e.g., <b>...</b> and <i>...</i>.  When one is found in a
177    wrapped paragraph, this tag is generated.  The tag's value is
178    a list of three elements: the raw style code (</b>), the
179    style letter (b), and a flag: 1 when the style turns on and
180    0 when the style turns off.  Note that all styles are
181    cancelled at the end of the paragraph. 
182
183    A renderer is free to render the styles as it prefers.
184
185LINK <link text>
186    The value is a page link, not including the [ and ].
187
188BTN <button text|command>
189    The value is the definition of a magic button, not including the
190    [% and %].
191
192MACRO <macro>
193    The value is an embedded macro command, not including the [@ and @].
Note: See TracBrowser for help on using the repository browser.