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
5aad1d42
Commit
5aad1d42
authored
Jul 25, 2013
by
Emanuil
Browse files
inline links should work with images
parent
3ff5c623
Changes
3
Hide whitespace changes
Inline
Side-by-side
Parsedown.php
View file @
5aad1d42
...
...
@@ -558,19 +558,19 @@ class Parsedown
# Inline Link / Image
if
(
strpos
(
$text
,
']('
)
!==
FALSE
and
preg_match_all
(
'/(!?)\[(
.*?
)\]\((.*?)\)/'
,
$text
,
$matches
,
PREG_SET_ORDER
))
# inline
if
(
strpos
(
$text
,
']('
)
!==
FALSE
and
preg_match_all
(
'/(!?)
(
\[(
(?:[^][]+|(?2))*
)\]
)
\((.*?)\)/'
,
$text
,
$matches
,
PREG_SET_ORDER
))
# inline
{
foreach
(
$matches
as
$matches
)
{
if
(
$matches
[
1
])
# image
{
$element
=
'<img alt="'
.
$matches
[
2
]
.
'" src="'
.
$matches
[
3
]
.
'">'
;
$element
=
'<img alt="'
.
$matches
[
3
]
.
'" src="'
.
$matches
[
4
]
.
'">'
;
}
else
{
$element_text
=
$this
->
parse_inline_elements
(
$matches
[
2
]);
$element_text
=
$this
->
parse_inline_elements
(
$matches
[
3
]);
$element
=
'<a href="'
.
$matches
[
3
]
.
'">'
.
$element_text
.
'</a>'
;
$element
=
'<a href="'
.
$matches
[
4
]
.
'">'
.
$element_text
.
'</a>'
;
}
$element_text
=
$this
->
parse_inline_elements
(
$matches
[
1
]);
...
...
tests/data/inline_link.html
View file @
5aad1d42
<p>
Here's a
<a
href=
"http://parsedown.org"
>
link
</a>
.
</p>
<p>
Here's an image link:
<a
href=
"http://daringfireball.net/projects/markdown/"
><img
alt=
"MD Logo"
src=
"http://parsedown.org/md.png"
></a>
.
</p>
\ No newline at end of file
tests/data/inline_link.md
View file @
5aad1d42
Here's a
[
link
](
http://parsedown.org
)
.
Here's an image link:
[

](http://daringfireball.net/projects/markdown/).
\ No newline at end of file
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