1.1 --- a/moinformat/serialisers/html/moin.py Mon Apr 15 15:13:40 2019 +0200
1.2 +++ b/moinformat/serialisers/html/moin.py Mon Apr 15 16:12:58 2019 +0200
1.3 @@ -3,7 +3,7 @@
1.4 """
1.5 HTML serialiser.
1.6
1.7 -Copyright (C) 2017, 2018 Paul Boddie <paul@boddie.org.uk>
1.8 +Copyright (C) 2017, 2018, 2019 Paul Boddie <paul@boddie.org.uk>
1.9
1.10 This program is free software; you can redistribute it and/or modify it under
1.11 the terms of the GNU General Public License as published by the Free Software
1.12 @@ -20,7 +20,8 @@
1.13 """
1.14
1.15 from moinformat.serialisers.common import escape_attr, escape_text, Serialiser
1.16 -from moinformat.tree.moin import LinkLabel, LinkParameter
1.17 +from moinformat.tree.moin import LinkLabel, LinkParameter, Text
1.18 +from moinformat.utils.links import parse_link_target
1.19
1.20 class HTMLSerialiser(Serialiser):
1.21
1.22 @@ -247,7 +248,20 @@
1.23 pass
1.24
1.25 def directive(self, directive, extra):
1.26 - pass
1.27 + name, text = directive.split(None, 1)
1.28 +
1.29 + # Produce a readable redirect.
1.30 +
1.31 + if name.lower() == "redirect":
1.32 + self.start_block()
1.33 +
1.34 + # Process the redirect argument as a link target, producing a link
1.35 + # element.
1.36 +
1.37 + target = parse_link_target(text, self.metadata)
1.38 + self._link(target, [LinkLabel([Text(text)])], "a", "href")
1.39 +
1.40 + self.end_block()
1.41
1.42 def linebreak(self):
1.43 self.out("<br />")