Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F5691
quotes_regex.patch
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Authored By
•
bzimport
Nov 21 2014, 10:37 PM
2014-11-21 22:37:05 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
quotes_regex.patch
View Options
--- includes/parser/Parser-original.php 2009-09-28 15:51:44.000000000 +0200
+++ includes/parser/Parser.php 2009-09-28 16:52:08.000000000 +0200
@@ -1091,7 +1091,13 @@
* Helper function for doAllQuotes()
*/
public function doQuotes( $text ) {
- $arr = preg_split( "/(''+)/", $text, -1, PREG_SPLIT_DELIM_CAPTURE );
+ # Split in groups of 2, 3, 5 or 6 apostrophes.
+ # If there are ever four apostrophes, assume the first is supposed to
+ # be text, and the remaining three constitute mark-up for bold text.
+ # If there are more than 6 apostrophes in a row, assume they're all
+ # text except for the last 6.
+ $arr = preg_split( "/('{2,3}(?:''')?)(?!')/", $text, -1, PREG_SPLIT_DELIM_CAPTURE );
+
if ( count( $arr ) == 1 )
return $text;
else
@@ -1106,20 +1112,6 @@
{
if ( ( $i % 2 ) == 1 )
{
- # If there are ever four apostrophes, assume the first is supposed to
- # be text, and the remaining three constitute mark-up for bold text.
- if ( strlen( $arr[$i] ) == 4 )
- {
- $arr[$i-1] .= "'";
- $arr[$i] = "'''";
- }
- # If there are more than 6 apostrophes in a row, assume they're all
- # text except for the last 6.
- else if ( strlen( $arr[$i] ) > 6 )
- {
- $arr[$i-1] .= str_repeat( "'", strlen( $arr[$i] ) - 6 );
- $arr[$i] = "''''''";
- }
# Count the number of occurrences of bold and italics mark-ups.
# We are not counting sequences of five apostrophes.
if ( strlen( $arr[$i] ) == 2 ) { $numitalics++; }
File Metadata
Details
Attached
Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5241
Default Alt Text
quotes_regex.patch (1 KB)
Attached To
Mode
T20765: Bold/italic markup handled differently depending on leading whitespace
Attached
Detach File
Event Timeline
Log In to Comment