FossilRepo

Improve Fossil wiki markup rendering: lists and text blocks - Convert Fossil wiki * list syntax to <ul><li> HTML - Wrap bare text blocks in <p> tags - Fixes pages like "New Build Documentation" that mix HTML tags with Fossil's native list syntax

lmata 2026-04-06 14:00 trunk
Commit c0276b7f148c74f18d258b1dc45d20f5b3209ab1aba82808c00d3fa8970e7ca9
1 file changed +26
--- fossil/views.py
+++ fossil/views.py
@@ -35,10 +35,36 @@
3535
3636
# Fossil wiki / HTML: convert Fossil-specific syntax to HTML
3737
content = re.sub(r"\[(/[^|\]]+)\|([^\]]+)\]", r'<a href="\1">\2</a>', content)
3838
content = re.sub(r"\[(https?://[^|\]]+)\|([^\]]+)\]", r'<a href="\1">\2</a>', content)
3939
content = re.sub(r"<verbatim>(.*?)</verbatim>", r"<pre><code>\1</code></pre>", content, flags=re.DOTALL)
40
+
41
+ # Convert Fossil wiki list syntax: lines starting with " * " to <ul><li>
42
+ lines = content.split("\n")
43
+ result = []
44
+ in_list = False
45
+ for line in lines:
46
+ stripped_line = line.strip()
47
+ if re.match(r"^\*\s", stripped_line) or re.match(r"^\d+\.\s", stripped_line):
48
+ if not in_list:
49
+ result.append("<ul>")
50
+ in_list = True
51
+ item_text = re.sub(r"^[\*\d+\.]\s*", "", stripped_line)
52
+ result.append(f"<li>{item_text}</li>")
53
+ else:
54
+ if in_list:
55
+ result.append("</ul>")
56
+ in_list = False
57
+ result.append(line)
58
+ if in_list:
59
+ result.append("</ul>")
60
+
61
+ content = "\n".join(result)
62
+
63
+ # Wrap bare text blocks in <p> tags (lines not inside HTML tags)
64
+ content = re.sub(r"\n\n(?!<)", "\n\n<p>", content)
65
+
4066
return content
4167
4268
4369
def _is_markdown(content: str) -> bool:
4470
"""Detect if content is Markdown vs Fossil wiki/HTML.
4571
--- fossil/views.py
+++ fossil/views.py
@@ -35,10 +35,36 @@
35
36 # Fossil wiki / HTML: convert Fossil-specific syntax to HTML
37 content = re.sub(r"\[(/[^|\]]+)\|([^\]]+)\]", r'<a href="\1">\2</a>', content)
38 content = re.sub(r"\[(https?://[^|\]]+)\|([^\]]+)\]", r'<a href="\1">\2</a>', content)
39 content = re.sub(r"<verbatim>(.*?)</verbatim>", r"<pre><code>\1</code></pre>", content, flags=re.DOTALL)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40 return content
41
42
43 def _is_markdown(content: str) -> bool:
44 """Detect if content is Markdown vs Fossil wiki/HTML.
45
--- fossil/views.py
+++ fossil/views.py
@@ -35,10 +35,36 @@
35
36 # Fossil wiki / HTML: convert Fossil-specific syntax to HTML
37 content = re.sub(r"\[(/[^|\]]+)\|([^\]]+)\]", r'<a href="\1">\2</a>', content)
38 content = re.sub(r"\[(https?://[^|\]]+)\|([^\]]+)\]", r'<a href="\1">\2</a>', content)
39 content = re.sub(r"<verbatim>(.*?)</verbatim>", r"<pre><code>\1</code></pre>", content, flags=re.DOTALL)
40
41 # Convert Fossil wiki list syntax: lines starting with " * " to <ul><li>
42 lines = content.split("\n")
43 result = []
44 in_list = False
45 for line in lines:
46 stripped_line = line.strip()
47 if re.match(r"^\*\s", stripped_line) or re.match(r"^\d+\.\s", stripped_line):
48 if not in_list:
49 result.append("<ul>")
50 in_list = True
51 item_text = re.sub(r"^[\*\d+\.]\s*", "", stripped_line)
52 result.append(f"<li>{item_text}</li>")
53 else:
54 if in_list:
55 result.append("</ul>")
56 in_list = False
57 result.append(line)
58 if in_list:
59 result.append("</ul>")
60
61 content = "\n".join(result)
62
63 # Wrap bare text blocks in <p> tags (lines not inside HTML tags)
64 content = re.sub(r"\n\n(?!<)", "\n\n<p>", content)
65
66 return content
67
68
69 def _is_markdown(content: str) -> bool:
70 """Detect if content is Markdown vs Fossil wiki/HTML.
71

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button