@@ -112,36 +112,38 @@ def test_em():
112112
113113
114114def  test_header_with_space ():
115-     assert  md ('<h3>\n \n Hello</h3>' ) ==  '### Hello\n \n ' 
116-     assert  md ('<h4>\n \n Hello</h4>' ) ==  '#### Hello\n \n ' 
117-     assert  md ('<h5>\n \n Hello</h5>' ) ==  '##### Hello\n \n ' 
118-     assert  md ('<h5>\n \n Hello\n \n </h5>' ) ==  '##### Hello\n \n ' 
119-     assert  md ('<h5>\n \n Hello   \n \n </h5>' ) ==  '##### Hello\n \n ' 
115+     assert  md ('<h3>\n \n Hello</h3>' ) ==  '\n ### Hello\n \n ' 
116+     assert  md ('<h4>\n \n Hello</h4>' ) ==  '\n #### Hello\n \n ' 
117+     assert  md ('<h5>\n \n Hello</h5>' ) ==  '\n ##### Hello\n \n ' 
118+     assert  md ('<h5>\n \n Hello\n \n </h5>' ) ==  '\n ##### Hello\n \n ' 
119+     assert  md ('<h5>\n \n Hello   \n \n </h5>' ) ==  '\n ##### Hello\n \n ' 
120120
121121
122122def  test_h1 ():
123-     assert  md ('<h1>Hello</h1>' ) ==  'Hello \n =====\n \n ' 
123+     assert  md ('<h1>Hello</h1>' ) ==  '\n \n Hello \n =====\n \n ' 
124124
125125
126126def  test_h2 ():
127-     assert  md ('<h2>Hello</h2>' ) ==  'Hello \n -----\n \n ' 
127+     assert  md ('<h2>Hello</h2>' ) ==  '\n \n Hello \n -----\n \n ' 
128128
129129
130130def  test_hn ():
131-     assert  md ('<h3>Hello</h3>' ) ==  '### Hello\n \n ' 
132-     assert  md ('<h4>Hello</h4>' ) ==  '#### Hello\n \n ' 
133-     assert  md ('<h5>Hello</h5>' ) ==  '##### Hello\n \n ' 
134-     assert  md ('<h6>Hello</h6>' ) ==  '###### Hello\n \n ' 
131+     assert  md ('<h3>Hello</h3>' ) ==  '\n ### Hello\n \n ' 
132+     assert  md ('<h4>Hello</h4>' ) ==  '\n #### Hello\n \n ' 
133+     assert  md ('<h5>Hello</h5>' ) ==  '\n ##### Hello\n \n ' 
134+     assert  md ('<h6>Hello</h6>' ) ==  '\n ###### Hello\n \n ' 
135135
136136
137137def  test_hn_chained ():
138-     assert  md ('<h1>First</h1>\n <h2>Second</h2>\n <h3>Third</h3>' , heading_style = ATX ) ==  '# First\n \n \n ## Second\n \n \n ### Third\n \n ' 
139-     assert  md ('X<h1>First</h1>' , heading_style = ATX ) ==  'X# First\n \n ' 
138+     assert  md ('<h1>First</h1>\n <h2>Second</h2>\n <h3>Third</h3>' , heading_style = ATX ) ==  '\n # First\n \n \n ## Second\n \n \n ### Third\n \n ' 
139+     assert  md ('X<h1>First</h1>' , heading_style = ATX ) ==  'X\n # First\n \n ' 
140+     assert  md ('X<h1>First</h1>' , heading_style = ATX_CLOSED ) ==  'X\n # First #\n \n ' 
141+     assert  md ('X<h1>First</h1>' ) ==  'X\n \n First\n =====\n \n ' 
140142
141143
142144def  test_hn_nested_tag_heading_style ():
143-     assert  md ('<h1>A <p>P</p> C </h1>' , heading_style = ATX_CLOSED ) ==  '# A P C #\n \n ' 
144-     assert  md ('<h1>A <p>P</p> C </h1>' , heading_style = ATX ) ==  '# A P C\n \n ' 
145+     assert  md ('<h1>A <p>P</p> C </h1>' , heading_style = ATX_CLOSED ) ==  '\n # A P C #\n \n ' 
146+     assert  md ('<h1>A <p>P</p> C </h1>' , heading_style = ATX ) ==  '\n # A P C\n \n ' 
145147
146148
147149def  test_hn_nested_simple_tag ():
@@ -157,12 +159,12 @@ def test_hn_nested_simple_tag():
157159    ]
158160
159161    for  tag , markdown  in  tag_to_markdown :
160-         assert  md ('<h3>A <'  +  tag  +  '>'  +  tag  +  '</'  +  tag  +  '> B</h3>' ) ==  '### A '  +  markdown  +  ' B\n \n ' 
162+         assert  md ('<h3>A <'  +  tag  +  '>'  +  tag  +  '</'  +  tag  +  '> B</h3>' ) ==  '\n ### A '  +  markdown  +  ' B\n \n ' 
161163
162-     assert  md ('<h3>A <br>B</h3>' , heading_style = ATX ) ==  '### A B\n \n ' 
164+     assert  md ('<h3>A <br>B</h3>' , heading_style = ATX ) ==  '\n ### A B\n \n ' 
163165
164166    # Nested lists not supported 
165-     # assert md('<h3>A <ul><li>li1</i><li>l2</li></ul></h3>', heading_style=ATX) == '### A li1 li2 B\n\n' 
167+     # assert md('<h3>A <ul><li>li1</i><li>l2</li></ul></h3>', heading_style=ATX) == '\n ### A li1 li2 B\n\n' 
166168
167169
168170def  test_hn_nested_img ():
@@ -172,18 +174,18 @@ def test_hn_nested_img():
172174        ("alt='Alt Text' title='Optional title'" , "Alt Text" , " \" Optional title\" " ),
173175    ]
174176    for  image_attributes , markdown , title  in  image_attributes_to_markdown :
175-         assert  md ('<h3>A <img src="/path/to/img.jpg" '  +  image_attributes  +  '/> B</h3>' ) ==  '### A '  +  markdown  +  ' B\n \n ' 
176-         assert  md ('<h3>A <img src="/path/to/img.jpg" '  +  image_attributes  +  '/> B</h3>' , keep_inline_images_in = ['h3' ]) ==  '### A  B\n \n ' 
177+         assert  md ('<h3>A <img src="/path/to/img.jpg" '  +  image_attributes  +  '/> B</h3>' ) ==  '\n ### A '  +  markdown  +  ' B\n \n ' 
178+         assert  md ('<h3>A <img src="/path/to/img.jpg" '  +  image_attributes  +  '/> B</h3>' , keep_inline_images_in = ['h3' ]) ==  '\n ### A  B\n \n ' 
177179
178180
179181def  test_hn_atx_headings ():
180-     assert  md ('<h1>Hello</h1>' , heading_style = ATX ) ==  '# Hello\n \n ' 
181-     assert  md ('<h2>Hello</h2>' , heading_style = ATX ) ==  '## Hello\n \n ' 
182+     assert  md ('<h1>Hello</h1>' , heading_style = ATX ) ==  '\n # Hello\n \n ' 
183+     assert  md ('<h2>Hello</h2>' , heading_style = ATX ) ==  '\n ## Hello\n \n ' 
182184
183185
184186def  test_hn_atx_closed_headings ():
185-     assert  md ('<h1>Hello</h1>' , heading_style = ATX_CLOSED ) ==  '# Hello #\n \n ' 
186-     assert  md ('<h2>Hello</h2>' , heading_style = ATX_CLOSED ) ==  '## Hello ##\n \n ' 
187+     assert  md ('<h1>Hello</h1>' , heading_style = ATX_CLOSED ) ==  '\n # Hello #\n \n ' 
188+     assert  md ('<h2>Hello</h2>' , heading_style = ATX_CLOSED ) ==  '\n ## Hello ##\n \n ' 
187189
188190
189191def  test_head ():
@@ -193,7 +195,7 @@ def test_head():
193195def  test_hr ():
194196    assert  md ('Hello<hr>World' ) ==  'Hello\n \n ---\n \n World' 
195197    assert  md ('Hello<hr />World' ) ==  'Hello\n \n ---\n \n World' 
196-     assert  md ('<p>Hello</p>\n <hr>\n <p>World</p>' ) ==  'Hello \n \n  \n \n \n ---\n \n \n World\n \n ' 
198+     assert  md ('<p>Hello</p>\n <hr>\n <p>World</p>' ) ==  '\n \n  Hello \n \n \n ---\n \n \n World\n \n ' 
197199
198200
199201def  test_i ():
@@ -210,12 +212,13 @@ def test_kbd():
210212
211213
212214def  test_p ():
213-     assert  md ('<p>hello</p>' ) ==  'hello\n \n ' 
214-     assert  md ('<p>123456789 123456789</p>' ) ==  '123456789 123456789\n \n ' 
215-     assert  md ('<p>123456789 123456789</p>' , wrap = True , wrap_width = 10 ) ==  '123456789\n 123456789\n \n ' 
216-     assert  md ('<p><a href="https://example.com">Some long link</a></p>' , wrap = True , wrap_width = 10 ) ==  '[Some long\n link](https://example.com)\n \n ' 
217-     assert  md ('<p>12345<br />67890</p>' , wrap = True , wrap_width = 10 , newline_style = BACKSLASH ) ==  '12345\\ \n 67890\n \n ' 
218-     assert  md ('<p>12345678901<br />12345</p>' , wrap = True , wrap_width = 10 , newline_style = BACKSLASH ) ==  '12345678901\\ \n 12345\n \n ' 
215+     assert  md ('<p>hello</p>' ) ==  '\n \n hello\n \n ' 
216+     assert  md ('<p>123456789 123456789</p>' ) ==  '\n \n 123456789 123456789\n \n ' 
217+     assert  md ('<p>123456789 123456789</p>' , wrap = True , wrap_width = 10 ) ==  '\n \n 123456789\n 123456789\n \n ' 
218+     assert  md ('<p><a href="https://example.com">Some long link</a></p>' , wrap = True , wrap_width = 10 ) ==  '\n \n [Some long\n link](https://example.com)\n \n ' 
219+     assert  md ('<p>12345<br />67890</p>' , wrap = True , wrap_width = 10 , newline_style = BACKSLASH ) ==  '\n \n 12345\\ \n 67890\n \n ' 
220+     assert  md ('<p>12345678901<br />12345</p>' , wrap = True , wrap_width = 10 , newline_style = BACKSLASH ) ==  '\n \n 12345678901\\ \n 12345\n \n ' 
221+     assert  md ('First<p>Second</p><p>Third</p>Fourth' ) ==  'First\n \n Second\n \n Third\n \n Fourth' 
219222
220223
221224def  test_pre ():
0 commit comments