(:groupheader:)(:Summary: Styling text for colour and other attributes:) See also [[Cookbook:WikiStylesPlus | Wiki Styles Plus]] and [[(PmWiki:)Wiki style colors]]. <:vspace> PmWiki uses [[WikiStyles]] for styling text with color and other attributes. PmWiki 2.0 introduced the ability to control the styling further and to even place styles on blocks. <:vspace> A style is specified within a pair of %-signs and styles the text that follows, as in: <:vspace> (:markup class=horiz:) This text is %color=red% red, %color=blue% blue, %% and normal (black). (:markupend:) <:vspace> There are a wide number of available style properties, borrowed primarily from HTML and CSS. In addition, an author can define a style "shortcut" by using the [@define=@] property. For example, to define a style of [@%red%@], one can use: <:vspace> (:markup class=horiz:) %define=mystyle color=red% Here is some %mystyle% red text created using a style shortcut. (:markupend:) <:vspace> Shortcuts can be combined with other styles, including other shortcuts: <:vspace> (:markup class=horiz:) %define=lovelyred color=red% %define=likegrapefruit bgcolor=yellow% <:vspace> %red% This text is red, %red bgcolor=#ccc% red on a grey background, and %lovelyred likegrapefruit% red on a yellow background. (:markupend:) <:vspace> So far, this is all basically the same as what was available in PmWiki 1.0. PmWiki 2.0 includes the capability to style blocks, by using the [@apply=@] style property. Specifying [@apply=block@] in a `WikiStyle will cause that style to be applied to the entire block, instead of just the text that follows: <:vspace> (:markup:) This entire block %apply=block bgcolor=yellow% has a yellow background, even though the `WikiStyle appears in the middle of the line. %bgcolor=pink% Other inline (non-block) WikiStyles can appear in the middle of the line,%% as before. (:markupend:) <:vspace> This means it's now possible to do right-aligned and centered text: <:vspace> (:markup:) %block text-align=right% The text of this paragraph is right-aligned. <:vspace> %block text-align=center% The text of this paragraph is centered. (:markupend:) <:vspace> <:vspace> In fact, PmWiki predefines [@%right%@] and [@%center%@] style shortcuts so that you can do this more simply: <:vspace> (:markup class=horiz:) %right% This is right-aligned. <:vspace> %center% This is centered. (:markupend:) <:vspace> Authors can define their own custom styles: <:vspace> (:markup:) %define=Pm block bgcolor=#fdf% %define=goofy center bgcolor=#dfd border='3px dotted green'% %define=rediguana right bgcolor=#ffffcc border='1px dotted red' padding=5px% %define=strike text-decoration=line-through% <:vspace> %Pm% Any text that is on a light purple background is a comment from "Pm". <:vspace> %goofy% Here's some text from Goofy. <:vspace> %rediguana% bla bla by rediguana! <:vspace> %goofy%Hello, I am %strike%upset%% %strike%disheartened%% happy to meet you. (:markupend:) <:vspace> Styles can be applied to almost any kind of block: <:vspace> (:markup class=horiz:) * %block bgcolor=yellow% Here is a list item * Here's another list item <:vspace> * Here's more of a list <:vspace> # A new list (:markupend:) <:vspace> In particular, this means that outlines are now possible using the predefined [@%ROMAN%@], [@%roman%@], [@%ALPHA%@], and [@%alpha%@] list-block styles. The style has to be specified on the first item in the list (and we may develop an alternate syntax for this sort of ordered list): <:vspace> (:markup class=horiz:) # %ROMAN% Top level ## %ALPHA% second-level ## second-level ## second-level ### third-level ### third-level ## second-level ### third-level #### %alpha% fourth-level ##### %roman% fifth-level ##### fifth-level #### fourth-level # top-level # top-level (:markupend:) <:vspace> [[Wiki styles]] can be combined with CSS stylesheets to do this automatically -- see [[Cookbook:OutlineLists]]. <:vspace> <:vspace> !! Q & A <:vspace> !!! How do I get a block of preformatted text? <:vspace> Use something similar to this (assuming you want markup within the block to be interpreted as wiki markup and URIs to be recognized). <:vspace> (:markup:) >>white-space=pre<< This block of text is ''preformatted'', see all the white-space and linebreaks are preserved. Links such as [[wiki styles]] etc still work. >><< (:markupend:) <:vspace> !!! How do I get a block of preformatted text with a colored background and a border? <:vspace> Use something similar to this (note that wiki markup etc is not recognized within the block): <:vspace> (:markup:) %block bgcolor=#f0f9ff border='1px solid gray' padding=5px%[@ ip access-list extended example-acl remark ** This is an example acl ** deny ip any host permit ip any any @] (:markupend:) <:vspace> !!! How do I get a block of text (including wiki markup) with a colored background and a border? (:markup class=horiz:) >>teal background-color:silver border:'medium dotted green'<< Hello world * bullet # number >><< (:markupend:) <:vspace> !!! How do I get a block of text (including wiki markup) with a border that is indented on the left and does NOT extend all the way to right? I'm not interested in having later text to the right as would occur with lfloat... <:vspace> You can use the @@indent width=50pct@@ wikistyle. <:vspace> (:markup class=horiz:) Before indention... >>frame indent width=50pct<< Hello world * bullet # number >><< ... after indention! (:markupend:)(:groupfooter:) <:block>