paul@116 | 1 | #!/usr/bin/env python |
paul@116 | 2 | |
paul@116 | 3 | """ |
paul@116 | 4 | Anchor macro for Moin compatibility. |
paul@116 | 5 | |
paul@116 | 6 | Copyright (C) 2018 Paul Boddie <paul@boddie.org.uk> |
paul@116 | 7 | |
paul@116 | 8 | This program is free software; you can redistribute it and/or modify it under |
paul@116 | 9 | the terms of the GNU General Public License as published by the Free Software |
paul@116 | 10 | Foundation; either version 3 of the License, or (at your option) any later |
paul@116 | 11 | version. |
paul@116 | 12 | |
paul@116 | 13 | This program is distributed in the hope that it will be useful, but WITHOUT |
paul@116 | 14 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
paul@116 | 15 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
paul@116 | 16 | details. |
paul@116 | 17 | |
paul@116 | 18 | You should have received a copy of the GNU General Public License along with |
paul@116 | 19 | this program. If not, see <http://www.gnu.org/licenses/>. |
paul@116 | 20 | """ |
paul@116 | 21 | |
paul@116 | 22 | from moinformat.macros.common import Macro |
paul@116 | 23 | from moinformat.tree.moin import Anchor |
paul@116 | 24 | |
paul@116 | 25 | class AnchorMacro(Macro): |
paul@116 | 26 | |
paul@116 | 27 | "An anchor macro." |
paul@116 | 28 | |
paul@116 | 29 | name = "Anchor" |
paul@116 | 30 | |
paul@116 | 31 | def evaluate(self): |
paul@116 | 32 | |
paul@116 | 33 | "Evaluate the macro, producing an anchor node." |
paul@116 | 34 | |
paul@116 | 35 | # Obtain the concatenated arguments since they might contain commas. |
paul@116 | 36 | |
paul@116 | 37 | argstr = ",".join(self.node.args) |
paul@116 | 38 | |
paul@116 | 39 | # Replace the macro node with the anchor. |
paul@116 | 40 | |
paul@116 | 41 | macro = self.node |
paul@116 | 42 | macro.parent.replace(macro, Anchor(argstr)) |
paul@116 | 43 | |
paul@116 | 44 | macro = AnchorMacro |
paul@116 | 45 | |
paul@116 | 46 | # vim: tabstop=4 expandtab shiftwidth=4 |