From c85af755acfcdd32f9093ac2d2f353a2343597ca Mon Sep 17 00:00:00 2001 From: Groggy Dice Date: Fri, 25 Apr 2014 01:26:11 -0400 Subject: [PATCH] html.py: format add-on description for HTML The description text does not get rendered very well on a webpage. One solution might be to use pre-wrap/word-wrap in the CSS, but due to differences between browsers, that's a can of worms (at least for me, I'm not a web pro). So, the not-so-elegant solution is to add
to every line. URLs are also not linked in the plain text. Although in modern browsers you can select the text and right-click, it's still convenient to turn them into actual links. --- data/tools/addon_manager/html.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/data/tools/addon_manager/html.py b/data/tools/addon_manager/html.py index d89728349ef..d0ba0927dba 100755 --- a/data/tools/addon_manager/html.py +++ b/data/tools/addon_manager/html.py @@ -134,8 +134,21 @@ unit packs, terrain packs, music packs, etc. Usually a (perhaps optional) depend else: w(('%s') % type) w(('%s' ) % (icon, imgurl)) + described = v("description", "(no description)") + if described != "(no description)": + shift = 0 + for urlref in re.finditer(r'(?])http://[\w./?&=%~-]+', described): + described = described[:urlref.start()+shift] + '' + urlref.group(0) + "" + described[urlref.end()+shift:] + shift += 15 + len(urlref.group(0)) + shift = 0 + for wesurl in re.finditer(r'(?"/])(forums?|r|R|wiki)\.wesnoth\.org/[\w./?&=%~-]+', described): + described = described[:wesurl.start()+shift] + '' + wesurl.group(0) + "" + described[wesurl.end()+shift:] + shift += 22 + len(wesurl.group(0)) + described = re.sub(r"\n", "\n
", described) + if sys.platform != "win32": + described = re.sub(r"\r(?!\n)", r"\r
", described) w('
%s
%s
' % ( - name, v("description", "(no description)"))) + name, described)) w("%s
" % name) w("Version: %s
" % v("version", "unknown")) w("Author: %s" % v("author", "unknown"))