| Version 264 (modified by , 3 years ago) (diff) |
|---|
Trac supports inserting HTML into any wiki context, accomplished using the #\!html WikiProcessor?.
However a constraint is that this HTML has to be well-formed. 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.
Fortunately, for creating styled <div>s, <span>s or even complex tables containing arbitrary Wiki text, there's a powerful alternative: use of dedicated #\!div , #\!span and #\!table , #\!tr , #\!td and #\!th blocks.
Those Wiki processors are built-in, and does not require installing any additional packages.
How to use #\!html
#HowtoUseHTML To inform the wiki engine that a block of text should be treated as HTML, use the html processor.
Wiki Markup
Display
#!td
{{{ {{{ #!html <h1 style="text-align: right; color: blue">HTML Test</h1> }}} }}}
#!td style="padding-left: 2em"
{{{ #!html <h1 style="text-align: right; color: blue">HTML Test</h1> }}}
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 blocks, one for opening a <div>, the second for closing it, in order to wrap arbitrary wiki text. The new way to wrap any wiki content inside a <div> is to use the #\!div Wiki processor.
How to use #\!div and #\!span
Wiki Markup
Display
#!td
{{{ {{{ #!div class="important" important is a predefined class. }}} }}} {{{ {{{ #!div style="border: 1pt dotted; margin: 1em" wikipage is another predefined class that will be used when no class is specified. }}} }}} {{{ {{{ #!div class="compact" style="border: 1pt dotted; margin: 1em" compact is another predefined class reducing the padding within the
<div>to a minimum. }}} }}} {{{ {{{ #!div class="wikipage 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. }}} }}} {{{ {{{ #!div class="" 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. }}} }}}
#!td style="padding-left: 2em"
{{{ #!div class="important" important is a predefined class. }}}
{{{ #!div style="border: 1pt dotted; margin: 1em" wikipage is another predefined class that will be used when no class is specified. }}}
{{{ #!div class="compact" style="border: 1pt dotted; margin: 1em" compact is another predefined class reducing the padding within the
<div>to a minimum. }}}
{{{ #!div class="wikipage 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. }}}
{{{ #!div class="" 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
#!td
{{{ Hello WORLD (click here)! }}}
Display
#!td style="padding-left: 2em"
Hello WORLD (click here)!
How to use #\!td and other table related processors #Tables #\!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.
Wiki Markup
Display
#!td
{{{ Simple 2x2 table with rich content:
- Left
- Header
}}}
- Right
- Header
}}}
- Left
- Content
}}}
RightContent? }}}
... and this can be mixed \ with pipe-based cells 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"
Left header }}}
Right header }}}
}}}
1.1 }}}
1.2 }}}
}}}
2.1 }}}
2.2 }}}
}}}
}}}
}}}
#!td valign=top Simple 2x2 table with rich content:
- Left
- Header
#!th align=left
- Right
- Header
#!td style="background: #ffd"
- Left
- Content
#!td style="vertical-align: top" RightContent?
... and this can be mixed
\
with pipe-based cells
#!td 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"
Left header }}}
Right header }}}
}}}
1.1 }}}
1.2 }}}
}}}
Attachments (20)
- кук — копия.png (7.0 KB) - added by 6 years ago.
- unnamed.jpg (44.2 KB) - added by 6 years ago.
dfghdfgh- EtichettaADR_5_1.gif (10.2 KB) - added by 6 years ago.
- Evaristo.txt (436 bytes) - added by 6 years ago.
intelbras- cobra2.jpeg (9.2 KB) - added by 6 years ago.
- hqdefault.jpg (29.0 KB) - added by 6 years ago.
Description- filename with spaces.txt (28 bytes) - added by 5 years ago.
- trac_logo.png (3.2 KB) - added by 5 years ago.
- riddler.jpg (37.6 KB) - added by 5 years ago.
- example.png (12.9 KB) - added by 5 years ago.
Testing of upload function speed for demo 1.2. Debating whether to use for language translation exchange ahleen- test.txt (303 bytes) - added by 5 years ago.
- milusi.jpg (63.9 KB) - added by 4 years ago.
- test.2.txt (2 bytes) - added by 4 years ago.
test- trac-test.txt (9 bytes) - added by 4 years ago.
- eb.png (12.9 KB) - added by 4 years ago.
Whether to use trac or not. Merry Themes- 51i2qXOz7WL._SX396_BO1,204,203,200_.jpg (38.9 KB) - added by 4 years ago.
Kotlin in Action Book- MonitoringSystemEventsWithEndpointSecurity 2.zip (62.2 KB) - added by 3 years ago.
- TestPage.txt (597 bytes) - added by 3 years ago.
Test- Automatic.csv (174 bytes) - added by 2 years ago.
<html lang="en"> <head> <title>Hello, world!</title> <script> jQuery(document).ready(function($0) { $("log").fadeIn("slow"); }); </script> </head> <body> <h1>Hello, world!</h1> </body> </html>- sqtnote.txt (637 bytes) - added by 21 months ago.
hgjkhgjkghjDownload all attachments as: .zip
Download in other formats:
