Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
CentralNic
parsedown
Commits
2bd2f81f
Commit
2bd2f81f
authored
May 12, 2014
by
Emanuil Rusev
Browse files
methods should not have more than one optional parameters
parent
e318e66d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Parsedown.php
View file @
2bd2f81f
...
...
@@ -934,17 +934,19 @@ class Parsedown
$markerPosition
=
0
;
while
(
$
markedE
xcerpt
=
strpbrk
(
$remainder
,
$this
->
spanMarkerList
))
while
(
$
e
xcerpt
=
strpbrk
(
$remainder
,
$this
->
spanMarkerList
))
{
$marker
=
$
markedE
xcerpt
[
0
];
$marker
=
$
e
xcerpt
[
0
];
$markerPosition
+=
strpos
(
$remainder
,
$marker
);
$Excerpt
=
array
(
'text'
=>
$excerpt
,
'context'
=>
$text
);
foreach
(
$this
->
SpanTypes
[
$marker
]
as
$spanType
)
{
$handler
=
'identify'
.
$spanType
;
$Span
=
$this
->
$handler
(
$
markedExcerpt
,
$tex
t
);
$Span
=
$this
->
$handler
(
$
Excerp
t
);
if
(
!
isset
(
$Span
))
{
...
...
@@ -980,7 +982,7 @@ class Parsedown
continue
2
;
}
$remainder
=
substr
(
$
markedE
xcerpt
,
1
);
$remainder
=
substr
(
$
e
xcerpt
,
1
);
$markerPosition
++
;
}
...
...
@@ -994,14 +996,14 @@ class Parsedown
# ~
#
protected
function
identifyUrl
(
$
e
xcerpt
,
$text
)
protected
function
identifyUrl
(
$
E
xcerpt
)
{
if
(
!
isset
(
$
e
xcerpt
[
1
])
or
$
e
xcerpt
[
1
]
!==
'/'
)
if
(
!
isset
(
$
E
xcerpt
[
'text'
][
1
])
or
$
E
xcerpt
[
'text'
][
1
]
!==
'/'
)
{
return
;
}
if
(
preg_match
(
'/\bhttps?:[\/]{2}[^\s<]+\b\/*/ui'
,
$text
,
$matches
,
PREG_OFFSET_CAPTURE
))
if
(
preg_match
(
'/\bhttps?:[\/]{2}[^\s<]+\b\/*/ui'
,
$
Excerpt
[
'con
text
'
]
,
$matches
,
PREG_OFFSET_CAPTURE
))
{
$url
=
str_replace
(
array
(
'&'
,
'<'
),
array
(
'&'
,
'<'
),
$matches
[
0
][
0
]);
...
...
@@ -1019,9 +1021,9 @@ class Parsedown
}
}
protected
function
identifyAmpersand
(
$
e
xcerpt
)
protected
function
identifyAmpersand
(
$
E
xcerpt
)
{
if
(
!
preg_match
(
'/^&#?\w+;/'
,
$
e
xcerpt
))
if
(
!
preg_match
(
'/^&#?\w+;/'
,
$
E
xcerpt
[
'text'
]
))
{
return
array
(
'markup'
=>
'&'
,
...
...
@@ -1030,14 +1032,14 @@ class Parsedown
}
}
protected
function
identifyStrikethrough
(
$
e
xcerpt
)
protected
function
identifyStrikethrough
(
$
E
xcerpt
)
{
if
(
!
isset
(
$
e
xcerpt
[
1
]))
if
(
!
isset
(
$
E
xcerpt
[
'text'
][
1
]))
{
return
;
}
if
(
$
e
xcerpt
[
1
]
===
$excerpt
[
0
]
and
preg_match
(
'/^~~(?=\S)(.+?)(?<=\S)~~/'
,
$
e
xcerpt
,
$matches
))
if
(
$
E
xcerpt
[
'text'
][
1
]
===
'~'
and
preg_match
(
'/^~~(?=\S)(.+?)(?<=\S)~~/'
,
$
E
xcerpt
[
'text'
]
,
$matches
))
{
return
array
(
'extent'
=>
strlen
(
$matches
[
0
]),
...
...
@@ -1050,12 +1052,12 @@ class Parsedown
}
}
protected
function
identifyEscapeSequence
(
$
e
xcerpt
)
protected
function
identifyEscapeSequence
(
$
E
xcerpt
)
{
if
(
isset
(
$
e
xcerpt
[
1
])
and
in_array
(
$
e
xcerpt
[
1
],
$this
->
specialCharacters
))
if
(
isset
(
$
E
xcerpt
[
'text'
][
1
])
and
in_array
(
$
E
xcerpt
[
'text'
][
1
],
$this
->
specialCharacters
))
{
return
array
(
'markup'
=>
$
e
xcerpt
[
1
],
'markup'
=>
$
E
xcerpt
[
'text'
][
1
],
'extent'
=>
2
,
);
}
...
...
@@ -1069,9 +1071,9 @@ class Parsedown
);
}
protected
function
identifyUrlTag
(
$
e
xcerpt
)
protected
function
identifyUrlTag
(
$
E
xcerpt
)
{
if
(
strpos
(
$
e
xcerpt
,
'>'
)
!==
false
and
preg_match
(
'/^<(https?:[\/]{2}[^\s]+?)>/i'
,
$
e
xcerpt
,
$matches
))
if
(
strpos
(
$
E
xcerpt
[
'text'
]
,
'>'
)
!==
false
and
preg_match
(
'/^<(https?:[\/]{2}[^\s]+?)>/i'
,
$
E
xcerpt
[
'text'
]
,
$matches
))
{
$url
=
str_replace
(
array
(
'&'
,
'<'
),
array
(
'&'
,
'<'
),
$matches
[
1
]);
...
...
@@ -1088,9 +1090,9 @@ class Parsedown
}
}
protected
function
identifyEmailTag
(
$
e
xcerpt
)
protected
function
identifyEmailTag
(
$
E
xcerpt
)
{
if
(
strpos
(
$
e
xcerpt
,
'>'
)
!==
false
and
preg_match
(
'/^<(\S+?@\S+?)>/'
,
$
e
xcerpt
,
$matches
))
if
(
strpos
(
$
E
xcerpt
[
'text'
]
,
'>'
)
!==
false
and
preg_match
(
'/^<(\S+?@\S+?)>/'
,
$
E
xcerpt
[
'text'
]
,
$matches
))
{
return
array
(
'extent'
=>
strlen
(
$matches
[
0
]),
...
...
@@ -1105,9 +1107,9 @@ class Parsedown
}
}
protected
function
identifyTag
(
$
e
xcerpt
)
protected
function
identifyTag
(
$
E
xcerpt
)
{
if
(
strpos
(
$
e
xcerpt
,
'>'
)
!==
false
and
preg_match
(
'/^<\/?\w.*?>/'
,
$
e
xcerpt
,
$matches
))
if
(
strpos
(
$
E
xcerpt
[
'text'
]
,
'>'
)
!==
false
and
preg_match
(
'/^<\/?\w.*?>/'
,
$
E
xcerpt
[
'text'
]
,
$matches
))
{
return
array
(
'markup'
=>
$matches
[
0
],
...
...
@@ -1116,11 +1118,11 @@ class Parsedown
}
}
protected
function
identifyInlineCode
(
$
e
xcerpt
)
protected
function
identifyInlineCode
(
$
E
xcerpt
)
{
$marker
=
$
e
xcerpt
[
0
];
$marker
=
$
E
xcerpt
[
'text'
][
0
];
if
(
preg_match
(
'/^('
.
$marker
.
'+)[ ]*(.+?)[ ]*(?<!'
.
$marker
.
')\1(?!'
.
$marker
.
')/'
,
$
e
xcerpt
,
$matches
))
if
(
preg_match
(
'/^('
.
$marker
.
'+)[ ]*(.+?)[ ]*(?<!'
.
$marker
.
')\1(?!'
.
$marker
.
')/'
,
$
E
xcerpt
[
'text'
]
,
$matches
))
{
$text
=
$matches
[
2
];
$text
=
htmlspecialchars
(
$text
,
ENT_NOQUOTES
,
'UTF-8'
);
...
...
@@ -1135,17 +1137,17 @@ class Parsedown
}
}
protected
function
identifyLink
(
$
e
xcerpt
)
protected
function
identifyLink
(
$
E
xcerpt
)
{
$extent
=
$
e
xcerpt
[
0
]
===
'!'
?
1
:
0
;
$extent
=
$
E
xcerpt
[
'text'
][
0
]
===
'!'
?
1
:
0
;
if
(
strpos
(
$
e
xcerpt
,
']'
)
and
preg_match
(
'/\[((?:[^][]|(?R))*)\]/'
,
$
e
xcerpt
,
$matches
))
if
(
strpos
(
$
E
xcerpt
[
'text'
]
,
']'
)
and
preg_match
(
'/\[((?:[^][]|(?R))*)\]/'
,
$
E
xcerpt
[
'text'
]
,
$matches
))
{
$Link
=
array
(
'text'
=>
$matches
[
1
],
'label'
=>
strtolower
(
$matches
[
1
]));
$extent
+=
strlen
(
$matches
[
0
]);
$substring
=
substr
(
$
e
xcerpt
,
$extent
);
$substring
=
substr
(
$
E
xcerpt
[
'text'
]
,
$extent
);
if
(
preg_match
(
'/^\s*\[([^][]+)\]/'
,
$substring
,
$matches
))
{
...
...
@@ -1194,7 +1196,7 @@ class Parsedown
$url
=
str_replace
(
array
(
'&'
,
'<'
),
array
(
'&'
,
'<'
),
$Link
[
'url'
]);
if
(
$
e
xcerpt
[
0
]
===
'!'
)
if
(
$
E
xcerpt
[
'text'
][
0
]
===
'!'
)
{
$Element
=
array
(
'name'
=>
'img'
,
...
...
@@ -1227,20 +1229,20 @@ class Parsedown
);
}
protected
function
identifyEmphasis
(
$
e
xcerpt
)
protected
function
identifyEmphasis
(
$
E
xcerpt
)
{
if
(
!
isset
(
$
e
xcerpt
[
1
]))
if
(
!
isset
(
$
E
xcerpt
[
'text'
][
1
]))
{
return
;
}
$marker
=
$
e
xcerpt
[
0
];
$marker
=
$
E
xcerpt
[
'text'
][
0
];
if
(
$
e
xcerpt
[
1
]
===
$marker
and
preg_match
(
$this
->
StrongRegex
[
$marker
],
$
e
xcerpt
,
$matches
))
if
(
$
E
xcerpt
[
'text'
][
1
]
===
$marker
and
preg_match
(
$this
->
StrongRegex
[
$marker
],
$
E
xcerpt
[
'text'
]
,
$matches
))
{
$emphasis
=
'strong'
;
}
elseif
(
preg_match
(
$this
->
EmRegex
[
$marker
],
$
e
xcerpt
,
$matches
))
elseif
(
preg_match
(
$this
->
EmRegex
[
$marker
],
$
E
xcerpt
[
'text'
]
,
$matches
))
{
$emphasis
=
'em'
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment