Changes between Version 1 and Version 2 of WikiHtml


Ignore:
Timestamp:
Mar 7, 2018, 4:17:33 PM (7 years ago)
Author:
trac
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • WikiHtml

    v1 v2  
    11= Using HTML in Wiki Text =
    22
    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.
     3Trac supports the display of HTML in any wiki context, by using the `#!html` [wiki:WikiProcessors WikiProcessor].
     4
     5However, this HTML has to be [http://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
     8Fortunately, 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.
    159
    1610== 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.
     11To inform the wiki engine that a block of text should be treated as HTML, use the ''html'' processor:
    1812
    1913||= Wiki Markup =||= Display =||
     
    3327}}}
    3428
    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.
     29Note 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
     31The 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.
     32The new way to wrap any wiki content inside a <div> is to use the `#!div` Wiki processor.
    3933
    4034== How to use `#!div` and `#!span` == #HowtoUseDivSpan
     
    4438  {{{
    4539  {{{
    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 
    50   {{{
    51   #!div class="wikipage" style="border: 1pt dotted"
    52   Only `wikipage` (same as specifying no class attribute)
    53   }}}
    54 
    55   {{{
    56   #!div class="wikipage compact " style="border: 1pt solid"
    57   Use combined classes (`compact` and `wikipage`)
    58   }}}
    59 
    60   {{{
    61   #!div class="compact" style="border: 1pt dotted"
    62   Only `compact`
    63   }}}
    64 
    65   {{{
    66   #!div class="" style="border: 1pt solid"
    67   No classes (//not// the same as specifying no class attribute...)
     40  #!div class="important"
     41  **important** is a predefined class.
     42  }}}
     43  }}}
     44  {{{
     45  {{{
     46  #!div style="border: 1pt dotted; margin: 1em"
     47  **wikipage** is another predefined class that will
     48  be used when no class is specified.
     49  }}}
     50  }}}
     51  {{{
     52  {{{
     53  #!div class="compact" style="border: 1pt dotted; margin: 1em"
     54  **compact** is another predefined class reducing
     55  the padding within the `<div>` to a minimum.
     56  }}}
     57  }}}
     58  {{{
     59  {{{
     60  #!div class="wikipage compact" style="border: 1pt dotted"
     61  Classes can be combined (here **wikipage** and **compact**)
     62  which results in this case in reduced //vertical//
     63  padding but there's still some horizontal space for coping
     64  with headings.
     65  }}}
     66  }}}
     67  {{{
     68  {{{
     69  #!div class="" style="border: 1pt dotted; margin: 1em"
     70  Explicitly specifying no classes is //not// the same
     71  as specifying no class attribute, as this will remove
     72  the //wikipage// default class.
    6873  }}}
    6974  }}}
    7075}}}
    7176{{{#!td style="padding-left: 2em"
    72   {{{
    73   #!div class="important" style="border: 2pt solid; text-align: center"
    74   This is the ''only'' way to go in Trac 0.11
    75   }}}
    76 
    77   {{{
    78   #!div class="wikipage" style="border: 1pt dotted"
    79   Only `wikipage` (same as specifying no class attribute)
    80   }}}
    81 
    82   {{{
    83   #!div class="wikipage compact " style="border: 1pt solid"
    84   Use combined classes (`compact` and `wikipage`)
    85   }}}
    86 
    87   {{{
    88   #!div class="compact" style="border: 1pt dotted"
    89   Only compact
    90   }}}
    91 
    92   {{{
    93   #!div class="" style="border: 1pt solid"
    94   No classes (//not// the same as specifying no class attribute...)
    95   }}}
    96 }}}
    97 
    98 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.
    99 
    100 For spans, you should rather use the Macro call syntax:
     77
     78  {{{
     79  #!div class="important"
     80  **important** is a predefined class.
     81  }}}
     82
     83  {{{
     84  #!div style="border: 1pt dotted; margin: 1em"
     85  **wikipage** is another predefined class that will
     86  be used when no class is specified.
     87  }}}
     88
     89  {{{
     90  #!div class="compact" style="border: 1pt dotted; margin: 1em"
     91  **compact** is another predefined class reducing
     92  the padding within the `<div>` to a minimum.
     93  }}}
     94
     95  {{{
     96  #!div class="wikipage compact" style="border: 1pt dotted"
     97  Classes can be combined (here **wikipage** and **compact**)
     98  which results in this case in reduced //vertical//
     99  padding but there's still some horizontal space for coping
     100  with headings.
     101  }}}
     102
     103  {{{
     104  #!div class="" style="border: 1pt dotted; margin: 1em"
     105  Explicitly specifying no classes is //not// the same
     106  as specifying no class attribute, as this will remove
     107  the //wikipage// default class.
     108  }}}
     109
     110}}}
     111
     112Note 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.
     113
     114For spans, you should use the Macro call syntax:
    101115||= Wiki Markup =||
    102116{{{#!td
     
    115129== How to use `#!td` and other table related processors == #Tables
    116130
    117 `#!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.
     131The `#!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.
    118132
    119133||= Wiki Markup =||= Display =||
     
    243257}}}
    244258
    245 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.
     259Note 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.
    246260
    247261{{{#!table class=""
     
    289303}}}
    290304
    291 
    292305== HTML comments ==
    293 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:
     306HTML 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:
    294307||= Wiki Markup =||
    295308{{{#!td
     
    313326}}}
    314327
    315 Please note that the character sequence "--" is not allowed in HTML comments, and will generate a rendering error.
     328Please note that the character sequence "`--`" is not allowed in HTML comments, and will generate a rendering error.
    316329
    317330