PmWiki

Markup Expressions-Talk

This is a talk page for improving MarkupExpressions.


Requests for further markup expressions

  • ftime add ordinal suffix for date format - st, nd, rd, th.
  • allow markup expressions to be nested
  • rtrim - remove trailing spaces (default) or character if optional parameter supplied (useful for page text variables);
    {(rtrim string optionalchar)}
  • ltrim - remove leading spaces (default) or character if optional parameter supplied (useful for page text variables);
    {(ltrim string optionalchar)}
  • trim - remove leading and trailing spaces (default) or character if optional parameter supplied (useful for page text variables);
    {(trim string optionalchar)}
  • nomarkup - remove markup such as separators (! headings, ----), lists (*, #, : :), emphasis ('', ''', [++], [--], etc), paragraphs ([[<<]], -<, ->), and optionally groups ([[x|y]] becomes y)
    {(nomarkup string nolinks)}
  • word - return specified word(s) (alfanum+"_"+"-"). If second number is greater than no of word, return all words til the end (KAL?)
    {(word string 1)} = return first word
    {(word string 2 4)} = return second, third and fourth word
  • token - return parsed string, list of valid separators is specified as 1. argument, no of token as 2. argument (KAL?)
    {(token string 'list-of-sep-chars' 3)}
  • return string before a target string (KAL?)
    • e.g.: {(stringbefore "sample string to be parsed" "ng")} will return "sample stri"
    • PHP-code to add to markupexpressions.php:
# return substring of string before targetstring:
##  expressions like {(stringbefore string targetstring)}
$MarkupExpr['stringbefore'] = 'stringbefore($args[0],$args[1])';

function stringbefore($text,$target)
{
  list($text2,$null) = explode($target,$text);
  return $text2;
}

how do I achieve the following

  • obtain the last n characters of a string
Use {(substr "string" -n)}
  • truncate the last n characters of a string
Use {(substr "string" 0 -n)}

Working examples

* "{$Name}"
# {(substr "{$Name}" 6 -5)}
# {(substr "{$Name}" -5)}
# {(substr "{$Name}" 0)}

# {(substr "{$Name}" 0 -5)}
# {(substr "{$Name}" -5 4)}
# {(substr "{$Name}" -5 -6)}
  • "MarkupExpressions-Talk"
  1. Expressions
  2. -Talk
  3. MarkupExpressions-Talk
  4. MarkupExpressions
  5. -Tal

Is it possible to nest markup expressions?

looks like the answer is no
{(substr "{$FullName}" 0 -5)}

{(asspaced '{$FullName}')}

{(asspaced '{(substr "{$FullName}" 0 -5)}')}

PmWiki.MarkupExpressions

Pm Wiki.Markup Expressions-Talk

(asspaced '{PmWiki.MarkupExpressions')}


This is a talk page for improving PmWiki.MarkupExpressions.