From 3a9971c77aee44d66a2f04c25d2a4542e7f12873 Mon Sep 17 00:00:00 2001 From: Nemo Date: Sat, 29 May 2021 02:18:43 +0530 Subject: [PATCH] Fixes the case of heading less markdown --- src/pystitcher/stitcher.py | 2 +- tests/.gitignore | 1 + tests/3.md | 5 +++++ tests/book-clean.md | 9 +++++---- tests/book-flatten.md | 8 ++++---- tests/book-keep.md | 10 ++-------- tests/min.md | 2 ++ tests/title.md | 6 ++++++ 8 files changed, 26 insertions(+), 17 deletions(-) create mode 100644 tests/.gitignore create mode 100644 tests/3.md create mode 100644 tests/min.md create mode 100644 tests/title.md diff --git a/src/pystitcher/stitcher.py b/src/pystitcher/stitcher.py index 145caa5..0eb3c6d 100644 --- a/src/pystitcher/stitcher.py +++ b/src/pystitcher/stitcher.py @@ -17,7 +17,7 @@ class Stitcher: self.currentPage = 1 self.title = None self.bookmarks = [] - self.currentLevel = None + self.currentLevel = 0 self.oldBookmarks = [] self.dir = os.path.dirname(os.path.abspath(inputBuffer.name)) # Fit complete page width by default diff --git a/tests/.gitignore b/tests/.gitignore new file mode 100644 index 0000000..a136337 --- /dev/null +++ b/tests/.gitignore @@ -0,0 +1 @@ +*.pdf diff --git a/tests/3.md b/tests/3.md new file mode 100644 index 0000000..617e3da --- /dev/null +++ b/tests/3.md @@ -0,0 +1,5 @@ + + +# Cast of Characters + +- Nemo, Master of Ceremonies diff --git a/tests/book-clean.md b/tests/book-clean.md index a72c2b6..95ac78b 100644 --- a/tests/book-clean.md +++ b/tests/book-clean.md @@ -1,12 +1,13 @@ existing_bookmarks: remove +author: Wiki, the Cat +subject: A book about adventures of Wiki, the cat. +keywords: wiki,potato,jelly # Super Potato Book # Volume 1 -[Part 1](2page.pdf) -[Part 2](2page.pdf) +[Part 1](1.pdf) # Volume 2 -[Part 3](2page.pdf) -[Part 4](2page.pdf) +[Part 2](2.pdf) diff --git a/tests/book-flatten.md b/tests/book-flatten.md index 27ffcbd..239cb4b 100644 --- a/tests/book-flatten.md +++ b/tests/book-flatten.md @@ -1,12 +1,12 @@ existing_bookmarks: flatten +title: Super Jelly Book + # Super Potato Book # Volume 1 -[Part 1](2page.pdf) -[Part 2](2page.pdf) +[Part 1](1.pdf) # Volume 2 -[Part 3](2page.pdf) -[Part 4](2page.pdf) +[Part 3](2.pdf) diff --git a/tests/book-keep.md b/tests/book-keep.md index 4176aab..ef07c1f 100644 --- a/tests/book-keep.md +++ b/tests/book-keep.md @@ -1,16 +1,10 @@ existing_bookmarks: keep -title: Super Jelly Book -author: Wiki, the Cat -subject: A book about adventures of Wiki, the cat. -keywords: wiki,potato,jelly # Super Potato Book # Volume 1 -[Part 1](2page.pdf) -[Part 2](2page.pdf) +[Part 1](1.pdf) # Volume 2 -[Part 3](2page.pdf) -[Part 4](2page.pdf) +[Part 3](2.pdf) diff --git a/tests/min.md b/tests/min.md new file mode 100644 index 0000000..bf3d9d2 --- /dev/null +++ b/tests/min.md @@ -0,0 +1,2 @@ +existing_bookmarks: keep +[Part 1](1.pdf) diff --git a/tests/title.md b/tests/title.md new file mode 100644 index 0000000..0e729be --- /dev/null +++ b/tests/title.md @@ -0,0 +1,6 @@ +--- +titlepage: true +--- +# Super Potato Book + +In memory of Starch