Changes between Version 3 and Version 4 of WikiHtml


Ignore:
Timestamp:
Dec 4, 2020, 2:27:59 PM (4 years ago)
Author:
trac
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • WikiHtml

    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
     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
     11To 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
    2417  <h1 style="text-align: right; color: blue">HTML Test</h1>
    2518  }}}
     
    2720}}}
    2821{{{#!td style="padding-left: 2em"
    29   {{{
    30   #!html
     22  {{{#!html
    3123  <h1 style="text-align: right; color: blue">HTML Test</h1>
    3224  }}}
    3325}}}
    3426
    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.
     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.
    3930
    4031== How to use `#!div` and `#!span` == #HowtoUseDivSpan
     
    4334{{{#!td
    4435  {{{
    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 
    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...)
     36  {{{#!div class="important"
     37  **important** is a predefined class.
     38  }}}
     39  }}}
     40  {{{
     41  {{{#!div style="border: 1pt dotted; margin: 1em"
     42  **wikipage** is another predefined class that will
     43  be used when no class is specified.
     44  }}}
     45  }}}
     46  {{{
     47  {{{#!div class="compact" style="border: 1pt dotted; margin: 1em"
     48  **compact** is another predefined class reducing
     49  the padding within the `<div>` to a minimum.
     50  }}}
     51  }}}
     52  {{{
     53  {{{#!div class="wikipage compact" style="border: 1pt dotted"
     54  Classes can be combined (here **wikipage** and **compact**)
     55  which results in this case in reduced //vertical//
     56  padding but there's still some horizontal space for coping
     57  with headings.
     58  }}}
     59  }}}
     60  {{{
     61  {{{#!div class="" style="border: 1pt dotted; margin: 1em"
     62  Explicitly specifying no classes is //not// the same
     63  as specifying no class attribute, as this will remove
     64  the //wikipage// default class.
    6865  }}}
    6966  }}}
    7067}}}
    7168{{{#!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:
     69
     70  {{{#!div class="important"
     71  **important** is a predefined class.
     72  }}}
     73
     74  {{{#!div style="border: 1pt dotted; margin: 1em"
     75  **wikipage** is another predefined class that will
     76  be used when no class is specified.
     77  }}}
     78
     79  {{{#!div class="compact" style="border: 1pt dotted; margin: 1em"
     80  **compact** is another predefined class reducing
     81  the padding within the `<div>` to a minimum.
     82  }}}
     83
     84  {{{#!div class="wikipage compact" style="border: 1pt dotted"
     85  Classes can be combined (here **wikipage** and **compact**)
     86  which results in this case in reduced //vertical//
     87  padding but there's still some horizontal space for coping
     88  with headings.
     89  }}}
     90
     91  {{{#!div class="" style="border: 1pt dotted; margin: 1em"
     92  Explicitly specifying no classes is //not// the same
     93  as specifying no class attribute, as this will remove
     94  the //wikipage// default class.
     95  }}}
     96
     97}}}
     98
     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].
     100
     101For spans, you should use the Macro call syntax:
    101102||= Wiki Markup =||
    102103{{{#!td
     
    113114}}}
    114115
    115 == How to use `#!td` and other table related processors == #Tables
    116 
    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.
     116== How to use `#!td` and other table related processors #Tables
     117
     118The `#!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.
    118119
    119120||= Wiki Markup =||= Display =||
     
    151152 attributes to the table itself...
    152153 
    153  {{{
    154  #!table style="border:none;text-align:center;margin:auto"
     154 {{{#!table style="border:none;text-align:center;margin:auto"
    155155   {{{#!tr ====================================
    156156     {{{#!th style="border: none"
     
    214214attributes to the table itself...
    215215
    216 {{{
    217 #!table style="border:none;text-align:center;margin:auto"
     216{{{#!table style="border:none;text-align:center;margin:auto"
    218217  {{{#!tr ====================================
    219218    {{{#!th style="border: none"
     
    243242}}}
    244243
    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.
     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.
    246245
    247246{{{#!table class=""
     
    289288}}}
    290289
    291 
    292 == 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:
     290== HTML comments
     291HTML 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:
    294292||= Wiki Markup =||
    295293{{{#!td
    296294  {{{
    297   {{{
    298   #!htmlcomment
     295  {{{#!htmlcomment
    299296  This block is translated to an HTML comment.
    300297  It can contain <tags> and &entities; that will not be escaped in the output.
     
    313310}}}
    314311
    315 Please note that the character sequence "--" is not allowed in HTML comments, and will generate a rendering error.
    316 
    317 
    318 == More Information ==
    319 
    320  * http://www.w3.org/ -- World Wide Web Consortium
    321  * 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
    322319
    323320----
    324 See also:  WikiProcessors, WikiFormatting, WikiRestructuredText
     321See also:  WikiFormatting, WikiProcessors, WikiRestructuredText