22#
33# Copyright (c) 2020-2022 Tatu Ylonen. See file LICENSE and https://ylonen.org
44
5+ import re
56import unittest
67
78from wikitextprocessor import Wtp
@@ -1101,7 +1102,7 @@ def test_link12(self):
11011102 self .assertEqual (link .kind , NodeKind .LINK )
11021103 self .assertEqual (link .largs , [["foo" ], ["\n [bar" ]])
11031104
1104- def test_link_trailing (self ):
1105+ def test_link_trailing_1 (self ):
11051106 tree = self .parse ("test" , "[[Help]]ing heal" )
11061107 self .assertEqual (len (tree .children ), 2 )
11071108 a , b = tree .children
@@ -1110,6 +1111,20 @@ def test_link_trailing(self):
11101111 self .assertEqual (a .children , ["ing" ])
11111112 self .assertEqual (b , " heal" )
11121113
1114+ def test_link_trailing_not_latin (self ):
1115+ _linktrailing_re = self .ctx .linktrailing_re
1116+ # Normally this alternative pattern would be provided by Wiktextract's
1117+ # WiktextractConfig or something similar.
1118+ self .ctx .linktrailing_re = re .compile (r"(?s)([a-z]+)(.*)" )
1119+ tree = self .parse ("test" , "[[appellāre]]の直説法所相現在第 foo" )
1120+ self .ctx .linktrailing_re = _linktrailing_re
1121+ self .assertEqual (len (tree .children ), 2 )
1122+ a , b = tree .children
1123+ self .assertEqual (a .kind , NodeKind .LINK )
1124+ self .assertEqual (a .largs , [["appellāre" ]])
1125+ self .assertEqual (a .children , [])
1126+ self .assertEqual (b , "の直説法所相現在第 foo" )
1127+
11131128 def test_url1 (self ):
11141129 tree = self .parse ("test" , "this https://wikipedia.com link" )
11151130 self .assertEqual (len (tree .children ), 3 )
0 commit comments