diff --git a/html2text.py b/html2text.py index b13615b5..e9bf9010 100755 --- a/html2text.py +++ b/html2text.py @@ -440,8 +440,21 @@ def handle_tag(self, tag, attrs, start): self.blockquote -= 1 self.p() - if tag in ['em', 'i', 'u'] and not self.ignore_emphasis: self.o(self.emphasis_mark) - if tag in ['strong', 'b'] and not self.ignore_emphasis: self.o(self.strong_mark) + if tag in ['em', 'i', 'u'] and not self.ignore_emphasis: + if not self.pre: + self.o(self.emphasis_mark) + elif start: + self.o("<"+tag+">") + else: + self.o(""+tag+">") + if tag in ['strong', 'b'] and not self.ignore_emphasis: + if not self.pre: + self.o(self.strong_mark) + elif start: + self.o("<"+tag+">") + else: + self.o(""+tag+">") + if tag in ['del', 'strike', 's']: if start: self.o("<"+tag+">") diff --git a/test/code_blocks.html b/test/code_blocks.html new file mode 100644 index 00000000..eac54efa --- /dev/null +++ b/test/code_blocks.html @@ -0,0 +1,9 @@ + +
++This is a bold statement. + +This is a foreign word. ++ + diff --git a/test/code_blocks.md b/test/code_blocks.md new file mode 100644 index 00000000..4bc252a6 --- /dev/null +++ b/test/code_blocks.md @@ -0,0 +1,6 @@ + + This is a bold statement. + + This is a foreign word. + +