Skip to content

Commit da1e184

Browse files
authored
Merge pull request #390 from xxyzz/int
Get system message from MediaWiki namespace pages
2 parents a97feda + e7fb865 commit da1e184

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/wikitextprocessor/parserfns.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1657,6 +1657,11 @@ def int_fn(
16571657
if wtp.project == "wiktionary" and len(args) > 0 and args[0] == "lang":
16581658
return wtp.lang_code
16591659
if len(args) > 0 and len(args[0]) > 0:
1660+
page_body = wtp.get_page_body(
1661+
args[0], wtp.NAMESPACE_DATA["MediaWiki"]["id"]
1662+
)
1663+
if page_body is not None:
1664+
return page_body
16601665
return f"⧼{args[0]}⧽"
16611666
return f"[[:{wtp.LOCAL_NS_NAME_BY_ID.get(10, '')}:int:]]"
16621667

tests/test_parserfns.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,3 +219,17 @@ def test_padright_zero_division(self):
219219
self.wtp.start_page("land")
220220
self.assertEqual(self.wtp.expand("{{padright:|1|}}"), "")
221221
self.assertEqual(self.wtp.expand("{{padright:|1}}"), "0")
222+
223+
def test_int_mediawiki_page(self):
224+
# https://vi.wiktionary.org/wiki/Thảo_luận_Mô_đun:ViePron
225+
# https://vi.wiktionary.org/wiki/Bản_mẫu:vie-pron/Bảng
226+
self.wtp.start_page("test")
227+
self.wtp.add_page(
228+
"MediaWiki:wiktionary-vie-pron",
229+
8,
230+
"[[Wiktionary:IPA|IPA]] theo giọng",
231+
)
232+
self.assertEqual(
233+
self.wtp.expand("{{int:wiktionary-vie-pron}}"),
234+
"[[Wiktionary:IPA|IPA]] theo giọng",
235+
)

0 commit comments

Comments
 (0)