Changes between Version 3 and Version 4 of WikiHtml


Ignore:
Timestamp:
05/08/22 15:12:15 (3 years ago)
Author:
trac
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • WikiHtml

    v3 v4  
    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 Fortunately, 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
     1= Using HTML in Wiki Text
     2
     3Trac supports the display of HTML in any wiki context, by using the `#!html` [wiki:WikiProcessors WikiProcessor].
     4
     5However, this HTML has to be [https://en.wikipedia.org/wiki/Well-formed_element well-formed].
     6In 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
     8For 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
    1111To inform the wiki engine that a block of text should be treated as HTML, use the ''html'' processor:
    1212
     
    1414{{{#!td
    1515  {{{
    16   {{{
    17   #!html
     16  {{{#!html
    1817  <h1 style="text-align: right; color: blue">HTML Test</h1>
    1918  }}}
     
    2120}}}
    2221{{{#!td style="padding-left: 2em"
    23   {{{
    24   #!html
     22  {{{#!html
    2523  <h1 style="text-align: right; color: blue">HTML Test</h1>
    2624  }}}
    2725}}}
    2826
    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.
     27Note 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
     29The 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.
    3330
    3431== How to use `#!div` and `#!span` == #HowtoUseDivSpan
     
    3734{{{#!td
    3835  {{{
    39   {{{
    40   #!div class="important"
     36  {{{#!div class="important"
    4137  **important** is a predefined class.
    4238  }}}
    4339  }}}
    4440  {{{
    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
    4843  be used when no class is specified.
    4944  }}}
    5045  }}}
    5146  {{{
    52   {{{
    53   #!div class="compact" style="border: 1pt dotted; margin: 1em"
     47  {{{#!div class="compact" style="border: 1pt dotted; margin: 1em"
    5448  **compact** is another predefined class reducing
    5549  the padding within the `<div>` to a minimum.
     
    5751  }}}
    5852  {{{
    59   {{{
    60   #!div class="wikipage compact" style="border: 1pt dotted"
     53  {{{#!div class="wikipage compact" style="border: 1pt dotted"
    6154  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//
    6356  padding but there's still some horizontal space for coping
    6457  with headings.
     
    6659  }}}
    6760  {{{
    68   {{{
    69   #!div class="" style="border: 1pt dotted; margin: 1em"
     61  {{{#!div class="" style="border: 1pt dotted; margin: 1em"
    7062  Explicitly specifying no classes is //not// the same
    7163  as specifying no class attribute, as this will remove
     
    7668{{{#!td style="padding-left: 2em"
    7769
    78   {{{
    79   #!div class="important"
     70  {{{#!div class="important"
    8071  **important** is a predefined class.
    8172  }}}
    8273
    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
    8676  be used when no class is specified.
    8777  }}}
    8878
    89   {{{
    90   #!div class="compact" style="border: 1pt dotted; margin: 1em"
     79  {{{#!div class="compact" style="border: 1pt dotted; margin: 1em"
    9180  **compact** is another predefined class reducing
    9281  the padding within the `<div>` to a minimum.
    9382  }}}
    9483
    95   {{{
    96   #!div class="wikipage compact" style="border: 1pt dotted"
     84  {{{#!div class="wikipage compact" style="border: 1pt dotted"
    9785  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//
    9987  padding but there's still some horizontal space for coping
    10088  with headings.
    10189  }}}
    10290
    103   {{{
    104   #!div class="" style="border: 1pt dotted; margin: 1em"
     91  {{{#!div class="" style="border: 1pt dotted; margin: 1em"
    10592  Explicitly specifying no classes is //not// the same
    10693  as specifying no class attribute, as this will remove
     
    11097}}}
    11198
    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.
     99Note 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].
    113100
    114101For spans, you should use the Macro call syntax:
     
    116103{{{#!td
    117104  {{{
    118   Hello 
     105  Hello
    119106  [[span(''WORLD'' (click [#anchor here]), style=color: green; font-size: 120%, id=anchor)]]!
    120107  }}}
     
    127114}}}
    128115
    129 == How to use `#!td` and other table related processors == #Tables
     116== How to use `#!td` and other table related processors #Tables
    130117
    131118The `#!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.
     
    157144 Pick the style the more appropriate
    158145 to your content
    159  
     146
    160147 See WikiFormatting#Tables for details
    161148 on the pipe-based table syntax.
    162149 }}}
    163  
    164  If one needs to add some 
     150
     151 If one needs to add some
    165152 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"
    169155   {{{#!tr ====================================
    170156     {{{#!th style="border: none"
     
    225211}}}
    226212
    227 If one needs to add some 
     213If one needs to add some
    228214attributes to the table itself...
    229215
    230 {{{
    231 #!table style="border:none;text-align:center;margin:auto"
     216{{{#!table style="border:none;text-align:center;margin:auto"
    232217  {{{#!tr ====================================
    233218    {{{#!th style="border: none"
     
    257242}}}
    258243
    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. 
     244Note 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.
    260245
    261246{{{#!table class=""
     
    303288}}}
    304289
    305 == HTML comments ==
     290== HTML comments
    306291HTML 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:
    307292||= Wiki Markup =||
    308293{{{#!td
    309294  {{{
    310   {{{
    311   #!htmlcomment
     295  {{{#!htmlcomment
    312296  This block is translated to an HTML comment.
    313297  It can contain <tags> and &entities; that will not be escaped in the output.
     
    326310}}}
    327311
    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 Consortium
    334  * http://www.w3.org/MarkUp/ -- HTML Markup Home Page
     312The 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
    335319
    336320----
    337 See also:  WikiProcessors, WikiFormatting, WikiRestructuredText
     321See also:  WikiFormatting, WikiProcessors, WikiRestructuredText