Skip to content

Commit

Permalink
Another attempt at fixing combinations of em and links
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian Fagir authored and michitux committed Mar 8, 2014
1 parent 59ac7be commit 0d73e52
Showing 1 changed file with 49 additions and 44 deletions.
93 changes: 49 additions & 44 deletions inc/parser/parser.php
Expand Up @@ -357,53 +357,58 @@ function getSort() {
*/
class Doku_Parser_Mode_formatting extends Doku_Parser_Mode {
var $type;

var $formatting = array (
'strong' => array (
'entry'=>'\*\*(?=.*\*\*)',
'exit'=>'\*\*',
'sort'=>70
),

'emphasis'=> array (
'entry'=>'//(?=[^\x00]*[^:])', //hack for bugs #384 #763 #1468
'exit'=>'//',
'sort'=>80
),

'underline'=> array (
'entry'=>'__(?=.*__)',
'exit'=>'__',
'sort'=>90
),

'monospace'=> array (
'entry'=>'\x27\x27(?=.*\x27\x27)',
'exit'=>'\x27\x27',
'sort'=>100
),

'subscript'=> array (
'entry'=>'<sub>(?=.*</sub>)',
'exit'=>'</sub>',
'sort'=>110
),

'superscript'=> array (
'entry'=>'<sup>(?=.*</sup>)',
'exit'=>'</sup>',
'sort'=>120
),

'deleted'=> array (
'entry'=>'<del>(?=.*</del>)',
'exit'=>'</del>',
'sort'=>130
),
);
var $formatting;

function Doku_Parser_Mode_formatting($type) {
global $PARSER_MODES;
$ltrs = '\w';
$gunk = '/\#~:.?+=&%@!\-\[\]';
$punc = '.:?\-;,';
$any = $ltrs.$gunk.$punc;

$this->formatting = array (
'strong' => array (
'entry'=>'\*\*(?=.*\*\*)',
'exit'=>'\*\*',
'sort'=>70
),

'emphasis'=> array (
'entry'=>'//(?=.*(?:[^:]//|//[^'.$any.']))',
'exit'=>'//',
'sort'=>80
),

'underline'=> array (
'entry'=>'__(?=.*__)',
'exit'=>'__',
'sort'=>90
),

'monospace'=> array (
'entry'=>'\x27\x27(?=.*\x27\x27)',
'exit'=>'\x27\x27',
'sort'=>100
),

'subscript'=> array (
'entry'=>'<sub>(?=.*</sub>)',
'exit'=>'</sub>',
'sort'=>110
),

'superscript'=> array (
'entry'=>'<sup>(?=.*</sup>)',
'exit'=>'</sup>',
'sort'=>120
),

'deleted'=> array (
'entry'=>'<del>(?=.*</del>)',
'exit'=>'</del>',
'sort'=>130
),
);

if ( !array_key_exists($type, $this->formatting) ) {
trigger_error('Invalid formatting type '.$type, E_USER_WARNING);
Expand Down

0 comments on commit 0d73e52

Please sign in to comment.