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
2e314ad4
Commit
2e314ad4
authored
Nov 02, 2013
by
Emanuil Rusev
Browse files
resolve #24
parent
e475602e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Parsedown.php
View file @
2e314ad4
...
...
@@ -122,6 +122,27 @@ class Parsedown
foreach
(
$lines
as
$line
)
{
# Block-Level HTML
if
(
$element
[
'type'
]
===
'block'
and
!
isset
(
$element
[
'closed'
]))
{
if
(
preg_match
(
'{<'
.
$element
[
'subtype'
]
.
'>$}'
,
$line
))
# <open>
{
$element
[
'depth'
]
++
;
}
if
(
preg_match
(
'{</'
.
$element
[
'subtype'
]
.
'>$}'
,
$line
))
# </close>
{
$element
[
'depth'
]
>
0
?
$element
[
'depth'
]
--
:
$element
[
'closed'
]
=
true
;
}
$element
[
'text'
]
.
=
"
\n
"
.
$line
;
continue
;
}
# Empty
if
(
$line
===
''
)
...
...
@@ -322,6 +343,38 @@ class Parsedown
continue
;
}
# Block-Level HTML <self-closing/>
if
(
preg_match
(
'{^<.+?/>$}'
,
$line
))
{
$elements
[]
=
$element
;
$element
=
array
(
'type'
=>
''
,
'text'
=>
$line
,
);
continue
;
}
# Block-Level HTML <open>
if
(
preg_match
(
'{^<(\w+)(?:[ ].*?)?>}'
,
$line
,
$matches
))
{
$elements
[]
=
$element
;
$element
=
array
(
'type'
=>
'block'
,
'subtype'
=>
strtolower
(
$matches
[
1
]),
'text'
=>
$line
,
'depth'
=>
0
,
);
preg_match
(
'{</'
.
$matches
[
1
]
.
'>\s*$}'
,
$line
)
and
$element
[
'closed'
]
=
true
;
continue
;
}
# ~
...
...
@@ -444,6 +497,10 @@ class Parsedown
$markup
.
=
'<hr />'
.
"
\n
"
;
break
;
default
:
$markup
.
=
$element
[
'text'
]
.
"
\n
"
;
}
}
...
...
tests/data/html.html
0 → 100644
View file @
2e314ad4
<p>
Self-closing tag:
</p>
<hr/>
<p>
Self-closing tag with attributes:
</p>
<hr
style=
"background: #eaa"
/>
<p>
Bare element:
</p>
<div>
content
</div>
<p>
Element with attributes:
</p>
<a
href=
"http://parsedown.org"
>
link
</a>
<p>
Nested elements:
</p>
<div>
parent
<div>
child
</div>
</div>
\ No newline at end of file
tests/data/html.md
0 → 100644
View file @
2e314ad4
Self-closing tag:
<hr/>
Self-closing tag with attributes:
<hr
style=
"background: #eaa"
/>
Bare element:
<div>
content
</div>
Element with attributes:
<a
href=
"http://parsedown.org"
>
link
</a>
Nested elements:
<div>
parent
<div>
child
</div>
</div>
\ 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