bug fix for link_path and escaping
3 files changed, 19 insertions(+), 14 deletions(-)

M quiescent/feed.py
M quiescent/post.py
M quiescent/static.py
M quiescent/feed.py +2 -2
@@ 49,9 49,9 @@ def _feed_entry(parent_element, post, do
     title = ET.SubElement(entry, 'title')
     title.text = post.title
     link = ET.SubElement(entry, 'link')
-    link.attrib['href'] = urljoin(domain, post.path)
+    link.attrib['href'] = urljoin(domain, post.link_path)
     entry_id = ET.SubElement(entry, 'id')
-    entry_id.text = urljoin(domain, post.path)
+    entry_id.text = urljoin(domain, post.link_path)
     updated = ET.SubElement(entry, 'updated')
     updated.text = post.date_time.isoformat()
     content = ET.SubElement(entry, 'content')

          
M quiescent/post.py +15 -10
@@ 69,7 69,8 @@ class RenderedPost:
     date_string: str
     html_leader: str
     html_body: str
-    path: str
+    link_path: str
+    file_path: str
 
 def parse(raw_text: str) -> RenderedPost:
     p = PostParser()

          
@@ 78,15 79,17 @@ def parse(raw_text: str) -> RenderedPost
     # UTC is used here so that a valid date format is included in the
     # atom feed, not great
     date = datetime.strptime(post_date, '%Y-%m-%d').replace(tzinfo=timezone.utc)
-    path = os.path.join(date.strftime("%Y"), f'{slugify(post_title)}.html')
+    file_path = os.path.join(date.strftime("%Y"), f'{slugify(post_title, escape=False)}.html')
+    link_path = os.path.join(date.strftime("%Y"), f'{slugify(post_title)}.html')
     return RenderedPost(post_title,
                         date,
                         post_date,
                         post_leader,
                         post_body,
-                        path)
+                        link_path,
+                        file_path)
 
-def slugify(text):
+def slugify(text, escape=True):
     '''
     Build hyphenated post slugs from raw text. RFC3986 requires percent
     encoding for UCS/unicode points.

          
@@ 103,9 106,11 @@ def slugify(text):
     collapse_hyphens = partial(re.sub, r'-+', '-')
     remove_trailing_hyphens = lambda s: s.strip('-')
     percent_encode = partial(urllib.parse.quote, safe='-')
-    return percent_encode(
-        remove_trailing_hyphens(
-            collapse_hyphens(
-                replace_nonword(
-                    remove_quotes(
-                        text.lower())))))
+    safer_string = remove_trailing_hyphens(
+        collapse_hyphens(
+            replace_nonword(
+                remove_quotes(
+                    text.lower()))))
+    if escape:
+        return percent_encode(safer_string)
+    return safer_string

          
M quiescent/static.py +2 -2
@@ 131,10 131,10 @@ class StaticGenerator:
         def write_post(post):
             try:
                 post_page = self.post_template.render({'post': post})
-                output_tree = os.path.dirname(os.path.join(self.config.output_dir, post.path))
+                output_tree = os.path.dirname(os.path.join(self.config.output_dir, post.file_path))
                 # reconstitute the input tree in the output directory
                 os.makedirs(output_tree, exist_ok=True)
-                output_path = os.path.join(self.config.output_dir, post.path)
+                output_path = os.path.join(self.config.output_dir, post.file_path)
                 with open(output_path, 'w', encoding='utf-8') as f:
                     f.write(post_page)
             except Exception as e: