Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/cygwin-apps/calm.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/calm
diff options
context:
space:
mode:
authorJon Turney <jon.turney@dronecode.org.uk>2023-12-13 16:26:31 +0300
committerJon Turney <jon.turney@dronecode.org.uk>2024-01-05 22:00:15 +0300
commita9826e13ff7e19a0b446ca22d58d8819ffcabd06 (patch)
tree2c342cbaa0cb61406600d70f91d554b35a931428 /calm
parent72a36434339e74676904906db287e720a0b75a0d (diff)
Improve rendering of minimal Markdown for description in package summary
Retain the heuristic which makes URLs in the description, and improve it's handling of some cases.
Diffstat (limited to 'calm')
-rwxr-xr-xcalm/pkg2html.py21
1 files changed, 14 insertions, 7 deletions
diff --git a/calm/pkg2html.py b/calm/pkg2html.py
index d44b40b..ea4cb8f 100755
--- a/calm/pkg2html.py
+++ b/calm/pkg2html.py
@@ -52,6 +52,8 @@ import textwrap
import time
from typing import NamedTuple
+import markdown
+
import xtarfile
from . import common_constants
@@ -80,13 +82,18 @@ def ldesc(po, bv):
return sdesc(po, bv)
header = header.strip('"')
- # escape html entities
- header = html.escape(header, quote=False)
- header = header.replace('\n\n', '\n<br>\n')
- # try to recognize things which look like bullet points
- header = re.sub(r'\n(\s*[*-]\s)', r'<br>\n\1', header)
- # linkify things which look like hyperlinks
- header = re.sub(r'http(s|)://[^\s\)]*', r'<a href="\g<0>">\g<0></a>', header)
+ header = markdown.markdown(header)
+
+ # linkify things which look like URLs
+ def linkify_without_fullstop(m):
+ url = m.group(0)
+ suffix = ''
+ if url[-1] == '.':
+ suffix = url[-1]
+ url = url[0:-1]
+ return '<a href="{0}">{0}</a>{1}'.format(url, suffix)
+
+ header = re.sub(r'http(s|)://[\w./_-]*', linkify_without_fullstop, header)
return header