[pmwiki-users] How to embed SVG as editable text

Petko Yotov 5ko at 5ko.fr
Wed Aug 16 13:45:44 CDT 2017


Here is your markup rule and function, the 4 changed lines are marked 
with #changed or #added:

   Markup('svgtag','fulltext','/\\{\\*(.*?)\\*\\}/s',"litsvg"); #changed

   function litsvg($m){ #changed
     $string = $m[1]; #added
     $out = '';
     $string = str_replace(array('>', '<', '&'),
       array('>', '<', '&'), $string);
     $string = str_replace(array('</p>','<pre>','</pre>',
       "<p class='vspace'>",'\\"'), array('','','','','"'),$string);
     $out = $out . $string;
     return Keep($out); #changed
   }

Note, this requires at least PmWiki 2.2.56 (latest recommended). You may 
have to upgrade.

Petko

-- 
PmWeekly Blog  :  http://www.pmwiki.org/News
If you upgrade :  http://www.pmwiki.org/Upgrades


On 2017-08-16 19:10, Lars Eighner wrote:
> This used to work. But php 7 hates it:
> 
> 
> Markup('svgtag','fulltext','/\\{\\*(.*?)\\*\\}/esi',"Keep(litsvg('$1'))");
> 
> function litsvg($string){
> $out = '';
> $string = str_replace(array('>', '<', '&'),
>   array('>', '<', '&'), $string);
> $string = str_replace(array('</p>','<pre>','</pre>',
>   "<p class='vspace'>",'\\"'), array('','','','','"'),$string);
> $out = $out . $string;
> return $out;
> }
> 
> 
> On Wed, 16 Aug 2017, Petko Yotov wrote:
> 
>> You should have, either in local/config.php, or in some cookbook/*.php 
>> file a line or a block like this:
>> 
>>  Markup(   or  Markup_e(
>>    'svgedit', or something like this
>>    '/\\{\\*(.*?)\\*\\}/', or something like this
>>   'Keep(PSS("$1"))' or "FmtSVGEdit()" or something like this.
>>  );
>> 
>> The third expression is what should tip you, '/\\{\\*(.*?)\\*\\}/', or 
>> something like this (it can be written in multiple ways).
>> 
>> If you find such a line, we may be able to rewrite it for PHP 7.
>> 
>> Do you edit actual SVG code directly in the wiki source page, eg
>> 
>>  {*<svg xmlns="..."><path d="m56 56l-52-52"/></svg>*}
>> 
>> ?
>> 
>> Petko
>> 
>> 



More information about the pmwiki-users mailing list