<?php if(!defined('PmWiki'))exit; /* A markup to display html tags from source code of a PmWiki page. Written by (c) Antony Templier 2011-2015 This text is written for PmWiki; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. See pmwiki.php for full details and lack of warranty. This text is partly based on the code of (:markup:)(:markupend:) in stdmarkup.php script. Copyright 2011-2015 Antony Templier Copyright 2004-2007 Patrick R. Michaud http://www.pmichaud.com Installation : in local/config.php add the following line. include_once("$FarmD/cookbook/displayhtml.php"); Usage : (:markup html=1:) Some pmwiki code ... (:markupend:) */ $RecipeInfo['DisplayHtml']['Version'] = '20150720'; ## (:markup:) for displaying markup examples function MarkupMarkupExtended($pagename, $text, $opt = '') { global $MarkupWordwrapFunction, $MarkupWrapTag; SDV($MarkupWordwrapFunction, PCCF('return str_replace(" ", " ", nl2br($m));')); SDV($MarkupWrapTag, 'code'); $MarkupMarkupOpt = array('class' => 'vert'); $opt = array_merge($MarkupMarkupOpt, ParseArgs($opt)); $html = MarkupToHTML($pagename, $text, array('escape' => 0)); if (@$opt['caption']) $caption = str_replace("'", ''', "<caption>{$opt['caption']}</caption>"); $class = preg_replace('/[^-\\s\\w]+/', ' ', @$opt['class']); if (strpos($class, 'horiz') !== false) { $sep = ''; $pretext = $MarkupWordwrapFunction($text, 40); } else { $sep = '</tr><tr>'; $pretext = $MarkupWordwrapFunction($text, 75); } /*------------------------------ * Get html tag with htmlentities */ $codehtml = htmlentities($html, ENT_QUOTES ); /*------------------------------ * Conditional output with html=1 */ if(@$opt['html']) { # ouptut with html tags $result = @"<table class='markup $class' align='center'>$caption <tr> <td class='markup1' valign='top'><h5>Source:</h5><$MarkupWrapTag>$pretext</$MarkupWrapTag></td>$sep <td class='markup1' valign='top'><h5>Html:</h5><pre>$codehtml</pre></td>$sep <td class='markup2' valign='top'><h5>Render:</h5><br />$html</td> </tr></table>"; } else { # Standard outout as in stdmarkup.php script. $result = @"<table class='markup $class' align='center'>$caption <tr><td class='markup1' valign='top'><$MarkupWrapTag>$pretext</$MarkupWrapTag></td>$sep<td class='markup2' valign='top'>$html</td></tr> </table>"; } return Keep($result); } Markup_e('markup', '<[=', "/\\(:markup(\\s+([^\n]*?))?:\\)[^\\S\n]*\\[([=@])(.*?)\\3\\]/si", "MarkupMarkupExtended(\$pagename, \$m[4], \$m[2])"); Markup_e('markupend', '>markup', "/\\(:markup(\\s+([^\n]*?))?:\\)[^\\S\n]*\n(.*?)\\(:markupend:\\)/si", "MarkupMarkupExtended(\$pagename, \$m[3], \$m[1])"); SDV($HTMLStylesFmt['markup'], " table.markup { border:2px dotted #ccf; width:90%; } td.markup1, td.markup2 { padding-left:10px; padding-right:10px; } table.vert td.markup1 { border-bottom:1px solid #ccf; } table.horiz td.markup1 { width:23em; border-right:1px solid #ccf; } table.markup caption { text-align:left; } div.faq p, div.faq pre { margin-left:2em; } div.faq p.question { margin:1em 0 0.75em 0; font-weight:bold; } div.faqtoc div.faq * { display:none; } div.faqtoc div.faq p.question { display:block; font-weight:normal; margin:0.5em 0 0.5em 20px; line-height:normal; } div.faqtoc div.faq p.question * { display:inline; } "); ?>