Skip to content

Commit c87a78c

Browse files
Merge pull request #665 from Crozzers/emphasis-overhaul
Rewrite emphasis and strong processing to be more GFM compliant
2 parents a30892f + 749c9cb commit c87a78c

File tree

7 files changed

+991
-53
lines changed

7 files changed

+991
-53
lines changed

lib/markdown2.py

Lines changed: 451 additions & 50 deletions
Large diffs are not rendered by default.

test/tm-cases/gfm_emphasis.html

Lines changed: 269 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,269 @@
1+
<p><em>foo bar</em></p>
2+
3+
<p>a * foo bar*</p>
4+
5+
<p>a*"foo"*</p>
6+
7+
<ul>
8+
<li>a *</li>
9+
</ul>
10+
11+
<p>foo<em>bar</em></p>
12+
13+
<p>5<em>6</em>78</p>
14+
15+
<p>пристаням<em>стремятся</em></p>
16+
17+
<p>aa_"bb"_cc</p>
18+
19+
<p>foo-<em>(bar)</em></p>
20+
21+
<p>_foo*</p>
22+
23+
<p>*foo bar *</p>
24+
25+
<p>*foo bar
26+
*</p>
27+
28+
<p>*(*foo)</p>
29+
30+
<p><em>(<em>foo</em>)</em></p>
31+
32+
<p><em>foo</em>bar</p>
33+
34+
<p>_foo bar _</p>
35+
36+
<p>_(_foo)</p>
37+
38+
<p><em>(<em>foo</em>)</em></p>
39+
40+
<p><em>foo</em>bar</p>
41+
42+
<p><em>пристаням</em>стремятся</p>
43+
44+
<p><em>foo</em>bar<em>baz</em></p>
45+
46+
<p><em>(bar)</em>.</p>
47+
48+
<p><strong>foo bar</strong></p>
49+
50+
<p>** foo bar**</p>
51+
52+
<p>a**"foo"**</p>
53+
54+
<p>foo<strong>bar</strong></p>
55+
56+
<p><strong>foo bar</strong></p>
57+
58+
<p>__ foo bar__</p>
59+
60+
<p>__
61+
foo bar__</p>
62+
63+
<p>a__"foo"__</p>
64+
65+
<p>foo<strong>bar</strong></p>
66+
67+
<p>5<strong>6</strong>78</p>
68+
69+
<p>пристаням<strong>стремятся</strong></p>
70+
71+
<p><strong>foo, <strong>bar</strong>, baz</strong></p>
72+
73+
<p>foo-<strong>(bar)</strong></p>
74+
75+
<p>**foo bar **</p>
76+
77+
<p>**(**foo)</p>
78+
79+
<p><em>(<strong>foo</strong>)</em></p>
80+
81+
<p><strong>Gomphocarpus (<em>Gomphocarpus physocarpus</em>, syn.
82+
<em>Asclepias physocarpa</em>)</strong></p>
83+
84+
<p><strong>foo "<em>bar</em>" foo</strong></p>
85+
86+
<p><strong>foo</strong>bar</p>
87+
88+
<p>__foo bar __</p>
89+
90+
<p>__(__foo)</p>
91+
92+
<p><em>(<strong>foo</strong>)</em></p>
93+
94+
<p><strong>foo</strong>bar</p>
95+
96+
<p><strong>пристаням</strong>стремятся</p>
97+
98+
<p><strong>foo</strong>bar<strong>baz</strong></p>
99+
100+
<p><strong>(bar)</strong>.</p>
101+
102+
<p><em>foo <a href="/url">bar</a></em></p>
103+
104+
<p><em>foo
105+
bar</em></p>
106+
107+
<p><em>foo <strong>bar</strong> baz</em></p>
108+
109+
<p><em>foo <em>bar</em> baz</em></p>
110+
111+
<p><em><em>foo</em> bar</em></p>
112+
113+
<p><em>foo <em>bar</em></em></p>
114+
115+
<p><em>foo <strong>bar</strong> baz</em></p>
116+
117+
<p><em>foo<strong>bar</strong>baz</em></p>
118+
119+
<p><em>foo</em><em>bar</em></p>
120+
121+
<p><em><strong>foo</strong> bar</em></p>
122+
123+
<p><em>foo <strong>bar</strong></em></p>
124+
125+
<p><em>foo<strong>bar</strong></em></p>
126+
127+
<p>foo<em><strong>bar</strong></em>baz</p>
128+
129+
<p>foo<strong><strong><strong>bar</strong></strong></strong>***baz</p>
130+
131+
<p><em>foo <strong>bar <em>baz</em> bim</strong> bop</em></p>
132+
133+
<p><em>foo <a href="/url"><em>bar</em></a></em></p>
134+
135+
<p>** is not an empty emphasis</p>
136+
137+
<p>**** is not an empty strong emphasis</p>
138+
139+
<p><strong>foo <a href="/url">bar</a></strong></p>
140+
141+
<p><strong>foo
142+
bar</strong></p>
143+
144+
<p><strong>foo <em>bar</em> baz</strong></p>
145+
146+
<p><strong>foo <strong>bar</strong> baz</strong></p>
147+
148+
<p><strong><strong>foo</strong> bar</strong></p>
149+
150+
<p><strong>foo <strong>bar</strong></strong></p>
151+
152+
<p><strong>foo <em>bar</em> baz</strong></p>
153+
154+
<p><strong>foo<em>bar</em>baz</strong></p>
155+
156+
<p><strong><em>foo</em> bar</strong></p>
157+
158+
<p><strong>foo <em>bar</em></strong></p>
159+
160+
<p><strong>foo <em>bar <strong>baz</strong>
161+
bim</em> bop</strong></p>
162+
163+
<p><strong>foo <a href="/url"><em>bar</em></a></strong></p>
164+
165+
<p>__ is not an empty emphasis</p>
166+
167+
<p>____ is not an empty strong emphasis</p>
168+
169+
<p>foo ***</p>
170+
171+
<p>foo <em>*</em></p>
172+
173+
<p>foo <em>_</em></p>
174+
175+
<p>foo *****</p>
176+
177+
<p>foo <strong>*</strong></p>
178+
179+
<p>foo <strong>_</strong></p>
180+
181+
<p>*<em>foo</em></p>
182+
183+
<p><em>foo</em>*</p>
184+
185+
<p>*<strong>foo</strong></p>
186+
187+
<p>***<em>foo</em></p>
188+
189+
<p><strong>foo</strong>*</p>
190+
191+
<p><em>foo</em>***</p>
192+
193+
<p>foo ___</p>
194+
195+
<p>foo <em>_</em></p>
196+
197+
<p>foo <em>*</em></p>
198+
199+
<p>foo _____</p>
200+
201+
<p>foo <strong>_</strong></p>
202+
203+
<p>foo <strong>*</strong></p>
204+
205+
<p>_<em>foo</em></p>
206+
207+
<p><em>foo</em>_</p>
208+
209+
<p>_<strong>foo</strong></p>
210+
211+
<p>___<em>foo</em></p>
212+
213+
<p><strong>foo</strong>_</p>
214+
215+
<p><em>foo</em>___</p>
216+
217+
<p><strong>foo</strong></p>
218+
219+
<p><em><em>foo</em></em></p>
220+
221+
<p><strong>foo</strong></p>
222+
223+
<p><em><em>foo</em></em></p>
224+
225+
<p><strong><strong>foo</strong></strong></p>
226+
227+
<p><strong><strong>foo</strong></strong></p>
228+
229+
<p><strong><strong><strong>foo</strong></strong></strong></p>
230+
231+
<p><em><strong>foo</strong></em></p>
232+
233+
<p><em><strong><strong>foo</strong></strong></em></p>
234+
235+
<p><em>foo _bar</em> baz_</p>
236+
237+
<p><em>foo <strong>bar *baz bim</strong> bam</em></p>
238+
239+
<p>**foo <strong>bar baz</strong></p>
240+
241+
<p>*foo <em>bar baz</em></p>
242+
243+
<p>*<a href="/url">bar*</a></p>
244+
245+
<p>_foo <a href="/url">bar_</a></p>
246+
247+
<p>*<img src="foo" title="*"/></p>
248+
249+
<p>**<a href="**"></p>
250+
251+
<p>__<a href="__"></p>
252+
253+
<p><em>a <code>*</code></em></p>
254+
255+
<p><em>a <code>_</code></em></p>
256+
257+
<p>**a<a href="http://foo.bar/?q=**">http://foo.bar/?q=**</a></p>
258+
259+
<p>__a<a href="http://foo.bar/?q=__">http://foo.bar/?q=__</a></p>
260+
261+
<p><strong>foo*bar</strong></p>
262+
263+
<p>_foo <strong>bar</strong> baz._bim</p>
264+
265+
<p><strong>__foo</strong> bar <strong>__baz</strong> bim <em>bam</em></p>
266+
267+
<p><strong>foo<em>bar</em></strong></p>
268+
269+
<p><strong><em>foo</em>bar</strong></p>

0 commit comments

Comments
 (0)