| 1 |
#!/usr/bin/env python3 |
| 2 |
import os |
| 3 |
import re |
| 4 |
import sys |
| 5 |
|
| 6 |
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) |
| 7 |
|
| 8 |
from DisplayCAL.meta import DOMAIN |
| 9 |
|
| 10 |
tplpth = os.path.join(os.path.dirname(__file__), "..", "misc", "README.template.html") |
| 11 |
with open(tplpth, "r") as tpl: |
| 12 |
readme = tpl.read() |
| 13 |
|
| 14 |
chglog = re.search( |
| 15 |
r'<div id="(?:changelog|history)">' ".+?<h2>.+?</h2>" ".+?<dl>.+?</dd>", |
| 16 |
readme, |
| 17 |
re.S, |
| 18 |
) |
| 19 |
if chglog: |
| 20 |
chglog = chglog.group() |
| 21 |
chglog = re.sub(r'<div id="(?:changelog|history)">', "", chglog) |
| 22 |
chglog = re.sub(r"</?d[l|d]>", "", chglog) |
| 23 |
chglog = re.sub(r"<(?:h2|dt)>.+?</(?:h2|dt)>", "", chglog) |
| 24 |
chglog = re.sub(r"<h3>.+?</h3>", "", chglog) |
| 25 |
if chglog: |
| 26 |
chglog = re.sub( |
| 27 |
re.compile(r"<h\d>(.+?)</h\d>", flags=re.I | re.S), |
| 28 |
r"<p><strong>\1</strong></p>", |
| 29 |
chglog, |
| 30 |
) |
| 31 |
chglog = re.sub( |
| 32 |
re.compile(r'href="(#[^"]+)"', flags=re.I), |
| 33 |
rf'href="https://{DOMAIN}/\1"', |
| 34 |
chglog, |
| 35 |
) |
| 36 |
|
| 37 |
print(chglog.encode(sys.stdout.encoding, "replace")) |