File tree Expand file tree Collapse file tree 4 files changed +22
-2
lines changed
Expand file tree Collapse file tree 4 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,12 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip
44
55## [ Unreleased] [ unreleased ]
66
7+ ### Added
8+ - Added support for ordered lists starting at numbers other than 1
9+
10+ ### Fixed
11+ - Fixed overly-eager escaping of list-like text (#141 )
12+
713## [ 4.5.0]
814### Added
915 - Added configuration option for list item style (#135 , #136 )
Original file line number Diff line number Diff line change @@ -48,7 +48,11 @@ public function convert(ElementInterface $element)
4848 return $ prefix . $ list_item_style . ' ' . $ value . "\n" ;
4949 }
5050
51- $ number = $ element ->getSiblingPosition ();
51+ if ($ list_type === 'ol ' && $ start = $ element ->getParent ()->getAttribute ('start ' )) {
52+ $ number = $ start + $ element ->getSiblingPosition () - 1 ;
53+ } else {
54+ $ number = $ element ->getSiblingPosition ();
55+ }
5256
5357 return $ prefix . $ number . '. ' . $ value . "\n" ;
5458 }
Original file line number Diff line number Diff line change @@ -109,7 +109,8 @@ private function escapeOtherCharactersRegex($line)
109109 {
110110 $ regExs = array (
111111 // Match numbers ending on ')' or '.' that are at the beginning of the line.
112- '/^[0-9]+(?=\)|\.)/ '
112+ // They will be escaped if immediately followed by a space or newline.
113+ '/^[0-9]+(?=(\)|\.)( |$))/ '
113114 );
114115
115116 foreach ($ regExs as $ i ) {
Original file line number Diff line number Diff line change @@ -133,6 +133,7 @@ public function test_lists()
133133 $ this ->html_gives_markdown ("<ol> \n <li>Item A</li> \n <li>Item B</li> \n</ol> " , "1. Item A \n2. Item B " );
134134 $ this ->html_gives_markdown ('<ol><li> Item A</li><li> Item B</li></ol> ' , "1. Item A \n2. Item B " );
135135 $ this ->html_gives_markdown ('<ol><li> <h3> Item A</h3><p>Description</p></li><li> Item B</li></ol> ' , "1. ### Item A \n \n Description \n2. Item B " );
136+ $ this ->html_gives_markdown ('<ol start="120"><li>Item A</li><li>Item B</li></ol> ' , "120. Item A \n121. Item B " );
136137 }
137138
138139 public function test_nested_lists ()
@@ -142,6 +143,14 @@ public function test_nested_lists()
142143 $ this ->html_gives_markdown ('<ol><li>Item A<ul><li>Nested A</li></ul></li><li>Item B</li></ol> ' , "1. Item A \n - Nested A \n2. Item B " );
143144 }
144145
146+ public function test_list_like_things_which_arent_lists ()
147+ {
148+ $ this ->html_gives_markdown ('<p>120.<p> ' , '120\. ' );
149+ $ this ->html_gives_markdown ('<p>120. <p> ' , '120\. ' );
150+ $ this ->html_gives_markdown ('<p>120.00<p> ' , '120.00 ' );
151+ $ this ->html_gives_markdown ('<p>120.00 USD<p> ' , '120.00 USD ' );
152+ }
153+
145154 public function test_code_samples ()
146155 {
147156 $ this ->html_gives_markdown ('<code><p>Some sample HTML</p></code> ' , '`<p>Some sample HTML</p>` ' );
You can’t perform that action at this time.
0 commit comments