[pmwiki-users] Trouble with rss feeds

Peter Bowers pbowers at pobox.com
Mon Sep 3 14:49:54 CDT 2012

On Mon, Sep 3, 2012 at 8:38 AM, Ian MacGregor <ardchoille42 at gmail.com> wrote:
> function MarkupExcerpt($pagename) {
>       $page = RetrieveAuthPage($pagename, 'read', false);
>       return substr(@$page['text'], 0, 200);
>     }

It seems to me that rather than just stripping out the markup you
would want to process the markup using MarkupToHTML() or something
like RunMarkupRules from Cookbook/Toolbox.  Of course, this could
potentially be slow on long pages...

In any event, if all you want to do is strip out certain undesired
markups in the source, you could define MarkupExcerpt() like this:

function MarkupExcerpt($pagename) {
      $page = RetrieveAuthPage($pagename, 'read', false);
      $DisappearList = array("title", "Description", "Summary", "toc-float");
      $text = preg_replace("/\(:".implode("|",
$DisappearList).".*?:\)/", "", @$page['text']);
      return substr(@$text, 0, 200);

(Beware: untested code -- treat it as realistic pseudo-code and you
won't be disappointed... :-)  )

Of course this would require that all the markups that were going to
be deleted would be the (:KEYWORD ...:) type of markup.  But if you
had something else it's fairly trivial to just make a list of regular
expressions or something...

Is that what you were looking for?


More information about the pmwiki-users mailing list