1.1 --- a/moinformat/macros/common.py Sat Apr 13 00:08:31 2019 +0200
1.2 +++ b/moinformat/macros/common.py Sat Apr 13 00:26:57 2019 +0200
1.3 @@ -3,7 +3,7 @@
1.4 """
1.5 Common macro functionality.
1.6
1.7 -Copyright (C) 2018 Paul Boddie <paul@boddie.org.uk>
1.8 +Copyright (C) 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 @@ -23,11 +23,15 @@
1.13
1.14 "Common macro functionality."
1.15
1.16 - def __init__(self, node, doc):
1.17 + def __init__(self, node, doc, metadata):
1.18
1.19 - "Initialise the macro with its tree 'node' and document root, 'doc'."
1.20 + """
1.21 + Initialise the macro with its tree 'node' and document root, 'doc',
1.22 + employing the given 'metadata'.
1.23 + """
1.24
1.25 self.node = node
1.26 self.doc = doc
1.27 + self.metadata = metadata
1.28
1.29 # vim: tabstop=4 expandtab shiftwidth=4
2.1 --- a/moinformat/macros/toc.py Sat Apr 13 00:08:31 2019 +0200
2.2 +++ b/moinformat/macros/toc.py Sat Apr 13 00:26:57 2019 +0200
2.3 @@ -3,7 +3,7 @@
2.4 """
2.5 Table of contents macro.
2.6
2.7 -Copyright (C) 2018 Paul Boddie <paul@boddie.org.uk>
2.8 +Copyright (C) 2018, 2019 Paul Boddie <paul@boddie.org.uk>
2.9
2.10 This program is free software; you can redistribute it and/or modify it under
2.11 the terms of the GNU General Public License as published by the Free Software
2.12 @@ -20,8 +20,9 @@
2.13 """
2.14
2.15 from moinformat.macros.common import Macro
2.16 -from moinformat.tree.moin import Block, Container, Heading, Link, List, \
2.17 - ListItem, Text
2.18 +from moinformat.tree.moin import Block, Container, Heading, Link, LinkLabel, \
2.19 + List, ListItem, Text
2.20 +from moinformat.utils.links import parse_link_target
2.21
2.22 def in_range(min_level, level, max_level):
2.23
2.24 @@ -228,7 +229,11 @@
2.25
2.26 "Return nodes for an entry involving 'heading'."
2.27
2.28 - return [Link(heading.nodes[:], "#%s" % heading.identifier), Text("\n")]
2.29 + target = "#%s" % heading.identifier
2.30 + link_target = parse_link_target(target, self.metadata)
2.31 + link_label = LinkLabel(heading.nodes[:])
2.32 +
2.33 + return [Link([link_label], link_target), Text("\n")]
2.34
2.35 macro = TableOfContents
2.36
3.1 --- a/moinformat/parsers/moin.py Sat Apr 13 00:08:31 2019 +0200
3.2 +++ b/moinformat/parsers/moin.py Sat Apr 13 00:26:57 2019 +0200
3.3 @@ -128,7 +128,7 @@
3.4
3.5 # Instantiate the class and evaluate the macro.
3.6
3.7 - macro = macro_cls(node, self.region)
3.8 + macro = macro_cls(node, self.region, self.metadata)
3.9 macro.evaluate()
3.10
3.11 # Metadata extraction.