Changes between Version 3 and Version 4 of 0.12/WikiHtml
- Timestamp:
- Feb 5, 2010, 8:43:38 PM (14 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
0.12/WikiHtml
v3 v4 1 1 = Using HTML in Wiki Text = 2 2 3 Trac supports inserting HTML into any wiki context, accomplished using the HTML [wiki:WikiProcessors WikiProcessor].3 Trac supports inserting HTML into any wiki context, accomplished using the `#!html` [wiki:WikiProcessors WikiProcessor]. 4 4 5 HTML support is built-in, and does not require installing any additional packages. 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. 6 9 7 == How to Use HTML == 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 8 17 To inform the wiki engine that a block of text should be treated as HTML, use the ''html'' processor. 9 18 10 This example should explain: 11 {{{ 12 #!html 13 <pre class="wiki">{{{ 14 #!html 15 <h1 style="text-align: right; color: blue">HTML Test</h1> 16 }}}</pre> 19 ||= Wiki Markup =||= Display =|| 20 {{{#!td 21 {{{ 22 {{{ 23 #!html 24 <h1 style="text-align: right; color: blue">HTML Test</h1> 25 }}} 26 }}} 17 27 }}} 18 19 Results in: 20 {{{ 21 #!html 22 <h1 style="text-align: right; color: blue">HTML Test</h1> 28 {{{#!td style="padding-left: 2em" 29 {{{ 30 #!html 31 <h1 style="text-align: right; color: blue">HTML Test</h1> 32 }}} 23 33 }}} 24 34 25 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. 26 36 27 Since 0.11, the filtering is done by Genshi, and as such, the produced output will be a well-formed fragment of HTML. In other words, 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.28 The new way to wrap any wiki content inside a <div> is to use the ''div'' Wiki processor: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. 29 39 30 {{{ 31 {{{ 32 #!div class=important style="border: 2pt solid; text-align: center" 33 This is the ''only'' way to go in Trac 0.11 40 == How to Use `#!div` and `#!span` == #HowtoUseDivSpan 41 42 ||= Wiki Markup =||= Display =|| 43 {{{#!td 44 {{{ 45 {{{ 46 #!div class=important style="border: 2pt solid; text-align: center" 47 This is the ''only'' way to go in Trac 0.11 48 }}} 49 }}} 34 50 }}} 35 }}} 36 37 Results in: 38 {{{ 39 #!div class=important style="border: 2pt solid; text-align: center" 40 This is the ''only'' way to go in Trac 0.11 51 {{{#!td style="padding-left: 2em" 52 {{{ 53 #!div class=important style="border: 2pt solid; text-align: center" 54 This is the ''only'' way to go in Trac 0.11 55 }}} 41 56 }}} 42 57 … … 44 59 45 60 For spans, you should rather use the Macro call syntax: 46 {{{ 47 Hello [[span(''WORLD'' (click [#world-anchor here]), style=color: green; font-size: 120%, id=world-anchor)]]! 61 ||= Wiki Markup =||= Display =|| 62 {{{#!td 63 {{{ 64 Hello 65 [[span(''WORLD'' (click [#anchor here]), style=color: green; font-size: 120%, id=anchor)]]! 66 }}} 48 67 }}} 49 50 Results in: 51 Hello [[span(''WORLD'' (click [#world-anchor here]), style=color: green; font-size: 120%, id=world-anchor)]]! 68 |--------------------------------------------------------------------------------- 69 ||= Display =|| 70 {{{#!td style="padding-left: 2em" 71 Hello 72 [[span(''WORLD'' (click [#anchor here]), style=color: green; font-size: 120%, id=anchor)]]! 73 }}} 52 74 53 75 54 76 == HTML comments == 55 77 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: 56 {{{ 57 {{{ 58 #!htmlcomment 59 This block is translated to an HTML comment. 60 It can contain <tags> and &entities; that will not be escaped in the output. 78 ||= Wiki Markup =|| 79 {{{#!td 80 {{{ 81 {{{ 82 #!htmlcomment 83 This block is translated to an HTML comment. 84 It can contain <tags> and &entities; that will not be escaped in the output. 85 }}} 86 }}} 61 87 }}} 88 |--------------------------------------------------------------------------------- 89 ||= Display =|| 90 {{{#!td 91 {{{ 92 <!-- 93 This block is translated to an HTML comment. 94 It can contain <tags> and &entities; that will not be escaped in the output. 95 --> 96 }}} 62 97 }}} 63 results in the following block in the HTML output: 64 {{{ 65 <!-- 66 This block is translated to an HTML comment. 67 It can contain <tags> and &entities; that will not be escaped in the output. 68 --> 69 }}} 98 70 99 Please note that the character sequence "--" is not allowed in HTML comments, and will generate a rendering error. 71 100