File tree Expand file tree Collapse file tree 6 files changed +233
-14
lines changed
testdata/TestCommonmark/list Expand file tree Collapse file tree 6 files changed +233
-14
lines changed Original file line number Diff line number Diff line change @@ -91,7 +91,12 @@ var commonmark = []Rule{
9191 text = escape .MarkdownCharacters (text )
9292
9393 // if its inside a list, trim the spaces to not mess up the indentation
94- if IndexWithText (selec ) == 0 && (selec .Parent ().Is ("li" ) || selec .Parent ().Is ("ol" ) || selec .Parent ().Is ("ul" )) {
94+ parent := selec .Parent ()
95+ next := selec .Next ()
96+ if IndexWithText (selec ) == 0 &&
97+ (parent .Is ("li" ) || parent .Is ("ol" ) || parent .Is ("ul" )) &&
98+ (next .Is ("ul" ) || next .Is ("ol" )) {
99+ // trim only spaces and not new lines
95100 text = strings .Trim (text , ` ` )
96101 }
97102
Original file line number Diff line number Diff line change 7777</li>
7878</ol>
7979<ul>
80- <li>Link:<a href="https://example.com">example</a> works</li>
81- <li>Link:
80+ <li>
81+ <p>Link: <a href="https://example.com">example</a> works</p>
82+ </li>
83+ <li>
84+ <p>Link:
85+ <a href="https://example.com">example</a>
86+ works</p>
87+ </li>
88+ <li>
89+ <p>Link:
90+ <a href="https://example.com">example</a>
91+ works</p>
92+ </li>
93+ <li>
94+ <p>Link:
95+ <a href="https://example.com">example</a>
96+ works</p>
97+ </li>
98+ <li>
99+ <p>Link:
82100<a href="https://example.com">example</a>
83- works</li>
101+ works</p>
102+ </li>
84103</ul>
85104<ol>
86- <li>First Thing
105+ <li>
106+ <p>Link: <a href="https://example.com">example</a> works</p>
107+ </li>
108+ <li>
109+ <p>Link:
110+ <a href="https://example.com">example</a>
111+ works</p>
112+ </li>
113+ <li>
114+ <p>First Thing</p>
87115<ul>
88116<li>Some Thing</li>
89117<li>Another Thing</li>
90118</ul>
91119</li>
92- <li>Second Thing</li>
120+ <li>
121+ <p>Second Thing</p>
122+ </li>
93123</ol>
94124<ul>
95125<li>
@@ -129,3 +159,28 @@ with two lines.</p>
129159</blockquote>
130160</li>
131161</ol>
162+ <ul>
163+ <li>
164+ <p><a href="http://example.com/icon"><img src="http://example.com/icon.png" alt=""></a></p>
165+ <h3>Title</h3>
166+ <p>Description</p>
167+ </li>
168+ <li>
169+ <p>All manually reviewed <em>Drosophila melanogaster</em> entries</p>
170+ </li>
171+ <li>
172+ <p>All manually reviewed <em>Drosophila pseudoobscura pseudoobscura</em> entries</p>
173+ </li>
174+ <li>
175+ <p>before <em>middle</em> after</p>
176+ </li>
177+ <li>
178+ <p>before <em>middle</em> after</p>
179+ </li>
180+ <li>
181+ <p>before <em>middle</em> after</p>
182+ </li>
183+ <li>
184+ <p>before <em>middle</em> after</p>
185+ </li>
186+ </ul>
Original file line number Diff line number Diff line change 4444</ ol >
4545
4646
47- <!--list with link inside-->
47+ <!--ul list with link inside-->
4848< ul >
4949 < li > Link: < a href ="https://example.com " target ="_blank "> example</ a > works</ li >
5050 < li >
5151 Link:
5252 < a href ="https://example.com " target ="_blank "> example</ a >
5353 works
5454 </ li >
55+ < li >
56+ Link:
57+ < a href ="https://example.com " target ="_blank "> example</ a >
58+ works
59+ </ li >
60+ < li >
61+ Link:
62+ < a href ="https://example.com " target ="_blank "> example</ a >
63+ works
64+ </ li >
65+ < li >
66+ Link:
67+ < a href ="https://example.com " target ="_blank "> example</ a >
68+ works
69+ </ li >
5570</ ul >
5671
72+ <!--ul list with link inside-->
73+ < ol >
74+ < li > Link: < a href ="https://example.com " target ="_blank "> example</ a > works</ li >
75+ < li >
76+ Link:
77+ < a href ="https://example.com " target ="_blank "> example</ a >
78+ works
79+ </ li >
80+ </ ol >
81+
5782<!--ol with a ul inside-->
5883< ol >
5984 < li >
112137 < p > A block quote.</ p >
113138 </ blockquote >
114139 </ li >
115- </ ol >
140+ </ ol >
141+
142+
143+ <!--list with img, heading-->
144+ < ul >
145+ < li >
146+ < a href ="/icon ">
147+ < img src ="/icon.png " />
148+ </ a >
149+ < div class ="content ">
150+ < h3 > Title</ h3 >
151+ < p > Description</ p >
152+ </ div >
153+ </ li >
154+ </ ul >
155+
156+
157+ <!--with em-->
158+ < ul style ="list-style-type:disc ">
159+ < li > All manually reviewed < em > Drosophila melanogaster</ em > entries</ li >
160+ < li > All manually reviewed < em > Drosophila pseudoobscura pseudoobscura</ em > entries</ li >
161+
162+ < li > before < em > middle</ em > after</ li >
163+ < li > before< em > middle</ em > after</ li >
164+ < li > before< em > middle</ em > after</ li >
165+ < li > before < em > middle</ em > after</ li >
166+ </ ul >
Original file line number Diff line number Diff line change 272724. 
282825. 22
2929
30- * Link:[example](https://example.com) works
30+ * Link: [example](https://example.com) works
31+ * Link:
32+ [example](https://example.com)
33+ works
34+
35+ * Link:
36+ [example](https://example.com)
37+ works
38+
3139* Link:
3240 [example](https://example.com)
41+ works
42+
43+ * Link:
44+ [example](https://example.com)
3345 works
3446
3547
48+ 1. Link: [example](https://example.com) works
49+ 2. Link:
50+ [example](https://example.com)
51+ works
52+
53+
36541. First Thing
3755 * Some Thing
3856 * Another Thing
6684
6785
6886
69- > A block quote.
87+ > A block quote.
88+
89+
90+ * [](http://example.com/icon)
91+
92+
93+ ### Title
94+
95+
96+
97+ Description
98+
99+
100+ * All manually reviewed _Drosophila melanogaster_ entries
101+ * All manually reviewed _Drosophila pseudoobscura pseudoobscura_ entries
102+ * before _middle_ after
103+ * before _middle_ after
104+ * before _middle_ after
105+ * before _middle_ after
Original file line number Diff line number Diff line change 272724. 
282825. 22
2929
30- - Link:[example](https://example.com) works
30+ - Link: [example](https://example.com) works
31+ - Link:
32+ [example](https://example.com)
33+ works
34+
35+ - Link:
36+ [example](https://example.com)
37+ works
38+
3139- Link:
3240 [example](https://example.com)
41+ works
42+
43+ - Link:
44+ [example](https://example.com)
3345 works
3446
3547
48+ 1. Link: [example](https://example.com) works
49+ 2. Link:
50+ [example](https://example.com)
51+ works
52+
53+
36541. First Thing
3755 - Some Thing
3856 - Another Thing
6684
6785
6886
69- > A block quote.
87+ > A block quote.
88+
89+
90+ - [](http://example.com/icon)
91+
92+
93+ ### Title
94+
95+
96+
97+ Description
98+
99+
100+ - All manually reviewed _Drosophila melanogaster_ entries
101+ - All manually reviewed _Drosophila pseudoobscura pseudoobscura_ entries
102+ - before _middle_ after
103+ - before _middle_ after
104+ - before _middle_ after
105+ - before _middle_ after
Original file line number Diff line number Diff line change 272724. 
282825. 22
2929
30- + Link:[example](https://example.com) works
30+ + Link: [example](https://example.com) works
31+ + Link:
32+ [example](https://example.com)
33+ works
34+
35+ + Link:
36+ [example](https://example.com)
37+ works
38+
3139+ Link:
3240 [example](https://example.com)
41+ works
42+
43+ + Link:
44+ [example](https://example.com)
3345 works
3446
3547
48+ 1. Link: [example](https://example.com) works
49+ 2. Link:
50+ [example](https://example.com)
51+ works
52+
53+
36541. First Thing
3755 + Some Thing
3856 + Another Thing
6684
6785
6886
69- > A block quote.
87+ > A block quote.
88+
89+
90+ + [](http://example.com/icon)
91+
92+
93+ ### Title
94+
95+
96+
97+ Description
98+
99+
100+ + All manually reviewed _Drosophila melanogaster_ entries
101+ + All manually reviewed _Drosophila pseudoobscura pseudoobscura_ entries
102+ + before _middle_ after
103+ + before _middle_ after
104+ + before _middle_ after
105+ + before _middle_ after
You can’t perform that action at this time.
0 commit comments