2ceb4e99d03494b708faa40a4c2cb394b3cd8cf6 — Evangelos Ribeiro Tzaras 2 months ago 13d4919
Convert markdown links to html hyperlinks

The following is an example of the regex:

>>> orig
'some text about [debian](https://debian.org "woohoo") yay!'
>>> re.sub("\[([^]]+?)\]\(([^)\s]+?)(?:\s.*?)?\)", r'<a href="\2">\1</a>', orig)
'some text about <a href="https://debian.org">debian</a> yay!'

Closes #19
1 files changed, 6 insertions(+), 2 deletions(-)

M src/pages.py
M src/pages.py => src/pages.py +6 -2
@@ 37,6 37,10 @@ from .config import APP_NAME, APP_ID, APP_VERSION, FMT_DAY_LIST
from . import models

def _convert_markdown_links(text):
    """converts markdown links to html hyperlinks"""
    return re.sub("\[([^]]+?)\]\(([^)\s]+?)(?:\s.*?)?\)", r'<a href="\2">\1</a>', text)

def _clean_markup(text):
    """remove unsupported markup from text to use in label"""
    text = text.replace("<p>", "").replace("</p>", "\n\n")

@@ 481,12 485,12 @@ class EventDetailPage(BasePage):
        # By now just filter out, but a more in-depth look should be taken
        if obj.abstract is not None and obj.abstract != "" and obj.abstract != "None":
            label = Gtk.Label(**LBL_PROPS)
            box.pack_start(label, False, False, 16)

        if obj.description is not None and obj.description != "" and obj.description != "None":
            label = Gtk.Label(**LBL_PROPS)
            box.pack_start(label, False, False, 16)

        ## links