From 0f1a5a288739ed2efce6b180b9aaaf241097ac1f Mon Sep 17 00:00:00 2001 From: CrispyPin Date: Fri, 25 Jun 2021 01:44:56 +0200 Subject: [PATCH] switch to a more HTML-friendly style of includes, fix include markers ending in more than 1 character --- html-combiner.py | 10 +++++----- pages/fractals/index.html | 4 ++-- pages/index.html | 4 ++-- templates/header.html | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/html-combiner.py b/html-combiner.py index 8b2f932..ce5c5b6 100755 --- a/html-combiner.py +++ b/html-combiner.py @@ -5,8 +5,8 @@ PAGE_DIR = "./pages/" TEMPLATE_DIR = "./templates/" TARGET_DIR = "./docs/" -INCLUDE_MARKER = "&include(" -INCLUDE_MARKER_END = ")" +INCLUDE_MARKER = " None: items = os.listdir(PAGE_DIR + path) @@ -45,14 +45,14 @@ def apply_include(contents: str) -> str: def insert_contents(contents, new_contents): index_start, index_end = get_marker_indices(contents) - return contents[:index_start] + new_contents + contents[index_end+1:] + return contents[:index_start] + new_contents + contents[index_end + len(INCLUDE_MARKER_END):] def get_included_name(contents): marker_start, marker_end = get_marker_indices(contents) name_start = marker_start + len(INCLUDE_MARKER) - name_end = marker_end - len(INCLUDE_MARKER_END) - return contents[name_start:name_end + 1] + name_end = marker_end + return contents[name_start:name_end] def get_marker_indices(contents: str) -> tuple: diff --git a/pages/fractals/index.html b/pages/fractals/index.html index 4efee5a..35f20fa 100644 --- a/pages/fractals/index.html +++ b/pages/fractals/index.html @@ -8,8 +8,8 @@ Document - &include(header.html) +

fractals go here woo

- &include(footer.html) + \ No newline at end of file diff --git a/pages/index.html b/pages/index.html index f84c03a..32fb439 100644 --- a/pages/index.html +++ b/pages/index.html @@ -8,9 +8,9 @@ CrispyPin.cc - &include(header.html) +

Homepage

Lorem, ipsum dolor sit amet consectetur adipisicing elit. Earum exercitationem quod laudantium neque. Dolor qui magnam debitis repellendus assumenda tenetur ab aliquam ea sit in harum facere neque ad nemo vel nesciunt distinctio totam, cupiditate, deleniti nam voluptas quia aperiam.

- &include(footer.html) + \ No newline at end of file diff --git a/templates/header.html b/templates/header.html index 8e9289d..ddf3c91 100644 --- a/templates/header.html +++ b/templates/header.html @@ -1,4 +1,4 @@
-&include(navbar.html) \ No newline at end of file + \ No newline at end of file