Skip to content
This repository was archived by the owner on Sep 24, 2022. It is now read-only.

Commit 7acd989

Browse files
authored
Merge pull request #1 from scpwiki/develop
Resolve issues with multiline regex strings, replaced with concatenated strings.
2 parents c10e8b2 + d1ad605 commit 7acd989

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+498
-504
lines changed

Text/Wiki/Parse/Default/Anchor.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ class Text_Wiki_Parse_Anchor extends Text_Wiki_Parse {
4545
* @var string
4646
*
4747
*/
48-
public $regex = '/
49-
(\[\[#\s) # Two brackets, then hash
50-
([-_A-Za-z0-9.%]+?) # Contents of anchor
51-
(\]\]) # Closing brackets
52-
/ix';
48+
public $regex = '/' .
49+
'(\[\[\#\s)' . # Two brackets, then hash
50+
'([-_A-Za-z0-9.%]+?)' . # Contents of anchor
51+
'(\]\])' . # Closing brackets
52+
'/ix';
5353

5454
/**
5555
*

Text/Wiki/Parse/Default/Bibcite.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ class Text_Wiki_Parse_Bibcite extends Text_Wiki_Parse {
4343
*
4444
*/
4545

46-
public $regex = '/
47-
\(\( # Opening parens
48-
bibcite\s # Module name and whitespace
49-
([a-z0-9]+) # Alphanumeric citation
50-
\)\) # Closing parens
51-
/ix';
46+
public $regex = '/' .
47+
'\(\(' . # Opening parens
48+
'bibcite\s' . # Module name and whitespace
49+
'([a-z0-9]+)' . # Alphanumeric citation
50+
'\)\)' . # Closing parens
51+
'/ix';
5252

5353
function process(&$matches) {
5454
$label = $matches[1];

Text/Wiki/Parse/Default/Bibliography.php

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ class Text_Wiki_Parse_Bibliography extends Text_Wiki_Parse {
3333
public $regex = null;
3434

3535
function parse() {
36-
$regex = '/
37-
^ # Start of line
38-
\[\[bibliography # Tag name
39-
(\s+[^\]]+)? # Parameters
40-
\]\]
41-
(.*?) # Contents
42-
\[\[\/bibliography\]\] # End tag
43-
[\s]*$ # Allow whitespace until end of the line
44-
/smx';
36+
$regex = '/' .
37+
'^' . # Start of line
38+
'\[\[bibliography' . # Tag name
39+
'(\s+[^\]]+)?' . # Parameters
40+
'\]\]' .
41+
'(.*?)' . # Contents
42+
'\[\[\/bibliography\]\]' . # End tag
43+
'[\s]*$' . # Allow whitespace until end of the line
44+
'/smx';
4545
$this->wiki->source = preg_replace_callback($regex,
4646
array(&$this, 'process'), $this->wiki->source, 1);
4747
}
@@ -57,15 +57,16 @@ function process(&$matches) {
5757
// parse the "inner" manually inserting delimiters
5858
$bi = $this->wiki->parseObj['Bibitem'];
5959

60-
$inside = preg_replace_callback("/
61-
^ # Start of line
62-
:\s? # Colon, then optional whitespace
63-
([a-z0-9]+) # Lowercase alphanumeric bib item name
64-
\s? # Optional whitespace
65-
:\s # Colon then mandatory whitespace
66-
(.*) # Rest of the line is the item definition
67-
$ # End of line
68-
/mix",
60+
$inside = preg_replace_callback(
61+
'/' .
62+
'^' . # Start of line
63+
':\s?' . # Colon, then optional whitespace
64+
'([a-z0-9]+)' . # Lowercase alphanumeric bib item name
65+
'\s?' . # Optional whitespace
66+
':\s' . # Colon then mandatory whitespace
67+
'(.*)' . # Rest of the line is the item definition
68+
'$' . # End of line
69+
'/mix',
6970
array(&$bi, 'process'), $inner);
7071

7172
return "\n" . $this->wiki->addToken($this->rule, array(

Text/Wiki/Parse/Default/Blockquote.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ class Text_Wiki_Parse_Blockquote extends Text_Wiki_Parse {
5151
*
5252
*/
5353

54-
public $regex = '/
55-
\n # Start at a newline
56-
((\>).*?\n) # Match a >, then anything up until a newline
57-
(?!(\>)) # Assert that the newline is not followed by a >
58-
/sx';
54+
public $regex = '/' .
55+
'\n' . # Start at a newline
56+
'((\>).*?\n)' . # Match a >, then anything up until a newline
57+
'(?!(\>))' . # Assert that the newline is not followed by a >
58+
'/sx';
5959
# Sorry, what? A line of blockquote //cannot// be followed by another
6060
# line? Am I reading that correctly? Then why is the second > captured?
6161
# ANSWER: This module doesn't even use this regex. Nice one, Wikidot.
@@ -93,12 +93,12 @@ function process(&$matches)
9393
// create an array called $list that contains a new set of
9494
// matches for the various list-item elements.
9595
preg_match_all(
96-
'/
97-
^
98-
(\>+?) # At least one >
99-
\s # Require exactly one whitespace
100-
(.*?\n) # Include anything else up until a newline
101-
/msx',
96+
'/' .
97+
'^' .
98+
'(\>+?)' . # At least one >
99+
'\s' . # Require exactly one whitespace
100+
'(.*?\n)' . # Include anything else up until a newline
101+
'/msx',
102102
$matches[1],
103103
$list,
104104
PREG_SET_ORDER

Text/Wiki/Parse/Default/Bold.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ class Text_Wiki_Parse_Bold extends Text_Wiki_Parse {
5151
*
5252
*/
5353

54-
public $regex = "/
55-
''' # Opening triple single-quotes
56-
(
57-
() # Nothing (captured, for some reason)
58-
|[^'].*?) # OR any text that doesn't start with a single quote
59-
''' # Closing triple single-quotes
60-
/x";
54+
public $regex = "/" .
55+
"'''" . # Opening triple single-quotes
56+
"(" .
57+
"()" . # Nothing (captured, for some reason)
58+
"|[^'].*?)" . # OR any text that doesn't start with a single quote
59+
"'''" . # Closing triple single-quotes
60+
"/x";
6161

6262
/**
6363
*

Text/Wiki/Parse/Default/Button.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@
2828
*/
2929
class Text_Wiki_Parse_Button extends Text_Wiki_Parse {
3030

31-
public $regex = '/
32-
\[\[ # Opening brackets
33-
button\s+ # Tag name
34-
([a-z0-9\-_]+) # Button name
35-
(?:\s+(.+?))? # Optional button parameters
36-
\]\] # Closing brackets
37-
/isx';
31+
public $regex = '/' .
32+
'\[\[' . # Opening brackets
33+
'button\s+' . # Tag name
34+
'([a-z0-9\-_]+)' . # Button name
35+
'(?:\s+(.+?))?' . # Optional button parameters
36+
'\]\]' . # Closing brackets
37+
'/isx';
3838

3939
function process(&$matches)
4040
{

Text/Wiki/Parse/Default/Clearfloat.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ class Text_Wiki_Parse_Clearfloat extends Text_Wiki_Parse {
4343
*
4444
*/
4545

46-
public $regex = '/
47-
^
48-
([~]{4,}) # ~~~~
49-
(>|<)? # Optional directional modifier
50-
$
51-
/mx';
46+
public $regex = '/' .
47+
'^' .
48+
'([~]{4,})' . # ~~~~
49+
'(>|<)?' . # Optional directional modifier
50+
'$' .
51+
'/mx';
5252

5353
/**
5454
*

Text/Wiki/Parse/Default/Collapsible.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ class Text_Wiki_Parse_Collapsible extends Text_Wiki_Parse {
4343
*
4444
*/
4545

46-
public $regex = '/
47-
(\n)? # Start with an optional newline?
48-
\[\[
49-
collapsible
50-
(\s.*?)? # Parameters of collapsbile
51-
\]\]
52-
(.*?) # Contents of collapsible - no nesting
53-
\[\[\/collapsible\]\]\s*
54-
/msix';
46+
public $regex = '/' .
47+
'(\n)?' . # Start with an optional newline?
48+
'\[\[' .
49+
'collapsible' .
50+
'(\s.*?)?' . # Parameters of collapsbile
51+
'\]\]' .
52+
'(.*?)' . # Contents of collapsible - no nesting
53+
'\[\[\/collapsible\]\]\s*' .
54+
'/msix';
5555

5656
/**
5757
*

Text/Wiki/Parse/Default/Colortext.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ class Text_Wiki_Parse_Colortext extends Text_Wiki_Parse {
4747
*
4848
*/
4949

50-
public $regex = '/
51-
\#\#
52-
(.+?) # Colour
53-
\| # Pipe to split colour and text
54-
(.+?) # Text
55-
\#\#
56-
/x';
50+
public $regex = '/' .
51+
'\#\#' .
52+
'(.+?)' . # Colou?r
53+
'\|' . # Pipe to split colour and text
54+
'(.+?)' . # Text
55+
'\#\#' .
56+
'/x';
5757

5858
/**
5959
*

Text/Wiki/Parse/Default/Comment.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ class Text_Wiki_Parse_Comment extends Text_Wiki_Parse {
4141
*
4242
*/
4343

44-
public $regex = '/
45-
(\n)? # Optional newline?
46-
\[!\-\- # [!--
47-
(.*?) # Any text - no nesting
48-
\-\-\] # --]
49-
/six';
44+
public $regex = '/' .
45+
'(\n)?' . # Optional newline?
46+
'\[!\-\-' . # [!--
47+
'(.*?)' . # Any text - no nesting
48+
'\-\-\]' . # --]
49+
'/six';
5050

5151
/**
5252
*

0 commit comments

Comments
 (0)