|
close
Warning:
Can't synchronize with repository "(default)" (/hepforge/svn/chaplin does not appear to be a Subversion repository.). Look in the Trac log for more information.
- Timestamp:
-
Jul 17, 2018, 2:10:00 PM (6 years ago)
- Author:
-
trac
- Comment:
-
--
Legend:
- Unmodified
- Added
- Removed
- Modified
-
v3
|
v4
|
|
1 | | = Using HTML in Wiki Text = |
2 | | |
3 | | Trac supports inserting HTML into any wiki context, accomplished using the `#!html` [wiki:WikiProcessors WikiProcessor]. |
4 | | |
5 | | However a constraint is that this HTML has to be well-formed. |
6 | | In particular you can't insert a start tag in an `#!html` block, |
7 | | resume normal wiki text and insert the corresponding end tag in a |
8 | | second `#!html` block. |
9 | | |
10 | | Fortunately, for creating styled <div>s, <span>s or even complex tables |
11 | | containing arbitrary Wiki text, there's a powerful alternative: use of |
12 | | dedicated `#!div`, `#!span` and `#!table`, `#!tr`, `#!td` and `#!th` blocks. |
13 | | |
14 | | Those Wiki processors are built-in, and does not require installing any additional packages. |
15 | | |
16 | | == How to use `#!html` == #HowtoUseHTML |
17 | | To inform the wiki engine that a block of text should be treated as HTML, use the ''html'' processor. |
18 | | |
19 | | ||= Wiki Markup =||= Display =|| |
20 | | {{{#!td |
21 | | {{{ |
22 | | {{{ |
23 | | #!html |
| 1 | = Using HTML in Wiki Text |
| 2 | |
| 3 | Trac supports the display of HTML in any wiki context, by using the `#!html` [wiki:WikiProcessors WikiProcessor]. |
| 4 | |
| 5 | However, this HTML has to be [http://en.wikipedia.org/wiki/Well-formed_element well-formed]. |
| 6 | In particular, you can't insert a start tag in an `#!html` block, resume normal wiki text and insert the corresponding end tag in a second `#!html` block. |
| 7 | |
| 8 | For creating styled `<div>`s, `<span>`s or even complex tables containing arbitrary Wiki text, there is a powerful alternative: `#!div`, `#!span` and `#!table`, `#!tr`, `#!td` and `#!th` blocks. Those Wiki processors are built-in and do not require additional packages to be installed. |
| 9 | |
| 10 | == How to use `#!html` #HowtoUseHTML |
| 11 | To inform the wiki engine that a block of text should be treated as HTML, use the ''html'' processor: |
| 12 | |
| 13 | ||= Wiki Markup =||= Display =|| |
| 14 | {{{#!td |
| 15 | {{{ |
| 16 | {{{#!html |
24 | 17 | <h1 style="text-align: right; color: blue">HTML Test</h1> |
25 | 18 | }}} |
… |
… |
|
27 | 20 | }}} |
28 | 21 | {{{#!td style="padding-left: 2em" |
29 | | {{{ |
30 | | #!html |
| 22 | {{{#!html |
31 | 23 | <h1 style="text-align: right; color: blue">HTML Test</h1> |
32 | 24 | }}} |
33 | 25 | }}} |
34 | 26 | |
35 | | Note that Trac sanitizes your HTML code before displaying it. That means that if you try to use potentially dangerous constructs such as Javascript event handlers, those will be removed from the output. |
36 | | |
37 | | Since 0.11, the filtering is done by Genshi, and as such, the produced output will be a well-formed fragment of HTML. As noted above in the introduction, this mean that you can no longer use two HTML blocks, one for opening a <div>, the second for closing it, in order to wrap arbitrary wiki text. |
38 | | The new way to wrap any wiki content inside a <div> is to use the `#!div` Wiki processor. |
| 27 | Note that Trac sanitizes your HTML code before displaying it. That means that potentially dangerous constructs, such as Javascript event handlers, will be removed from the output. |
| 28 | |
| 29 | The filtering is done by [http://genshi.edgewall.org/ Genshi] and the output will be a well-formed fragment of HTML. This means that you cannot use two HTML blocks, one for opening a <div> and another for closing it, in order to wrap arbitrary wiki text. |
39 | 30 | |
40 | 31 | == How to use `#!div` and `#!span` == #HowtoUseDivSpan |
… |
… |
|
43 | 34 | {{{#!td |
44 | 35 | {{{ |
45 | | {{{ |
46 | | #!div class="important" |
| 36 | {{{#!div class="important" |
47 | 37 | **important** is a predefined class. |
48 | 38 | }}} |
49 | 39 | }}} |
50 | 40 | {{{ |
51 | | {{{ |
52 | | #!div style="border: 1pt dotted; margin: 1em" |
| 41 | {{{#!div style="border: 1pt dotted; margin: 1em" |
53 | 42 | **wikipage** is another predefined class that will |
54 | 43 | be used when no class is specified. |
… |
… |
|
56 | 45 | }}} |
57 | 46 | {{{ |
58 | | {{{ |
59 | | #!div class="compact" style="border: 1pt dotted; margin: 1em" |
| 47 | {{{#!div class="compact" style="border: 1pt dotted; margin: 1em" |
60 | 48 | **compact** is another predefined class reducing |
61 | 49 | the padding within the `<div>` to a minimum. |
… |
… |
|
63 | 51 | }}} |
64 | 52 | {{{ |
65 | | {{{ |
66 | | #!div class="wikipage compact" style="border: 1pt dotted" |
| 53 | {{{#!div class="wikipage compact" style="border: 1pt dotted" |
67 | 54 | Classes can be combined (here **wikipage** and **compact**) |
68 | 55 | which results in this case in reduced //vertical// |
… |
… |
|
72 | 59 | }}} |
73 | 60 | {{{ |
74 | | {{{ |
75 | | #!div class="" style="border: 1pt dotted; margin: 1em" |
| 61 | {{{#!div class="" style="border: 1pt dotted; margin: 1em" |
76 | 62 | Explicitly specifying no classes is //not// the same |
77 | 63 | as specifying no class attribute, as this will remove |
… |
… |
|
82 | 68 | {{{#!td style="padding-left: 2em" |
83 | 69 | |
84 | | {{{ |
85 | | #!div class="important" |
| 70 | {{{#!div class="important" |
86 | 71 | **important** is a predefined class. |
87 | 72 | }}} |
88 | 73 | |
89 | | {{{ |
90 | | #!div style="border: 1pt dotted; margin: 1em" |
| 74 | {{{#!div style="border: 1pt dotted; margin: 1em" |
91 | 75 | **wikipage** is another predefined class that will |
92 | 76 | be used when no class is specified. |
93 | 77 | }}} |
94 | 78 | |
95 | | {{{ |
96 | | #!div class="compact" style="border: 1pt dotted; margin: 1em" |
| 79 | {{{#!div class="compact" style="border: 1pt dotted; margin: 1em" |
97 | 80 | **compact** is another predefined class reducing |
98 | 81 | the padding within the `<div>` to a minimum. |
99 | 82 | }}} |
100 | 83 | |
101 | | {{{ |
102 | | #!div class="wikipage compact" style="border: 1pt dotted" |
| 84 | {{{#!div class="wikipage compact" style="border: 1pt dotted" |
103 | 85 | Classes can be combined (here **wikipage** and **compact**) |
104 | 86 | which results in this case in reduced //vertical// |
… |
… |
|
107 | 89 | }}} |
108 | 90 | |
109 | | {{{ |
110 | | #!div class="" style="border: 1pt dotted; margin: 1em" |
| 91 | {{{#!div class="" style="border: 1pt dotted; margin: 1em" |
111 | 92 | Explicitly specifying no classes is //not// the same |
112 | 93 | as specifying no class attribute, as this will remove |
… |
… |
|
116 | 97 | }}} |
117 | 98 | |
118 | | Note that the contents of a `#!div` block are contained in one or more paragraphs, which have a non-zero top and bottom margin. This leads to the top and bottom padding in the example above. To remove the top and bottom margin of the contents, add the `compact` class to the `#!div`. Another predefined class besides `wikipage` and `compact` is `important`, which can be used to make a paragraph stand out. Extra CSS classes can be defined via the `site/style.css` file for example, see TracInterfaceCustomization#SiteAppearance. |
119 | | |
120 | | For spans, you should rather use the Macro call syntax: |
| 99 | Note that the contents of a `#!div` block are contained in one or more paragraphs, which have a non-zero top and bottom margin. This leads to the top and bottom padding in the example above. To remove the top and bottom margin of the content, add the `compact` class to the `#!div`. Another predefined class besides `wikipage` and `compact` is `important`, which can be used to make a paragraph stand out. Extra CSS classes can be defined via [TracInterfaceCustomization#SiteAppearance site/style.css]. |
| 100 | |
| 101 | For spans, you should use the Macro call syntax: |
121 | 102 | ||= Wiki Markup =|| |
122 | 103 | {{{#!td |
… |
… |
|
133 | 114 | }}} |
134 | 115 | |
135 | | == How to use `#!td` and other table related processors == #Tables |
136 | | |
137 | | `#!td` or `#!th` processors are actually the main ones, for creating table data and header cells, respectively. The other processors `#!table` and `#!tr` are not required for introducing a table structure, as `#!td` and `#!th` will do this automatically. The `|-` row separator can be used to start a new row when needed, but some may prefer to use a `#!tr` block for that, as this introduces a more formal grouping and offers the possibility to use an extra level of indentation. The main purpose of the `#!table` and `#!tr` is to give the possibility to specify HTML attributes, like ''style'' or ''valign'' to these elements. |
| 116 | == How to use `#!td` and other table related processors #Tables |
| 117 | |
| 118 | The `#!td` or `#!th` processors should be used to create table data and table header cells, respectively. The other processors `#!table` and `#!tr` are not required for introducing a table structure, as `#!td` and `#!th` will do this automatically. The `|-` row separator can be used to start a new row when needed, but some may prefer to use a `#!tr` block for that, as this introduces a more formal grouping and offers the possibility to use an extra level of indentation. The main purpose of the `#!table` and `#!tr` is to give the possibility to specify HTML attributes, like ''style'' or ''valign'' to these elements. |
138 | 119 | |
139 | 120 | ||= Wiki Markup =||= Display =|| |
… |
… |
|
171 | 152 | attributes to the table itself... |
172 | 153 | |
173 | | {{{ |
174 | | #!table style="border:none;text-align:center;margin:auto" |
| 154 | {{{#!table style="border:none;text-align:center;margin:auto" |
175 | 155 | {{{#!tr ==================================== |
176 | 156 | {{{#!th style="border: none" |
… |
… |
|
234 | 214 | attributes to the table itself... |
235 | 215 | |
236 | | {{{ |
237 | | #!table style="border:none;text-align:center;margin:auto" |
| 216 | {{{#!table style="border:none;text-align:center;margin:auto" |
238 | 217 | {{{#!tr ==================================== |
239 | 218 | {{{#!th style="border: none" |
… |
… |
|
263 | 242 | }}} |
264 | 243 | |
265 | | Note that by default tables are assigned the "wiki" CSS class, which gives a distinctive look to the header cells and a default border to the table and cells (as can be seen for the tables on this page). By removing this class (`#!table class=""`), one regains complete control on the table presentation. In particular, neither the table, the rows nor the cells will have a border, so this is a more effective way to get such an effect than having to specify a `style="border: no"` parameter everywhere. |
| 244 | Note that by default tables are assigned the "wiki" CSS class, which gives a distinctive look to the header cells and a default border to the table and cells, as can be seen for the tables on this page. By removing this class (`#!table class=""`), one regains complete control on the table presentation. In particular, neither the table nor the rows nor the cells will have a border, so this is a more effective way to get such an effect rather than having to specify a `style="border: no"` parameter everywhere. |
266 | 245 | |
267 | 246 | {{{#!table class="" |
… |
… |
|
309 | 288 | }}} |
310 | 289 | |
311 | | |
312 | | == HTML comments == |
313 | | HTML comments are stripped from the output of the `html` processor. To add an HTML comment to a wiki page, use the `htmlcomment` processor (available since 0.12). For example, the following code block: |
| 290 | == HTML comments |
| 291 | HTML comments are stripped from the output of the `html` processor. To add an HTML comment to a wiki page, use the `htmlcomment` processor, available since Trac 0.12: |
314 | 292 | ||= Wiki Markup =|| |
315 | 293 | {{{#!td |
316 | 294 | {{{ |
317 | | {{{ |
318 | | #!htmlcomment |
| 295 | {{{#!htmlcomment |
319 | 296 | This block is translated to an HTML comment. |
320 | 297 | It can contain <tags> and &entities; that will not be escaped in the output. |
… |
… |
|
333 | 310 | }}} |
334 | 311 | |
335 | | Please note that the character sequence "`--`" is not allowed in HTML comments, and will generate a rendering error. |
336 | | |
337 | | |
338 | | == More Information == |
| 312 | The character sequence `--` is not allowed in HTML comments, and will generate a rendering error. |
| 313 | |
| 314 | |
| 315 | == More Information |
339 | 316 | |
340 | 317 | * http://www.w3.org/ -- World Wide Web Consortium |
… |
… |
|
342 | 319 | |
343 | 320 | ---- |
344 | | See also: WikiProcessors, WikiFormatting, WikiRestructuredText |
| 321 | See also: WikiFormatting, WikiProcessors, WikiRestructuredText |
|