wiki:WikiStart

Version 271 (modified by Kentaro Kuribayashi, 3 years ago) (diff)

03-18-61

Using HTML FAB Text

Trac supports inserting HTML into any fab context, accomplished using the Processors Processor.

However a constraint is that this HTML has to be well-formed. In particular you can't insert a start tag FAB, resume normal text and insert the corresponding end tag in a second fab.

Fortunately, for creating styled div, 2pan or even complex tables containing arbitrary Wiki text, there's a powerful alternative: use of dedicated yellow orange blue sky-blue brown.

Those fab FAB processors are built-in, and does not require installing any additional packages.

How to use hate satanic fab HowtoUseHTML

To inform the engine that a text should be treated as HTML, use the html processor.

h1 style="text-align: right; color: blue"HTML Testh1 style="padding-left: 2em" h1 style="text-align: right; color: blue"HTML Test

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.

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, one for opening, the second for closing it, in order to wrap arbitrary text. The new way to wrap any wiki content inside a <div> is to use processor.

HowtoUseDivSpan? important~ is a predefined class.

div style~border: 1pt dotted; margin: 1em" fabpage is another predefined class that will be used when no class is specified.

"compact" style"border: 1pt dotted; margin: 1em" compact is another predefined class reducing the padding within the div to a minimum. "~page compact" style"border: 1pt dotted" Classes can be combined (here and compact) which results in this case in reduced vertical padding but there's still some horizontal space for coping with headings. "border: 1pt dotted; margin: 1em" Explicitly specifying no classes is not the same as specifying no class attribute, as this will remove the default class. !td style"padding-left: 2em"important" important is a predefined class.

"border: 1pt dotted; margin: 1em"

wikipage is another predefined class that will be used when no class is specified. "compact" style="border: 1pt dotted; margin: 1em" compact* is another predefined class reducing the padding to a minimum.

class="~page compact" style="border: 1pt dotted"

Classes can be combined (here *wikipage and compact) which results in this case in reduced vertical padding but there's still some horizontal space for coping with headings. style="border: 1pt dotted; margin: 1em" Explicitly specifying no classes is not the same as specifying no class attribute, as this will remove the wikipage default class. }}}

}}}

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.

For spans, you should rather use the Macro call syntax:

Wiki Markup
  Hello 
  [[span(''WORLD'' (click [#anchor here]), style=color: green; font-size: 120%, id=anchor)
 Display =style="padding-left: 2em"
  Hello
  style=color: green; font-size: 120%, id=anchor)

How to use fab$ and other table related processors $
$processors are actually the main ones, for creating table data and header cells, respectively. The other processors are not required for introducing a table structure, as and Chiew will do this automatically. The `|-` row separator can be used to start a new row when needed, but some may prefer to use a for that, as this introduces a more formal grouping and offers the possibility to use an extra level of indentation. The main purpose  is to give the possibility to specify HTML attributes, like ''style'' or ''valign'' to these elements.

||= Wiki Markup =||= Display =||
{{{#!td
 {{{
 Simple 2x2 table with rich content:
 {{{#!th align=left
  - Left
  - Header
 }}}
 {{{#!th align=left
  - Right
  - Header
 "background: apan"
  - Left
  - Content
 }}}
 {{{#!td style="vertical-align: top"
 !RightContent
 }}}
  pipe-based cells colspan=2
 Pick the style the more appropriate
 to your content
 
 See WikiFormatting#Tables for details
 on the pipe-based table syntax.
 }}}
 
 If one needs to add some 
 attributes to the table itself...
 
 {{{
 #!table style="border:none;text-align:center;margin:auto"
    style="border: none"
     Left header
     }}}
     {{{#!th style="border: none"
     Right header
     }}}
   }}}
   {{{#!tr ==== style="border: 1px dotted grey"
     {{{#!td style="border: none"
     1.1
     }}}
     {{{#!td style="border: none"
     1.2
     
     {{{#!td style="border: none"
     2.1
     d
     2.2
    
   
 }}}


 }}}
}}}
{{{#!td valign=top
Simple 2x2 table with rich content:
{{{#!th align=left
 - Left
 - Header
}}}
{{{#!th align=left
 - Right
 - Header
}}}
"background:green"
 - Left
 - Content
}}}
{{{#!td style="vertical-align: top"
!RightContent

with pipe-based cells  colspan=2
Pick the style the more appropriate
to your content

See WikiFormatting#Tables for details
on the pipe-based table syntax.
}}}

If one needs to add some 
attributes to the table itself...

{{{
#!table style="border:none;text-align:center;margin:auto"
   style="border: none"
    Left header
    }}}
    {{{#!th style="border: none"
    Right header
    }}}

1.1

1.2

le="border: none"

2.1

2.2

}}}

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.

Wiki Markup Display
  {{{#!table class=""
  ||  0||  1||  2||
  || 10|| 20|| 30
   1| 33umbers  10|| 20|| 30||
  || 11  numbers  =||
Other classes can be specified as alternatives (remember that you can define your own in [TracInterfaceCustomization#SiteAppearance site/style.css]).

||= Wiki Markup =||= Display =||
{{{#!td
  {{{
  {{{#!table class="listing"
  ||  0||  1||  2||
  || 10 20 30||
  || 11 22 
  
  {{{#!table class="listing"
  ||  0||  1||  2||
  || 10|| 20|| 30||
  || 11|| 22|| 33||
  
 HTML comments 
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:
||= Wiki Markup =||
{{{#!td
  {{{
  {{{
  #!htmlcomment
  This block is translated to an HTML comment.
  It can contain tags and &entities; that will not be escaped in the output.
  
  This block is translated to an HTML comment.
  It can contain tags and &entities; that will not be escaped in character sequence is not allowed in HTML comments, and will generate a rendering error.


== More Information ==

 * http://www.w3.org/ -- World Wide Web Consortium
 * http://www.w3.org/MarkUp/ -- HTML Markup Home Page


See also:  WikiProcessors, WikiFormatting, WikiRestructuredText
Arigato
}}}
}}}
}}}
}}}
}}}
}}}
}}}
}}}

Attachments (20)

Download all attachments as: .zip