[Pmwiki-users] Line breaks again

Patrick R. Michaud pmichaud
Fri Aug 29 23:24:45 CDT 2003

On Fri, Aug 29, 2003 at 10:23:17AM -0400, J. Perkins wrote:
> This is a new paragraph. This is *bold*, and this is _italic_ (quite 
> possible your email client provided the appropriate text styles for you 
> there).
>  [...]
> If I could change the 
> bold and italic formatting too, that would be a plus. The rest of the 
> markup I am quite happy with.

I'll cover the newline issue in a later email, but to briefly cover the
bold/italic markup issue, I've always thought that *bold* and _italic_
for wiki markup were a bad idea, because while it might work for single
word highlighting it could produce some "pathological" cases if they're
extended to multiple words.  For example:

   Highlighting a *single* _word_ is probably okay.

   The formula 8 * 3 + 75 * 14 is probably not meant to have "3 + 75"
   in bold face.

   Some lines contain references to filenames_with_underscores.doc, where
   the _ ... _ isn't meant to be italics.  Also, if you make references to
   functions and variables such as E_ERROR and O_TRUNC then the underscores
   should be interpreted as italicizing "ERROR and O".

However, to test my premise I did a quick scan of pages on several of my
wiki sites (approx 4000 pages) to see how often these pathological cases
actually occur.  Multiple underscores occur quite frequently in lines 
where they should not be interpreted as italic markup, while multiple 
asterisks on a line almost never occur.

At any rate, if you decide you want it, it's fairly easy to add *bold* and 
_italic_ markup to PmWiki.  The simple version is to add the following to

   $InlineReplacements["/_(.+?)_/"] = "<i>\$1</i>";
   $InlineReplacements["/\\*(.+?)\\*/"] = "<b>\$1</b>";

However, the first one is likely to run into problems with lines that
have multiple underscores in them, so perhaps a better solution is

   $InlineReplacements["/(^|\\s)_(.+?)_(\\s|\$)/"] = "<i>\$2</i>";
   $InlineReplacements["/(^|\\s)\\*(.+?)\\*(\\s|\$)/"] = "<b>\$2</b>";

which requires the underscores and asterisks to have whitespace (or line
endings) on either side of them, so that _this is italics_ is italicized 
while this_is_italics is not.  I don't know if this "underscores means
italics only some of the time" would cause confusion for authors--i.e.,
with these rules underscores can't be used to create italics in the
middle of words.  Keep in mind that there are other potential 
oddities, such as

   This line has *bold words*
   *This line is not bold* (it's a bullet list item)
   [=*=]This line is not bold either*
   [==]*But this line is bold*
   * *This is a bolded list item*

Also, on many of the pages I examined people would use long sequences of
underscores or asterisks (e.g., to create blanks _____ for forms or to
separate **** very important items), in which case the rules need to
be modified to require a non-underscore or non-asterisk in the thing
being italicized or bolded:

   $InlineReplacements["/(^|\\s)_(.*?[^_].*?)_(\\s|\$)/"] = "<i>\$2</i>";
   $InlineReplacements["/(^|\\s)\\*(.*?[^*].*?)\\*(\\s|\$)/"] = "<b>\$2</b>";

Anyway, given that it's so easy to locally customize these markups into
PmWiki and that I think they could cause some author confusion, I'm not
currently planning to add these to be part of the official distribution
markup and will probably just add them to the cookbook.  However, based
on my recent studies of markup text, with enough favorable opinions from
the group I could be persuaded to place them in the core 
distribution--e.g., available either by default or via an $EnableXXX option.  


More information about the pmwiki-users mailing list