# HG changeset patch # User Paul Boddie # Date 1551385475 -3600 # Node ID 44df186028399104e7b846f8d4bfac6a7234ae44 # Parent c9ac6e3843e1e25287a7dcf46114911c1a70fcd8 Provide a way of updating the conversion metadata and setting a document title. diff -r c9ac6e3843e1 -r 44df18602839 moinconvert --- a/moinconvert Mon Feb 25 21:34:41 2019 +0100 +++ b/moinconvert Thu Feb 28 21:24:35 2019 +0100 @@ -289,6 +289,8 @@ if macros: p.evaluate_macros() + p.update_metadata(metadata) + # Show a document tree for debugging purposes, if requested. if tree: diff -r c9ac6e3843e1 -r 44df18602839 moinformat/parsers/moin.py --- a/moinformat/parsers/moin.py Mon Feb 25 21:34:41 2019 +0100 +++ b/moinformat/parsers/moin.py Thu Feb 28 21:24:35 2019 +0100 @@ -123,6 +123,15 @@ macro = macro_cls(node, self.region) macro.evaluate() + # Metadata extraction. + + def update_metadata(self, metadata): + + "Update 'metadata' for the document." + + if self.headings: + metadata.set("title", self.headings[0].text_content()) + # Heading disambiguation. def identify_headings(self): diff -r c9ac6e3843e1 -r 44df18602839 moinformat/themes/html.py --- a/moinformat/themes/html.py Mon Feb 25 21:34:41 2019 +0100 +++ b/moinformat/themes/html.py Thu Feb 28 21:24:35 2019 +0100 @@ -3,7 +3,7 @@ """ Common HTML theme functionality. -Copyright (C) 2018 Paul Boddie +Copyright (C) 2018, 2019 Paul Boddie This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -71,7 +71,7 @@ "encoding" : self.output.encoding, "root" : self.linker.get_top_level() or ".", "text" : text, - "title" : self.metadata.get("pagename"), + "title" : self.metadata.get("title") or self.metadata.get("pagename"), } subs["links"] = self.get_links(subs) return template % subs