diff --git a/.travis.yml b/.travis.yml index 93208f8f..9367b46b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,6 @@ language: python python: - "2.7" - "pypy" - - "3.4" - "3.5" - "3.6" - "3.7-dev" diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index bd8deb15..d12afcd2 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -42,4 +42,4 @@ Sym Roe (github.com/symroe) Alex Elzenaar (github.com/aelzenaar) Francisco Saldaña (github.com/FrankSalad) Shivam Kumar Jha (github.com/thealphadollar) -ryanvilbrandt (github.com/ryanvilbrandt) +Ryan Vilbrandt (github.com/ryanvilbrandt) diff --git a/lib/markdown2.py b/lib/markdown2.py index 3a5d5d9b..4c0654c0 100755 --- a/lib/markdown2.py +++ b/lib/markdown2.py @@ -1682,15 +1682,14 @@ def _do_lists(self, text): (.*) # list item text = \2 ''', re.M | re.X | re.S) - _task_list_warpper_str = r' %s' + _task_list_warpper_str = r' %s' def _task_list_item_sub(self, match): marker = match.group(1) item_text = match.group(2) - if marker in ['[x]','[X]']: - return self._task_list_warpper_str % ('checked ', item_text) - elif marker == '[ ]': - return self._task_list_warpper_str % ('', item_text) + checked_str = "" if marker == '[ ]' else "checked " + disabled_str = "" if "task_list_checkable" in self.extras else "disabled" + return self._task_list_warpper_str % (checked_str, disabled_str, item_text) _last_li_endswith_two_eols = False def _list_item_sub(self, match): @@ -2293,17 +2292,19 @@ def calculate_toc_html(toc): This expects the `_toc` attribute to have been set on this instance. """ - if toc is None: + if not toc: return None def indent(): return ' ' * (len(h_stack) - 1) lines = [] h_stack = [0] # stack of header-level numbers + # Build TOC for level, id, name in toc: if level > h_stack[-1]: - lines.append("%s
if True:
- print "hi"
+if True:
+ print "hi"
diff --git a/test/tm-cases/fenced_code_blocks_safe_highlight.html b/test/tm-cases/fenced_code_blocks_safe_highlight.html
index df5bbec5..a08985a7 100644
--- a/test/tm-cases/fenced_code_blocks_safe_highlight.html
+++ b/test/tm-cases/fenced_code_blocks_safe_highlight.html
@@ -1,5 +1,5 @@
-if True:
- print "hi"
+if True:
+ print "hi"
That's using the fenced-code-blocks extra with Python
diff --git a/test/tm-cases/fenced_code_blocks_syntax_highlighting.html b/test/tm-cases/fenced_code_blocks_syntax_highlighting.html
index df5bbec5..a08985a7 100644
--- a/test/tm-cases/fenced_code_blocks_syntax_highlighting.html
+++ b/test/tm-cases/fenced_code_blocks_syntax_highlighting.html
@@ -1,5 +1,5 @@
-
if True:
- print "hi"
+if True:
+ print "hi"
That's using the fenced-code-blocks extra with Python
diff --git a/test/tm-cases/fenced_code_blocks_syntax_indentation.html b/test/tm-cases/fenced_code_blocks_syntax_indentation.html
index 11a7c241..37b5723e 100644
--- a/test/tm-cases/fenced_code_blocks_syntax_indentation.html
+++ b/test/tm-cases/fenced_code_blocks_syntax_indentation.html
@@ -1,5 +1,5 @@
def foo():
- print "foo"
+ print "foo"
- print "bar"
+ print "bar"
diff --git a/test/tm-cases/issue3_bad_code_color_hack.html b/test/tm-cases/issue3_bad_code_color_hack.html
index 46f329aa..8aedb76c 100644
--- a/test/tm-cases/issue3_bad_code_color_hack.html
+++ b/test/tm-cases/issue3_bad_code_color_hack.html
@@ -7,6 +7,6 @@ заголовок
Some python code:
# комментарий
-if True:
- print "hi"
+if True:
+ print "hi"
diff --git a/test/tm-cases/toc_2.toc_html b/test/tm-cases/toc_2.toc_html
index 08288703..dceb843b 100644
--- a/test/tm-cases/toc_2.toc_html
+++ b/test/tm-cases/toc_2.toc_html
@@ -6,8 +6,10 @@
- Chicken
- Pork
diff --git a/test/tm-cases/toc_3.toc_html b/test/tm-cases/toc_3.toc_html
index 08288703..dceb843b 100644
--- a/test/tm-cases/toc_3.toc_html
+++ b/test/tm-cases/toc_3.toc_html
@@ -6,8 +6,10 @@
- Chicken
- Pork
diff --git a/test/tm-cases/toc_6.html b/test/tm-cases/toc_6.html
new file mode 100644
index 00000000..251ec1ae
--- /dev/null
+++ b/test/tm-cases/toc_6.html
@@ -0,0 +1,35 @@
+
Testing toc starting with a deeper header than h1
+
+Fruit
+
+
+- apples
+
+
+Veggies
+
+
+- carrots
+
+
+Testing a jump in toc over more than two "layers"
+
+Meat
+
+
+- beef
+
+
+Dairy
+
+
+- milk
+
+
+Testing proper closing tags at end of toc
+
+Sugar
+
+
+- candy
+
diff --git a/test/tm-cases/toc_6.opts b/test/tm-cases/toc_6.opts
new file mode 100644
index 00000000..ac671854
--- /dev/null
+++ b/test/tm-cases/toc_6.opts
@@ -0,0 +1 @@
+{"extras": ["toc"]}
diff --git a/test/tm-cases/toc_6.tags b/test/tm-cases/toc_6.tags
new file mode 100644
index 00000000..2b2472e0
--- /dev/null
+++ b/test/tm-cases/toc_6.tags
@@ -0,0 +1 @@
+toc extra
diff --git a/test/tm-cases/toc_6.text b/test/tm-cases/toc_6.text
new file mode 100644
index 00000000..610fecdd
--- /dev/null
+++ b/test/tm-cases/toc_6.text
@@ -0,0 +1,25 @@
+Testing toc starting with a deeper header than h1
+
+### Fruit
+
+- apples
+
+## Veggies
+
+- carrots
+
+Testing a jump in toc over more than two "layers"
+
+##### Meat
+
+- beef
+
+# Dairy
+
+- milk
+
+Testing proper closing tags at end of toc
+
+### Sugar
+
+- candy
diff --git a/test/tm-cases/toc_6.toc_html b/test/tm-cases/toc_6.toc_html
new file mode 100644
index 00000000..52712a09
--- /dev/null
+++ b/test/tm-cases/toc_6.toc_html
@@ -0,0 +1,21 @@
+
+
+
+ - Fruit
+
+ - Veggies
+
+
+
+ - Meat
+
+
+
+
+ - Dairy
+
+
+ - Sugar
+
+
+