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
f5f1706e
Commit
f5f1706e
authored
Feb 02, 2014
by
Emanuil Rusev
Browse files
improve consistency of list item
parent
b257d0ec
Changes
3
Hide whitespace changes
Inline
Side-by-side
Parsedown.php
View file @
f5f1706e
...
...
@@ -194,16 +194,14 @@ class Parsedown
case
'li'
:
if
(
$block
[
'indentation'
]
===
$indentation
and
preg_match
(
'/^'
.
$block
[
'marker'
]
.
'[ ](.*)/'
,
$deindented_line
,
$matches
))
if
(
$block
[
'indentation'
]
===
$indentation
and
preg_match
(
'/^'
.
$block
[
'marker'
]
.
'[ ]
+
(.*)/'
,
$deindented_line
,
$matches
))
{
unset
(
$block
[
'last'
]);
$blocks
[]
=
$block
;
$block
[
'last'
]
=
true
;
$block
[
'lines'
]
=
array
();
$block
[
'lines'
]
[]
=
preg_replace
(
'/^[ ]{0,4}/'
,
''
,
$matches
[
1
]);
$block
[
'lines'
]
=
array
(
$matches
[
1
]);
unset
(
$block
[
'first'
]);
unset
(
$block
[
'interrupted'
]);
...
...
@@ -213,7 +211,7 @@ class Parsedown
if
(
!
isset
(
$block
[
'interrupted'
]))
{
$line
=
preg_replace
(
'/^[ ]{0,
4
}/'
,
''
,
$line
);
$line
=
preg_replace
(
'/^[ ]{0,
'
.
$block
[
'baseline'
]
.
'
}/'
,
''
,
$line
);
$block
[
'lines'
]
[]
=
$line
;
...
...
@@ -223,7 +221,7 @@ class Parsedown
{
$block
[
'lines'
]
[]
=
''
;
$line
=
preg_replace
(
'/^[ ]{0,
4
}/'
,
''
,
$line
);
$line
=
preg_replace
(
'/^[ ]{0,
'
.
$block
[
'baseline'
]
.
'
}/'
,
''
,
$line
);
$block
[
'lines'
]
[]
=
$line
;
...
...
@@ -491,34 +489,40 @@ class Parsedown
# li
if
(
preg_match
(
'/^[*+-][ ](.*)/'
,
$deindented_line
,
$matches
))
if
(
preg_match
(
'/^
(
[*+-][ ]
+)
(.*)/'
,
$deindented_line
,
$matches
))
{
$blocks
[]
=
$block
;
$baseline
=
$indentation
+
strlen
(
$matches
[
1
]);
$block
=
array
(
'type'
=>
'li'
,
'indentation'
=>
$indentation
,
'baseline'
=>
$baseline
,
'marker'
=>
'[*+-]'
,
'first'
=>
true
,
'last'
=>
true
,
'lines'
=>
array
(),
);
$block
[
'lines'
]
[]
=
preg_replace
(
'/^[ ]{0,4}/'
,
''
,
$matches
[
1
]);
$block
[
'lines'
]
[]
=
preg_replace
(
'/^[ ]{0,4}/'
,
''
,
$matches
[
2
]);
continue
2
;
}
}
# li
st item
# li
if
(
$deindented_line
[
0
]
<=
'9'
and
preg_match
(
'/^\d+[.][ ](.*)/'
,
$deindented_line
,
$matches
))
if
(
$deindented_line
[
0
]
<=
'9'
and
preg_match
(
'/^
(
\d+[.][ ]
+)
(.*)/'
,
$deindented_line
,
$matches
))
{
$blocks
[]
=
$block
;
$baseline
=
$indentation
+
strlen
(
$matches
[
1
]);
$block
=
array
(
'type'
=>
'li'
,
'indentation'
=>
$indentation
,
'baseline'
=>
$baseline
,
'marker'
=>
'\d+[.]'
,
'first'
=>
true
,
'last'
=>
true
,
...
...
@@ -526,7 +530,7 @@ class Parsedown
'lines'
=>
array
(),
);
$block
[
'lines'
]
[]
=
preg_replace
(
'/^[ ]{0,4}/'
,
''
,
$matches
[
1
]);
$block
[
'lines'
]
[]
=
preg_replace
(
'/^[ ]{0,4}/'
,
''
,
$matches
[
2
]);
continue
;
}
...
...
tests/data/deeply_nested_list.html
0 → 100644
View file @
f5f1706e
<ul>
<li>
li
<ul>
<li>
li
<ul>
<li>
li
<ul>
<li>
li
</li>
</ul>
</li>
<li>
li
</li>
</ul>
</li>
<li>
li
</li>
</ul>
</li>
<li>
li
</li>
</ul>
\ No newline at end of file
tests/data/deeply_nested_list.md
0 → 100644
View file @
f5f1706e
-
li
-
li
-
li
-
li
-
li
-
li
-
li
\ 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