Skip to content

Commit e0ba1dc

Browse files
committed
fix function parse_transclusion()
1 parent 408938a commit e0ba1dc

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

_test suite/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5646,7 +5646,7 @@ function test_wiki() {
56465646
assert(['Wikipedia:Sandbox', enwiki.title_of(page_data)], 'enwiki.title_of() #1');
56475647
assert(['Abc', enwiki.title_of('abc')], 'enwiki.title_of() #2');
56485648
// {Date}page_data.creation_Date
5649-
assert(['2002-12-20T21:50:14.000Z', page_data && page_data.creation_Date.toISOString()], 'get_creation_Date: [[Wikipedia:Sandbox]]');
5649+
assert(['2008-03-14T03:01:58.000Z', page_data && page_data.creation_Date.toISOString()], 'get_creation_Date: [[Wikipedia:Sandbox]]');
56505650
_finish_test('wiki: get_creation_Date and others');
56515651
}, {
56525652
get_creation_Date: true

application/net/wiki/parser/wikitext.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -967,8 +967,17 @@ function module_code(library_namespace) {
967967
}
968968
}
969969

970-
// 可算 function preprocess_section_link_token(token, options) 的簡化版。
971-
// 可能保留 "\n"、不可見字符 必須自己 .trim()。
970+
/**
971+
* 將 wiki element 轉成 key。
972+
*
973+
* 可算 function preprocess_section_link_token(token, options) 的簡化版。
974+
*
975+
* 可能保留 "\n"、不可見字符 必須自己 .trim()。
976+
*
977+
* @param {Array|String}token
978+
* wiki element token
979+
* @returns {String|Array} key
980+
*/
972981
function wiki_element_to_key(token) {
973982
if (!Array.isArray(token))
974983
return token;
@@ -994,6 +1003,7 @@ function module_code(library_namespace) {
9941003
// console.trace([ has_no_string, _token ]);
9951004
if (token.type === 'plain' && !has_no_string)
9961005
return _token.join('');
1006+
// 注意: 這時 不會回傳 {String}!
9971007
return set_wiki_type(_token, token.type);
9981008
}
9991009

@@ -2660,11 +2670,11 @@ function module_code(library_namespace) {
26602670
invoke_properties.module_name
26612671
// token[1]: module name 模組名稱
26622672
= wiki_API.normalize_title(wiki_element_to_key(
2663-
value, options).trim());
2673+
value, options).toString().trim());
26642674
} else if (invoke_properties && _index === 2) {
26652675
invoke_properties.function_name
26662676
// token[2]: lua function name 函式名稱
2667-
= wiki_element_to_key(value, options).trim()
2677+
= wiki_element_to_key(value, options)
26682678
// || 'main'
26692679
;
26702680
} else {

0 commit comments

Comments
 (0)