diff --git a/mwparserfromhell/nodes/template.py b/mwparserfromhell/nodes/template.py index c1abc2a..08ab4a5 100644 --- a/mwparserfromhell/nodes/template.py +++ b/mwparserfromhell/nodes/template.py @@ -249,11 +249,11 @@ class Template(Node): if not force_nonconformity: before_n, after_n = self._get_spacing_conventions(use_names=True) if before_n and after_n: - name = parse_anything([before_n, value, after_n]) + name = parse_anything([before_n, name, after_n]) elif before_n: - name = parse_anything([before_n, value]) + name = parse_anything([before_n, name]) elif after_n: - name = parse_anything([value, after_n]) + name = parse_anything([name, after_n]) before_v, after_v = self._get_spacing_conventions(use_names=False) if before_v and after_v: diff --git a/mwparserfromhell/wikicode.py b/mwparserfromhell/wikicode.py index e0f5acd..2c532f5 100644 --- a/mwparserfromhell/wikicode.py +++ b/mwparserfromhell/wikicode.py @@ -386,12 +386,12 @@ class Wikicode(StringMixIn): With *flat* as ``True``, each returned section contains all of its subsections within the :py:class:`~.Wikicode`; otherwise, the returned sections contain only the section up to the next heading, regardless of - its size. If *matches* is given, it should be a regex to matched + its size. If *matches* is given, it should be a regex to be matched against the titles of section headings; only sections whose headings - match the regex will be included. If *levels* is given, it should be a = - list of integers; only sections whose heading levels are within the - list will be returned. If *include_headings* is ``True``, the section's - literal :py:class:`~.Heading` object will be included in returned + match the regex will be included. If *levels* is given, it should be a + iterable of integers; only sections whose heading levels are within it + will be returned. If *include_headings* is ``True``, the section's + beginning :py:class:`~.Heading` object will be included in returned :py:class:`~.Wikicode` objects; otherwise, this is skipped. """ if matches: @@ -402,16 +402,16 @@ class Wikicode(StringMixIn): headings = [head for head in headings if head.level in levels] sections = [] - buffers = [[maxsize, 0]] + buffers = [(maxsize, 0)] i = 0 while i < len(self.nodes): if self.nodes[i] in headings: this = self.nodes[i].level for (level, start) in buffers: if not flat or this <= level: - buffers.remove([level, start]) + buffers.remove((level, start)) sections.append(Wikicode(self.nodes[start:i])) - buffers.append([this, i]) + buffers.append((this, i)) if not include_headings: i += 1 i += 1