[dokuwiki] Re: & entities

  • From: Eddie Kohler <kohler@xxxxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Tue, 14 Feb 2006 16:58:41 -0800

Chris, this is not defining new syntax entities (like replacing >> with &laquo;), but about recognizing and preserving entities in the source (i.e., if the user types "&#7E;", leave that as "&#7E;" in the HTML output, rather than quoting it to "&amp;#7E;"). Among other things, this gives you a way to programmatically quote text that might be misinterpreted as wiki syntax.

Here is the patch.  Any comments?

diff -ru dokuwiki-2005-09-22/inc/parser/xhtml.php click-dokuwiki/inc/ parser/xhtml.php
--- dokuwiki-2005-09-22/inc/parser/xhtml.php 2005-10-18 14:21:16.000000000 -0700
+++ click-dokuwiki/inc/parser/xhtml.php 2006-01-12 22:58:37.000000000 -0800
@@ -37,6 +37,8 @@
var $entities = array();
var $interwiki = array();
+ var $htmltrans = array('<' => '&lt;', '>' => '&gt;');
+
var $lastsec = 0;
var $store = '';
@@ -986,7 +988,8 @@
}


function _xmlEntities($string) {
- return htmlspecialchars($string);
+ $ret = preg_replace('/&(?!#\d+;|#x(\d[a-zA-Z])+;|\w+;)/', '&amp;', $string);
+ return strtr($ret, $this->htmltrans);
}


     function _headerToLink($title) {


Eddie


On Feb 14, 2006, at 4:52 PM, Chris Smith wrote:

Eddie Kohler wrote:
Hi all,

I've written a patch that allows &whatever; entities to make it through to HTML. Other &s are quoted as usual. Would this be generally useful? Had someone else done it already?

Thanks,
Eddie

--DokuWiki mailing list - more info at
http://wiki.splitbrain.org/wiki:mailinglist

You can define entity codes in conf/entities.local.conf

Personally, I don't think a patch is appropriate, but a syntax plugin would be suitable.

Cheers,

Chris
--
DokuWiki mailing list - more info at
http://wiki.splitbrain.org/wiki:mailinglist

-- DokuWiki mailing list - more info at http://wiki.splitbrain.org/wiki:mailinglist

Other related posts: