Changeset 1219
- Timestamp:
- 08/11/2008 03:21:08 PM (2 years ago)
- Files:
-
- 1 modified
-
trunk/formatters/wakka.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/formatters/wakka.php
r1218 r1219 1 1 <?php 2 2 /** 3 * Wikka Formatting Engine3 * The Wikka Formatting Engine 4 4 * 5 5 * This is the main formatting engine used by Wikka to parse wiki markup and render valid XHTML. … … 34 34 if (!defined('PATTERN_CODE')) define('PATTERN_CODE', '(.*)'); 35 35 /**#@-*/ 36 37 36 /** 38 37 * Match heading tags. … … 60 59 */ 61 60 if (!defined('PATTERN_MATCH_PAGE_FORMATOPTION')) define('PATTERN_MATCH_PAGE_FORMATOPTION', '/(^|;)page(;|$)/'); 61 /** 62 * Match "<a " when it isn't preceded by "</a>" 63 */ 64 if (!defined('PATTERN_OPEN_A_ALONE')) define('PATTERN_OPEN_A_ALONE', '(?<!</a>|^)<a '); 65 /** 66 * Match the end of a string when the string doesn't end with </a> 67 */ 68 if (!defined('PATTERN_END_OF_STRING_ALONE')) define('PATTERN_END_OF_STRING_ALONE', '(?<!</a>)$'); 69 /** 70 * Match "</a>" when it is not followed by an opening link markup (<a ) 71 */ 72 if (!defined('PATTERN_CLOSE_A_ALONE')) define('PATTERN_CLOSE_A_ALONE', '</a>(?!<a |$)'); 73 /** 74 * Match the start of a string when the string doesn't start with "<a " 75 */ 76 if (!defined('PATTERN_START_OF_STRING_ALONE')) define('PATTERN_START_OF_STRING_ALONE', '^(?!<a )'); 62 77 63 78 // @@@ is this condition handy? would prevent generating IDs on a page fragment … … 127 142 $opening_anchor = '<a class="heading" href="#'.$h_id.'">'; 128 143 $closing_anchor = '</a>'; 129 /**130 * Match "<a " when it isn't preceded by "</a>"131 */132 define('PATTERN_OPEN_A_ALONE', '(?<!</a>|^)<a ');133 /**134 * Match the end of a string when the string doesn't end with </a>135 */136 define('PATTERN_END_OF_STRING_ALONE', '(?<!</a>)$');137 /**138 * Match "</a>" when it is not followed by an opening link markup (<a )139 */140 define('PATTERN_CLOSE_A_ALONE', '</a>(?!<a |$)');141 /**142 * Match the start of a string when the string doesn't start with "<a "143 */144 define('PATTERN_START_OF_STRING_ALONE', '^(?!<a )');145 144 $h_heading = preg_replace('@('.PATTERN_OPEN_A_ALONE. '|'.PATTERN_END_OF_STRING_ALONE. ')@', $closing_anchor.'\\0', $h_heading); 146 145 $h_heading = preg_replace('@('.PATTERN_CLOSE_A_ALONE.'|'.PATTERN_START_OF_STRING_ALONE.')@', '\\0'.$opening_anchor, $h_heading); 147 146 148 147 // rebuild element, adding id 149 return '< '.$h_tagname.$h_attribs.' id="'.$h_id.'">'.$h_heading.'</'.$h_tagname.'>';148 return '<a class="heading" href="#'.$h_id.'"><'.$h_tagname.$h_attribs.' id="'.$h_id.'">'.$h_heading.'</'.$h_tagname.'></a>'; 150 149 } 151 150 }