diff --git a/lib/markdown2.py b/lib/markdown2.py index 0cc651ee..a73a4373 100755 --- a/lib/markdown2.py +++ b/lib/markdown2.py @@ -1153,6 +1153,9 @@ def _run_span_gamut(self, text): if "strike" in self.extras: text = self._do_strike(text) + if "underline" in self.extras: + text = self._do_underline(text) + text = self._do_italics_and_bold(text) if "smarty-pants" in self.extras: @@ -1954,6 +1957,11 @@ def _do_strike(self, text): text = self._strike_re.sub(r"\1", text) return text + _ins_re = re.compile(r"--(?=\S)(.+?)(?<=\S)--", re.S) + def _do_underline(self, text): + text = self._ins_re.sub(r"\1", text) + return text + _strong_re = re.compile(r"(\*\*|__)(?=\S)(.+?[*_]*)(?<=\S)\1", re.S) _em_re = re.compile(r"(\*|_)(?=\S)(.+?)(?<=\S)\1", re.S) _code_friendly_strong_re = re.compile(r"\*\*(?=\S)(.+?[*_]*)(?<=\S)\*\*", re.S) diff --git a/test/tm-cases/ins.html b/test/tm-cases/ins.html new file mode 100644 index 00000000..ff8f7a47 --- /dev/null +++ b/test/tm-cases/ins.html @@ -0,0 +1 @@ +

This is some underline text.

diff --git a/test/tm-cases/ins.opts b/test/tm-cases/ins.opts new file mode 100644 index 00000000..5722f05c --- /dev/null +++ b/test/tm-cases/ins.opts @@ -0,0 +1 @@ +{"extras": ["underline"]} diff --git a/test/tm-cases/ins.tags b/test/tm-cases/ins.tags new file mode 100644 index 00000000..c166945c --- /dev/null +++ b/test/tm-cases/ins.tags @@ -0,0 +1 @@ +extras underline diff --git a/test/tm-cases/ins.text b/test/tm-cases/ins.text new file mode 100644 index 00000000..8ee0c9f5 --- /dev/null +++ b/test/tm-cases/ins.text @@ -0,0 +1 @@ +This is some --underline-- text.