From 7308c8055ec50475ccd3df146b76ee6b986f789c Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Fri, 23 Jun 2017 02:46:06 -0400 Subject: [PATCH] Not perfect, but slightly better template param space guessing (#155) --- mwparserfromhell/nodes/template.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mwparserfromhell/nodes/template.py b/mwparserfromhell/nodes/template.py index 9c89fbd..58d25ae 100644 --- a/mwparserfromhell/nodes/template.py +++ b/mwparserfromhell/nodes/template.py @@ -136,6 +136,11 @@ class Template(Node): component = str(param.value) match = re.search(r"^(\s*).*?(\s*)$", component, FLAGS) before, after = match.group(1), match.group(2) + if not use_names and component.isspace() and "\n" in before: + # If the value is empty, we expect newlines in the whitespace + # to be after the content, not before it: + before, after = before.split("\n", 1) + after = "\n" + after before_theories[before] += 1 after_theories[after] += 1