Changes between Version 2 and Version 3 of WikiHtml
- Timestamp:
- Nov 26, 2022, 2:16:52 PM (2 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
WikiHtml
v2 v3 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 tunately, 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` ==#HowtoUseHTML1 = 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 [https://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 11 To inform the wiki engine that a block of text should be treated as HTML, use the ''html'' processor: 12 12 … … 14 14 {{{#!td 15 15 {{{ 16 {{{ 17 #!html 16 {{{#!html 18 17 <h1 style="text-align: right; color: blue">HTML Test</h1> 19 18 }}} … … 21 20 }}} 22 21 {{{#!td style="padding-left: 2em" 23 {{{ 24 #!html 22 {{{#!html 25 23 <h1 style="text-align: right; color: blue">HTML Test</h1> 26 24 }}} 27 25 }}} 28 26 29 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. 30 31 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 can no longer use two HTML blocks, one for opening a <div> and another for closing it, in order to wrap arbitrary wiki text. 32 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 [https://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. 33 30 34 31 == How to use `#!div` and `#!span` == #HowtoUseDivSpan … … 37 34 {{{#!td 38 35 {{{ 39 {{{ 40 #!div class="important" 36 {{{#!div class="important" 41 37 **important** is a predefined class. 42 38 }}} 43 39 }}} 44 40 {{{ 45 {{{ 46 #!div style="border: 1pt dotted; margin: 1em" 47 **wikipage** is another predefined class that will 41 {{{#!div style="border: 1pt dotted; margin: 1em" 42 **wikipage** is another predefined class that will 48 43 be used when no class is specified. 49 44 }}} 50 45 }}} 51 46 {{{ 52 {{{ 53 #!div class="compact" style="border: 1pt dotted; margin: 1em" 47 {{{#!div class="compact" style="border: 1pt dotted; margin: 1em" 54 48 **compact** is another predefined class reducing 55 49 the padding within the `<div>` to a minimum. … … 57 51 }}} 58 52 {{{ 59 {{{ 60 #!div class="wikipage compact" style="border: 1pt dotted" 53 {{{#!div class="wikipage compact" style="border: 1pt dotted" 61 54 Classes can be combined (here **wikipage** and **compact**) 62 which results in this case in reduced //vertical// 55 which results in this case in reduced //vertical// 63 56 padding but there's still some horizontal space for coping 64 57 with headings. … … 66 59 }}} 67 60 {{{ 68 {{{ 69 #!div class="" style="border: 1pt dotted; margin: 1em" 61 {{{#!div class="" style="border: 1pt dotted; margin: 1em" 70 62 Explicitly specifying no classes is //not// the same 71 63 as specifying no class attribute, as this will remove … … 76 68 {{{#!td style="padding-left: 2em" 77 69 78 {{{ 79 #!div class="important" 70 {{{#!div class="important" 80 71 **important** is a predefined class. 81 72 }}} 82 73 83 {{{ 84 #!div style="border: 1pt dotted; margin: 1em" 85 **wikipage** is another predefined class that will 74 {{{#!div style="border: 1pt dotted; margin: 1em" 75 **wikipage** is another predefined class that will 86 76 be used when no class is specified. 87 77 }}} 88 78 89 {{{ 90 #!div class="compact" style="border: 1pt dotted; margin: 1em" 79 {{{#!div class="compact" style="border: 1pt dotted; margin: 1em" 91 80 **compact** is another predefined class reducing 92 81 the padding within the `<div>` to a minimum. 93 82 }}} 94 83 95 {{{ 96 #!div class="wikipage compact" style="border: 1pt dotted" 84 {{{#!div class="wikipage compact" style="border: 1pt dotted" 97 85 Classes can be combined (here **wikipage** and **compact**) 98 which results in this case in reduced //vertical// 86 which results in this case in reduced //vertical// 99 87 padding but there's still some horizontal space for coping 100 88 with headings. 101 89 }}} 102 90 103 {{{ 104 #!div class="" style="border: 1pt dotted; margin: 1em" 91 {{{#!div class="" style="border: 1pt dotted; margin: 1em" 105 92 Explicitly specifying no classes is //not// the same 106 93 as specifying no class attribute, as this will remove … … 110 97 }}} 111 98 112 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 the `site/style.css` file for example, see TracInterfaceCustomization#SiteAppearance.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]. 113 100 114 101 For spans, you should use the Macro call syntax: … … 116 103 {{{#!td 117 104 {{{ 118 Hello 105 Hello 119 106 [[span(''WORLD'' (click [#anchor here]), style=color: green; font-size: 120%, id=anchor)]]! 120 107 }}} … … 127 114 }}} 128 115 129 == How to use `#!td` and other table related processors ==#Tables116 == How to use `#!td` and other table related processors #Tables 130 117 131 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. … … 157 144 Pick the style the more appropriate 158 145 to your content 159 146 160 147 See WikiFormatting#Tables for details 161 148 on the pipe-based table syntax. 162 149 }}} 163 164 If one needs to add some 150 151 If one needs to add some 165 152 attributes to the table itself... 166 167 {{{ 168 #!table style="border:none;text-align:center;margin:auto" 153 154 {{{#!table style="border:none;text-align:center;margin:auto" 169 155 {{{#!tr ==================================== 170 156 {{{#!th style="border: none" … … 225 211 }}} 226 212 227 If one needs to add some 213 If one needs to add some 228 214 attributes to the table itself... 229 215 230 {{{ 231 #!table style="border:none;text-align:center;margin:auto" 216 {{{#!table style="border:none;text-align:center;margin:auto" 232 217 {{{#!tr ==================================== 233 218 {{{#!th style="border: none" … … 257 242 }}} 258 243 259 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. 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. 260 245 261 246 {{{#!table class="" … … 303 288 }}} 304 289 305 == HTML comments ==290 == HTML comments 306 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: 307 292 ||= Wiki Markup =|| 308 293 {{{#!td 309 294 {{{ 310 {{{ 311 #!htmlcomment 295 {{{#!htmlcomment 312 296 This block is translated to an HTML comment. 313 297 It can contain <tags> and &entities; that will not be escaped in the output. … … 326 310 }}} 327 311 328 Please note that the character sequence "`--`"is not allowed in HTML comments, and will generate a rendering error.329 330 331 == More Information ==332 333 * http ://www.w3.org/ -- World Wide Web Consortium334 * http ://www.w3.org/MarkUp/ -- HTML Markup Home Page312 The character sequence `--` is not allowed in HTML comments, and will generate a rendering error. 313 314 315 == More Information 316 317 * https://www.w3.org/ -- World Wide Web Consortium 318 * https://www.w3.org/MarkUp/ -- HTML Markup Home Page 335 319 336 320 ---- 337 See also: Wiki Processors, WikiFormatting, WikiRestructuredText321 See also: WikiFormatting, WikiProcessors, WikiRestructuredText