From 9426a41aa622ea7c282f451c3274f167307f428d Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 13 Jun 2007 20:40:15 +0200 Subject: make typography option three staged FS#1142 Because correct smart quote parsing with regular expressions is nearly impossible, especially when dealing with quote usage in languages different from english, the typography configuration option was changed. 0 means to completely disable any typography replacements 1 will only handle the multiply entitity and double quotes, this should nearly always work without problems and is the new default 2 will add singlequote parsing. This might break because single quotes and apostrophes are not always easily distinguishable. Especially in languages where single quote openings and apostrophes are different characters you might experience problems. For english it should nearly always work. darcs-hash:20070613184015-7ad00-0cebc3f807f54467d54458075c5c9f651355c5ba.gz --- inc/parser/parser.php | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'inc/parser') diff --git a/inc/parser/parser.php b/inc/parser/parser.php index ee6a8beae..747c60333 100644 --- a/inc/parser/parser.php +++ b/inc/parser/parser.php @@ -702,9 +702,6 @@ class Doku_Parser_Mode_wordblock extends Doku_Parser_Mode { } //------------------------------------------------------------------- -/** -* @TODO Quotes and 640x480 are not supported - just straight replacements here -*/ class Doku_Parser_Mode_entity extends Doku_Parser_Mode { // A list var $entities = array(); @@ -758,18 +755,23 @@ class Doku_Parser_Mode_multiplyentity extends Doku_Parser_Mode { class Doku_Parser_Mode_quotes extends Doku_Parser_Mode { function connectTo($mode) { + global $conf; + $ws = '[\s/\#~:+=&%@\-;,\x28\x29\]\[{}><"\']'; // whitespace $nws = '[^\s/\#~:+=&%@\-;,\x28\x29\]\[{}><"\']'; // non whitespace - $this->Lexer->addSpecialPattern( - "(?<=^|$ws)'(?=$nws)",$mode,'singlequoteopening' - ); - $this->Lexer->addSpecialPattern( - "(?<=^|$nws)'(?=$|$ws)",$mode,'singlequoteclosing' - ); - $this->Lexer->addSpecialPattern( - "(?<=^|$nws)'(?=$|$nws)",$mode,'apostrophe' - ); + if($conf['typography'] == 2){ + $this->Lexer->addSpecialPattern( + "(?<=^|$ws)'(?=$nws)",$mode,'singlequoteopening' + ); + $this->Lexer->addSpecialPattern( + "(?<=^|$nws)'(?=$|$ws)",$mode,'singlequoteclosing' + ); + $this->Lexer->addSpecialPattern( + "(?<=^|$nws)'(?=$|$nws)",$mode,'apostrophe' + ); + } + $this->Lexer->addSpecialPattern( "(?<=^|$ws)\"(?=$nws)",$mode,'doublequoteopening' ); -- cgit v1.2.3