diff options
| author | 2018-04-13 11:51:52 +0100 | |
|---|---|---|
| committer | 2018-04-13 11:51:52 +0100 | |
| commit | 47f183be8b877d21edc44622a09046157bd80c00 (patch) | |
| tree | f3ba401c359ff25aa5e25f35ac73afb60c801227 /pysite/rst/roles.py | |
| parent | Small styling fix for RST lists (diff) | |
[Wiki] Fix wiki page interpreted text role
Page slugs may contain slashes after all
Diffstat (limited to 'pysite/rst/roles.py')
| -rw-r--r-- | pysite/rst/roles.py | 28 | 
1 files changed, 11 insertions, 17 deletions
| diff --git a/pysite/rst/roles.py b/pysite/rst/roles.py index 10f14603..acba31e4 100644 --- a/pysite/rst/roles.py +++ b/pysite/rst/roles.py @@ -91,29 +91,23 @@ def page_role(_role: str, rawtext: str, text: str, lineno: int, inliner: Inliner      set_classes(options)      if "/" in text: -        parts = [escape(x) for x in text.split("/")] +        parts = [escape(x) for x in text.rsplit("/", 1)]      else:          msg = inliner.reporter.error("Page specification must be in the form <page_slug>/<text>", line=lineno)          prb = inliner.problematic(text, rawtext, msg)          return [prb], [msg] -    if len(parts) != 2: -        msg = inliner.reporter.error("Page specification must be in the form <page_slug>/<text>", line=lineno) -        prb = inliner.problematic(text, rawtext, msg) - -        return [prb], [msg] -    else: -        try: -            url = url_for("wiki.page", page=parts[0]) -            name = parts[1] +    try: +        url = url_for("wiki.page", page=parts[0]) +        name = parts[1] -            html = f"""<a href="{url}">{name}</a>""" +        html = f"""<a href="{url}">{name}</a>""" -            node = nodes.raw(html, html, format="html", **options) -            return [node], [] -        except Exception as e: -            msg = inliner.reporter.error(str(e), line=lineno) -            prb = inliner.problematic(text, rawtext, msg) +        node = nodes.raw(html, html, format="html", **options) +        return [node], [] +    except Exception as e: +        msg = inliner.reporter.error(str(e), line=lineno) +        prb = inliner.problematic(text, rawtext, msg) -            return [prb], [msg] +        return [prb], [msg] | 
