From 49fa23af8141f7c5665e2e8633ad425cd823dfec Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Tue, 30 Dec 2014 13:58:58 -0500 Subject: Preserve order of nested headers in TOC Fixes #380. The TOC replacement is now seperate from building the TOC, which allows us to iter through the doc in order rather than with the non-order-preserving interparent pethod. This is almost a complete refactor of the run method. Also cleaned up the config stuff. Thanks to @colewerner for the report and test case. --- tests/extensions/test.cfg | 4 ++++ tests/extensions/toc_nested_list.html | 30 ++++++++++++++++++++++++++++++ tests/extensions/toc_nested_list.txt | 19 +++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 tests/extensions/toc_nested_list.html create mode 100644 tests/extensions/toc_nested_list.txt (limited to 'tests') diff --git a/tests/extensions/test.cfg b/tests/extensions/test.cfg index 5605d3f..7e27b29 100644 --- a/tests/extensions/test.cfg +++ b/tests/extensions/test.cfg @@ -36,6 +36,10 @@ toc_nested2: markdown.extensions.toc: permalink: "[link]" +toc_nested_list: + extensions: + - markdown.extensions.toc + wikilinks: extensions: - markdown.extensions.wikilinks diff --git a/tests/extensions/toc_nested_list.html b/tests/extensions/toc_nested_list.html new file mode 100644 index 0000000..6912411 --- /dev/null +++ b/tests/extensions/toc_nested_list.html @@ -0,0 +1,30 @@ +

Title

+
+ +
+

Section 1

+
    +
  1. +

    List Item 1

    +

    Subsection 1

    +

    Explanation 1

    +
  2. +
  3. +

    List Item 2

    +

    Subsection 2

    +

    Explanation 2

    +
  4. +
+

Section 2

+

Section 3

\ No newline at end of file diff --git a/tests/extensions/toc_nested_list.txt b/tests/extensions/toc_nested_list.txt new file mode 100644 index 0000000..d83e96f --- /dev/null +++ b/tests/extensions/toc_nested_list.txt @@ -0,0 +1,19 @@ +# Title + +[TOC] + +## Section 1 + +1. List Item 1 + + ### Subsection 1 + Explanation 1 + +2. List Item 2 + + ### Subsection 2 + Explanation 2 + +## Section 2 + +## Section 3 \ No newline at end of file -- cgit v1.2.3