Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add underline 'u' support in extras #360

Merged
merged 3 commits into from Jun 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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.