Skip to content

Commit

Permalink
Merge pull request #360 from starry69/master
Browse files Browse the repository at this point in the history
Add underline 'u' support in extras
  • Loading branch information
nicholasserra committed Jun 26, 2020
2 parents 55359c5 + a67f47e commit 6af16f4
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/markdown2.py
Expand Up @@ -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:
Expand Down Expand Up @@ -1954,6 +1957,11 @@ def _do_strike(self, text):
text = self._strike_re.sub(r"<strike>\1</strike>", text)
return text

_ins_re = re.compile(r"--(?=\S)(.+?)(?<=\S)--", re.S)
def _do_underline(self, text):
text = self._ins_re.sub(r"<u>\1</u>", 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)
Expand Down
1 change: 1 addition & 0 deletions test/tm-cases/ins.html
@@ -0,0 +1 @@
<p>This is some <u>underline</u> text.</p>
1 change: 1 addition & 0 deletions test/tm-cases/ins.opts
@@ -0,0 +1 @@
{"extras": ["underline"]}
1 change: 1 addition & 0 deletions test/tm-cases/ins.tags
@@ -0,0 +1 @@
extras underline
1 change: 1 addition & 0 deletions test/tm-cases/ins.text
@@ -0,0 +1 @@
This is some --underline-- text.

0 comments on commit 6af16f4

Please sign in to comment.