Skip to content

Commit

Permalink
Merge pull request #408 from tatuylonen/expansionnewlines
Browse files Browse the repository at this point in the history
Remove "multitrans" kludge with newlines
  • Loading branch information
kristian-clausal authored Nov 30, 2023
2 parents af54e9e + f7298e1 commit 420bcbe
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 21 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
test:
rm -rf .coverage htmlcov
python -m nose2 --output-buffer --pretty-assert --with-coverage --coverage-report=html
quick:
quicktest:
python -m nose2 --output-buffer --pretty-assert
clean:
rm -rf __pycache__
Expand Down
20 changes: 0 additions & 20 deletions src/wiktextract/extractor/en/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -1955,18 +1955,9 @@ def recurse(node, seq):
return ret
return None

# Kludge for multitrans bug, see wikitextprocessor issue 39
# and another place with this post_fn else on this page for
# the main expansion of a page
def multitrans_post_fn(name, ht, text):
if name == "multitrans" and not text.startswith("\n"):
return "\n" + text
return None

tree = wxr.wtp.parse(
subpage_content,
pre_expand=True,
post_template_fn=multitrans_post_fn,
additional_expand=ADDITIONAL_EXPAND_TEMPLATES,
do_not_pre_expand=DO_NOT_PRE_EXPAND_TEMPLATES
)
Expand Down Expand Up @@ -3460,22 +3451,11 @@ def parse_page(
# hierarchy by manipulating the subtitle levels in certain cases.
text = fix_subtitle_hierarchy(wxr, text)

# fix for bug multitrans and trans-top templates: multitrans creates
# lists, but is pre-expanded in wikitextprocessor before trans-top
# is expanded, so the first item ends up on the same line:
# {{trans-top}}* Foobarian translation item <- not parsed as list item
# This is duplicated elsewhere on this page for subpages
def multitrans_post_fn(name, ht, text):
if name == "multitrans" and not text.startswith("\n"):
return "\n" + text
return None

# Parse the page, pre-expanding those templates that are likely to
# influence parsing
tree = wxr.wtp.parse(
text,
pre_expand=True,
post_template_fn=multitrans_post_fn,
additional_expand=ADDITIONAL_EXPAND_TEMPLATES,
do_not_pre_expand=DO_NOT_PRE_EXPAND_TEMPLATES
)
Expand Down

0 comments on commit 420bcbe

Please sign in to comment.