AlignText
<< | Cookbook-V1 | >>
Note: The recipes here are for PmWiki versions 0.6 and 1.0 only. For PmWiki 2.0 recipes, see Cookbook.
Goal
Adding the ability to align text right or to center it. Also add underline possibility.
Solution
Markup text according to...
--_Align text to the right--_
-_-Center text-_-
__underline text__
Discussion
Add the following to local.php
$InlineReplacements["/__(.*?)__/"] ="<span style='text-decoration:underline'>\$1</span>"; $InlineReplacements["/--_(.*?)--_/"] ="<div align='right'>\$1</div>"; $InlineReplacements["/-_-(.*?)-_-/"] ="<div align='center'>\$1</div>";
Comments & Bugs
Works with PmWiki > 0.5.24 and 0.6.0
2004-03-05 - First - thanks for doing this - I have needed a centering and underline capability.
As given above, the underline has some problems. For example, a long string of '_' will be interpreted in sections as requiring underlining. Also, consider trying to do a checklist type line:
__Item 1 __Item 2 __Item 3
This is also inadvertantly underlined in sections.
What seems to be a little better, and is in keeping with the other proposed markups, might be something like: -__underlined stuff__-
The regular expression is then: /-__(.*?)__-/.
Also, take a look at the mailing list thread starting at http://pmichaud.com/pipermail/pmwiki-users_pmichaud.com/2003-August/001282.html for a discussion of underline (and bold and italic) patterns. Finally, as of PmWiki 0.6.9 you can now write %text-decoration:underline define=ul%
and afterwards use %ul%underlined stuff%%
to do underlining. --Pm
- Example
- This text has an underlined phrase in it.
pmwiki-2.3.38 -- Last modified by {{Pm}}