File tree Expand file tree Collapse file tree 2 files changed +25
-3
lines changed
Expand file tree Collapse file tree 2 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -431,7 +431,14 @@ bool Converter::ParseCharInTag(char ch) {
431431 current_tag_.pop_back ();
432432 }
433433 skipping_leading_whitespace = true ; // Reset for next tag
434- return OnHasLeftTag ();
434+ if (!is_self_closing_tag_)
435+ return OnHasLeftTag ();
436+ else {
437+ OnHasLeftTag ();
438+ is_self_closing_tag_ = false ;
439+ is_closing_tag_ = true ;
440+ return OnHasLeftTag ();
441+ }
435442 }
436443
437444 if (ch == ' "' ) {
@@ -484,7 +491,7 @@ bool Converter::OnHasLeftTag() {
484491 if (!is_closing_tag_) {
485492 tag->OnHasLeftOpeningTag (this );
486493 }
487- if (is_closing_tag_ || is_self_closing_tag_) {
494+ else {
488495 is_closing_tag_ = false ;
489496
490497 tag->OnHasLeftClosingTag (this );
Original file line number Diff line number Diff line change @@ -352,6 +352,20 @@ bool testWhitespaceTags() {
352352 return true ;
353353}
354354
355+ // Test self closing tags <a href=\"http://example1.com/\">First</a> <br/> then <a href=\"http://example2.com\">second</a>
356+ bool testSelfClosingTags () {
357+ testOption (" selfClosingTags" );
358+
359+ string html = " <a href=\" http://example1.com/\" >First</a> <br/> then <a href=\" http://example2.com\" >second</a>" ;
360+
361+ html2md::Converter c (html);
362+ auto md = c.convert ();
363+
364+ return md.find (" [First](http://example1.com/)" ) != string::npos &&
365+ md.find (" [second](http://example2.com)" ) != string::npos &&
366+ md.find (" \n " ) != string::npos;
367+ }
368+
355369int main (int argc, const char **argv) {
356370 // List to store all markdown files in this dir
357371 vector<string> files;
@@ -409,7 +423,8 @@ int main(int argc, const char **argv) {
409423 &testUppercaseAttributes,
410424 &testMixedCaseTags,
411425 &testSelfClosingUppercaseTags,
412- &testWhitespaceTags
426+ &testWhitespaceTags,
427+ &testSelfClosingTags,
413428 };
414429
415430 for (const auto &test : tests)
You can’t perform that action at this time.
0 commit comments