Commits

Christian Jann  committed f8b2395

Issue #50 When clicking "read more" in a post on the home page,
the reader should not be directed to the top of the post.
Maybe insert a reference label and redirect to there instead?

  • Participants
  • Parent commits 8a40121

Comments (0)

Files changed (2)

File tinkerer/ext/patch.py

     """
     Create "read more" link if marker exists.
     """
-    marker_more = "<!-- more -->"
+    marker_more = '<a name="more"/>'
     pos = body.find(marker_more)
 
     if pos == -1:
         return body
 
     body = body[:pos]
-    return body + ('<a class="readmore" href="%s.html">%s</a></div>' %
+    return body + ('<a class="readmore" href="%s.html#more">%s</a></div>' %
                 (docpath + docname, UIStr.READ_MORE))
 
 
     # if node is hyperlink            
     elif node_name == "a":
         ref = node.getAttributeNode("href")
-        # patch links only - either starting with "../" or having
-        # "internal" class
-        is_relative = ref.value.startswith("../") 
-        if is_relative or "internal" in node.getAttribute("class"):
-            ref.value = docpath + ref.value
+        # skip anchor links <a name="anchor1"></a>, <a name="more"/>
+        if ref != None:
+            # patch links only - either starting with "../" or having
+            # "internal" class
+            is_relative = ref.value.startswith("../") 
+            if is_relative or "internal" in node.getAttribute("class"):
+                ref.value = docpath + ref.value
             
 
     # recurse            

File tinkerer/ext/readmore.py

 
 
     def run(self):
-        return [nodes.raw("", "<!-- more -->", format="html")] 
+        return [nodes.raw("", '<a name="more"/>', format="html")]