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
diff options
context:
space:
mode:
-rwxr-xr-xcalm/pkg2html.py21
-rw-r--r--requirements.txt1
-rwxr-xr-xtest/testdata/htdocs.expected/summary/openssh-src.html4
-rw-r--r--test/testdata/htdocs.expected/summary/openssh.html4
4 files changed, 19 insertions, 11 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
diff --git a/requirements.txt b/requirements.txt
index b75566e..3cb6f87 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -5,6 +5,7 @@ flake8-builtins
flake8-import-order
license_expression
lockfile
+markdown
pycodestyle
python-daemon
xtarfile[zstd]
diff --git a/test/testdata/htdocs.expected/summary/openssh-src.html b/test/testdata/htdocs.expected/summary/openssh-src.html
index 2bf497c..9ac2ab1 100755
--- a/test/testdata/htdocs.expected/summary/openssh-src.html
+++ b/test/testdata/htdocs.expected/summary/openssh-src.html
@@ -13,8 +13,8 @@
<table class="pkgdetails">
<tr><td><p><span class="detail">summary</span>:</p></td><td><p>The OpenSSH server and client programs</p></td></tr>
<tr><td><p><span class="detail">description</span>:</p></td><td><p>OpenSSH is a program for logging into a remote machine and for
- executing commands on a remote machine. It can replace rlogin and rsh,
- providing encrypted communication between two machines.</p></td></tr>
+ executing commands on a remote machine. It can replace rlogin and rsh,
+ providing encrypted communication between two machines.</p></td></tr>
<tr><td><p><span class="detail">categories</span>:</p></td><td><p>Net</p></td></tr>
<tr><td><p><span class="detail">install package(s)</span>:</p></td><td><p><a href="openssh.html">openssh</a></p></td></tr>
<tr><td><p><span class="detail">maintainer(s)</span>:</p></td><td><p>Corinna Vinschen
diff --git a/test/testdata/htdocs.expected/summary/openssh.html b/test/testdata/htdocs.expected/summary/openssh.html
index a97c3ca..75f3bc2 100644
--- a/test/testdata/htdocs.expected/summary/openssh.html
+++ b/test/testdata/htdocs.expected/summary/openssh.html
@@ -13,8 +13,8 @@
<table class="pkgdetails">
<tr><td><p><span class="detail">summary</span>:</p></td><td><p>The OpenSSH server and client programs</p></td></tr>
<tr><td><p><span class="detail">description</span>:</p></td><td><p>OpenSSH is a program for logging into a remote machine and for
- executing commands on a remote machine. It can replace rlogin and rsh,
- providing encrypted communication between two machines.</p></td></tr>
+ executing commands on a remote machine. It can replace rlogin and rsh,
+ providing encrypted communication between two machines.</p></td></tr>
<tr><td><p><span class="detail">categories</span>:</p></td><td><p>Net</p></td></tr>
<tr><td><p><span class="detail">rdepends</span>:</p></td><td><p><a href="keychain.html">keychain</a></p></td></tr>
<tr><td><p><span class="detail">source package</span>:</p></td><td><p><a href="openssh-src.html">openssh</a></p></td></tr>