Skip to content

Commit

Permalink
fix function parse_wikilink(), + function get_parameter(NO)
Browse files Browse the repository at this point in the history
  • Loading branch information
kanasimi committed Oct 27, 2022
1 parent 4b62ec4 commit 90fa1b4
Show file tree
Hide file tree
Showing 11 changed files with 144 additions and 98 deletions.
4 changes: 2 additions & 2 deletions _structure/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -1297,8 +1297,8 @@ if (typeof CeL === 'function') {
// that also matches script content restrictions.
if (matched = config.match(/\/\*([\s\S]+?)\*\//))
config = matched[1];
if (config = (JSON.parse || eval_parse)(config.replace(
/[\s\r\n]*\/\//g, '')))
if (config = (typeof JSON === 'object' && JSON.parse || eval_parse)
(config.replace(/[\s\r\n]*\/\//g, '')))
env.script_config = config;
}
} catch (e) {
Expand Down
9 changes: 9 additions & 0 deletions _test suite/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3445,6 +3445,15 @@ function test_wiki() {
wikitext = '[[a|a{{!}}b|c]]'; parsed = CeL.wiki.parser(wikitext).parse();
assert([wikitext, parsed.toString()], 'wiki.parse.link #2');
assert(['a{{!}}b|c', parsed[0].display_text.toString()], 'wiki.parse.link #2-1');
wikitext = '[[[[T]]]]'; parsed = CeL.wiki.parser(wikitext).parse();
assert([wikitext, parsed.toString()], 'wiki.parse.link #3');
assert(['[[', parsed[0]], 'wiki.parse.link #3-1');
assert(['link', parsed[1].type], 'wiki.parse.link #3-2');
assert([']]', parsed[2]], 'wiki.parse.link #3-3');
wikitext = '[[{{T}}]]'; parsed = CeL.wiki.parser(wikitext).parse();
assert([wikitext, parsed.toString()], 'wiki.parse.link #4');
assert(['link', parsed[0].type], 'wiki.parse.link #4-1');
assert(['transclusion', parsed[0] && parsed[0][0] && parsed[0][0][0].type], 'wiki.parse.link #4-2');

wikitext = '[[Image:a.svg|thumb|20px|b{{c|d[[e]]f}}]]'; parsed = CeL.wiki.parser(wikitext).parse();
assert([wikitext, parsed.toString()], 'wiki.parse.file #1');
Expand Down
40 changes: 20 additions & 20 deletions application/locale/resources/i18n/qqq.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions application/locale/resources/pms-IT.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 20 additions & 20 deletions application/locale/resources/qqq_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -2636,7 +2636,7 @@
"message": "Comma-separator",
"original_message_language_code": "en-US",
"notes": "Used for separating lists of items. Should the same as <bdi><code>{{int:Comma-separator}}</code></bdi> ([[translatewiki:MediaWiki:Comma-separator]]).\nBe careful to the presence of a trailing space when appropriate for your language (if it is needed, you can input it as <code>&amp;#32;</code> to avoid its trimming when editing this message.\nSee also [[MediaWiki:Comma-separator]], [https://st.unicode.org/cldr-apps/v#/zh/Displaying_Lists/ Displaying Lists]; [[MediaWiki:Word-separator]], [[MediaWiki:Pipe-separator]], [[MediaWiki:And]].",
"references": "{{GitHub|kanasimi/CeJS/blob/master/application/net/wiki/data.js#L3001}}\n: {{GitHub|kanasimi/CeJS/blob/master/application/net/wiki/edit.js#L1316}}\n: {{GitHub|kanasimi/CeJS/blob/master/application/net/wiki/page.js#L164}}\n: {{GitHub|kanasimi/wikibot/blob/master/replace/replace_tool.js#L1564}}\n: {{GitHub|kanasimi/wikibot/blob/master/routine/20160517.%E8%A7%A3%E6%B6%88%E6%B8%88%E3%81%BF%E4%BB%AE%E3%83%AA%E3%83%B3%E3%82%AF%E3%82%92%E3%83%AA%E3%83%B3%E3%82%AF%E3%81%AB%E7%BD%AE%E3%81%8D%E6%8F%9B%E3%81%88%E3%82%8B.js#L647}}\n: {{GitHub|kanasimi/wikibot/blob/master/routine/20210923.update_foreign_featured_contents_list.js#L613}}",
"references": "{{GitHub|kanasimi/CeJS/blob/master/application/net/wiki/data.js#L3001}}\n: {{GitHub|kanasimi/CeJS/blob/master/application/net/wiki/edit.js#L1317}}\n: {{GitHub|kanasimi/CeJS/blob/master/application/net/wiki/page.js#L164}}\n: {{GitHub|kanasimi/wikibot/blob/master/replace/replace_tool.js#L1564}}\n: {{GitHub|kanasimi/wikibot/blob/master/routine/20160517.%E8%A7%A3%E6%B6%88%E6%B8%88%E3%81%BF%E4%BB%AE%E3%83%AA%E3%83%B3%E3%82%AF%E3%82%92%E3%83%AA%E3%83%B3%E3%82%AF%E3%81%AB%E7%BD%AE%E3%81%8D%E6%8F%9B%E3%81%88%E3%82%8B.js#L647}}\n: {{GitHub|kanasimi/wikibot/blob/master/routine/20210923.update_foreign_featured_contents_list.js#L613}}",
"repositories": "{{GitHub|kanasimi/CeJS|CeJS|link=hidden}}, {{GitHub|kanasimi/wikibot|wikibot|link=hidden}}"
},
"check-the-emergency-stop-page-$1": {
Expand Down Expand Up @@ -2684,68 +2684,68 @@
"message": "無法以正常方式編輯,嘗試當作 Flow 討論頁面。",
"original_message_language_code": "cmn-Hant-TW",
"notes": "[[w:WP:Flow]]",
"references": "{{GitHub|kanasimi/CeJS/blob/master/application/net/wiki/edit.js#L523}}",
"references": "{{GitHub|kanasimi/CeJS/blob/master/application/net/wiki/edit.js#L524}}",
"repositories": "{{GitHub|kanasimi/CeJS|CeJS|link=hidden}}"
},
"failed-to-edit-the-page-$1-$2": {
"message": "Failed to edit the page %1: %2",
"original_message_language_code": "en-US",
"parameters": "%1: page link, %2: the error",
"references": "{{GitHub|kanasimi/CeJS/blob/master/application/net/wiki/edit.js#L552}}",
"references": "{{GitHub|kanasimi/CeJS/blob/master/application/net/wiki/edit.js#L553}}",
"repositories": "{{GitHub|kanasimi/CeJS|CeJS|link=hidden}}"
},
"no-changes-to-page-content-$1": {
"message": "No changes to page content: %1",
"original_message_language_code": "en-US",
"notes": "Nothing to update. The contents are the same. Nothing changed.",
"parameters": "%1: page link",
"references": "{{GitHub|kanasimi/CeJS/blob/master/application/net/wiki/edit.js#L560}}",
"references": "{{GitHub|kanasimi/CeJS/blob/master/application/net/wiki/edit.js#L561}}",
"repositories": "{{GitHub|kanasimi/CeJS|CeJS|link=hidden}}"
},
"content-is-empty": {
"message": "Content is empty",
"notes": "Used as log message.",
"scope": "application.net.wiki",
"original_message_language_code": "en-US",
"references": "{{GitHub|kanasimi/CeJS/blob/master/application/net/wiki/edit.js#L622}}",
"references": "{{GitHub|kanasimi/CeJS/blob/master/application/net/wiki/edit.js#L623}}",
"repositories": "{{GitHub|kanasimi/CeJS|CeJS|link=hidden}}"
},
"content-is-not-settled": {
"message": "Content is not settled",
"notes": "Used as log message.",
"scope": "application.net.wiki",
"original_message_language_code": "en-US",
"references": "{{GitHub|kanasimi/CeJS/blob/master/application/net/wiki/edit.js#L624}}",
"references": "{{GitHub|kanasimi/CeJS/blob/master/application/net/wiki/edit.js#L625}}",
"repositories": "{{GitHub|kanasimi/CeJS|CeJS|link=hidden}}"
},
"abandon-change": {
"message": "Abandon change",
"notes": "Used as log message.",
"scope": "application.net.wiki",
"original_message_language_code": "en-US",
"references": "{{GitHub|kanasimi/CeJS/blob/master/application/net/wiki/edit.js#L631}}",
"references": "{{GitHub|kanasimi/CeJS/blob/master/application/net/wiki/edit.js#L632}}",
"repositories": "{{GitHub|kanasimi/CeJS|CeJS|link=hidden}}"
},
"no-reason-provided": {
"message": "No reason provided",
"notes": "Used as log message.",
"scope": "application.net.wiki",
"original_message_language_code": "en-US",
"references": "{{GitHub|kanasimi/CeJS/blob/master/application/net/wiki/edit.js#L648}}",
"references": "{{GitHub|kanasimi/CeJS/blob/master/application/net/wiki/edit.js#L649}}",
"repositories": "{{GitHub|kanasimi/CeJS|CeJS|link=hidden}}"
},
"the-text-between-update-comments-will-be-automatically-overwritten-by-the-bot": {
"message": "The text between update comments will be automatically overwritten by the bot.",
"original_message_language_code": "en-US",
"references": "{{GitHub|kanasimi/CeJS/blob/master/application/net/wiki/edit.js#L1513}}",
"references": "{{GitHub|kanasimi/CeJS/blob/master/application/net/wiki/edit.js#L1514}}",
"repositories": "{{GitHub|kanasimi/CeJS|CeJS|link=hidden}}"
},
"no-content": {
"message": "No content",
"notes": "沒有頁面內容。; Repositories: {{GitHub|kanasimi/CeJS|CeJS|link=hidden}}",
"scope": "work_crawler.js: check_next_chapter()",
"original_message_language_code": "en-US",
"references": "{{GitHub|kanasimi/CeJS/blob/master/application/net/wiki/edit.js#L1602}}\n: {{GitHub|kanasimi/CeJS/blob/master/application/net/wiki/page.js#L3496}}\n: {{GitHub|kanasimi/CeJS/blob/master/application/net/wiki/page.js#L3515}}\n: {{GitHub|kanasimi/CeJS/blob/master/application/net/wiki/page.js#L682}}\n: {{GitHub|kanasimi/CeJS/blob/master/application/net/work_crawler/ebook.js#L656}}",
"references": "{{GitHub|kanasimi/CeJS/blob/master/application/net/wiki/edit.js#L1603}}\n: {{GitHub|kanasimi/CeJS/blob/master/application/net/wiki/page.js#L3500}}\n: {{GitHub|kanasimi/CeJS/blob/master/application/net/wiki/page.js#L3519}}\n: {{GitHub|kanasimi/CeJS/blob/master/application/net/wiki/page.js#L682}}\n: {{GitHub|kanasimi/CeJS/blob/master/application/net/work_crawler/ebook.js#L656}}",
"repositories": "{{GitHub|kanasimi/CeJS|CeJS|link=hidden}}"
},
"$1-results": {
Expand Down Expand Up @@ -2886,7 +2886,7 @@
"original_message_language_code": "en-US",
"notes": "",
"parameters": "%1: page link",
"references": "{{GitHub|kanasimi/CeJS/blob/master/application/net/wiki/page.js#L3525}}\n: {{GitHub|kanasimi/wikibot/blob/master/replace/replace_tool.js#L708}}",
"references": "{{GitHub|kanasimi/CeJS/blob/master/application/net/wiki/page.js#L3529}}\n: {{GitHub|kanasimi/wikibot/blob/master/replace/replace_tool.js#L708}}",
"repositories": "{{GitHub|kanasimi/CeJS|CeJS|link=hidden}}, {{GitHub|kanasimi/wikibot|wikibot|link=hidden}}"
},
"there-are-more-than-one-$1-in-$2": {
Expand Down Expand Up @@ -8279,66 +8279,66 @@
"original_message_language_code": "cmn-Hant-TW",
"notes": "As a note phrase in talk pages.",
"parameters": "%1: link to a web anchor, %2: link to the target page",
"references": "{{GitHub|kanasimi/wikibot/blob/master/routine/20201008.fix_anchor.js#L1148}}\n: {{GitHub|kanasimi/wikibot/blob/master/routine/20201008.fix_anchor.js#L1312}}",
"references": "{{GitHub|kanasimi/wikibot/blob/master/routine/20201008.fix_anchor.js#L1147}}\n: {{GitHub|kanasimi/wikibot/blob/master/routine/20201008.fix_anchor.js#L1311}}",
"repositories": "{{GitHub|kanasimi/wikibot|wikibot|link=hidden}}"
},
"the-anchor-($2)-has-been-deleted-by-other-users-before": {
"message": "此網頁錨點(%2)之前[[Special:Diff/%1|曾被其他用戶刪除過]]。",
"original_message_language_code": "cmn-Hant-TW",
"parameters": "%1: revid, %2: anchor name",
"notes": "{{tl|Broken anchors}}の内で表示。",
"references": "{{GitHub|kanasimi/wikibot/blob/master/routine/20201008.fix_anchor.js#L1155}}",
"references": "{{GitHub|kanasimi/wikibot/blob/master/routine/20201008.fix_anchor.js#L1154}}",
"repositories": "{{GitHub|kanasimi/wikibot|wikibot|link=hidden}}"
},
"reminder-of-an-inactive-anchor": {
"message": "提醒失效的網頁錨點",
"original_message_language_code": "cmn-Hant-TW",
"notes": "Use in edit summaries. 用於編輯註解。編集の要約。",
"references": "{{GitHub|kanasimi/wikibot/blob/master/routine/20201008.fix_anchor.js#L1160}}\n: {{GitHub|kanasimi/wikibot/blob/master/routine/20201008.fix_anchor.js#L1168}}",
"references": "{{GitHub|kanasimi/wikibot/blob/master/routine/20201008.fix_anchor.js#L1159}}\n: {{GitHub|kanasimi/wikibot/blob/master/routine/20201008.fix_anchor.js#L1167}}",
"repositories": "{{GitHub|kanasimi/wikibot|wikibot|link=hidden}}"
},
"update-links-to-archived-section-$1-$2": {
"message": "更新指向存檔的連結%1:%2",
"original_message_language_code": "cmn-Hant-TW",
"parameters": "%1: percentage 百分比 e.g., \"42%\"; %2: links being processed 正在處理的連結",
"notes": "Use in edit summaries. 用於編輯註解。[[w:ja:Wikipedia:井戸端/subj/議論の過去ログのリンク修正はいかがでしょうか|過去ログリンク修正]]の編集の要約。",
"references": "{{GitHub|kanasimi/wikibot/blob/master/routine/20201008.fix_anchor.js#L1243}}",
"references": "{{GitHub|kanasimi/wikibot/blob/master/routine/20201008.fix_anchor.js#L1242}}",
"repositories": "{{GitHub|kanasimi/wikibot|wikibot|link=hidden}}"
},
"incorrect-capitalization-spaced-section-title": {
"message": "大小寫或空白相異的網頁錨點",
"original_message_language_code": "cmn-Hant-TW",
"notes": "Use in edit summaries. 用於編輯註解。編集の要約。 Too different to be considered as the same meaning.",
"references": "{{GitHub|kanasimi/wikibot/blob/master/routine/20201008.fix_anchor.js#L1279}}",
"references": "{{GitHub|kanasimi/wikibot/blob/master/routine/20201008.fix_anchor.js#L1278}}",
"repositories": "{{GitHub|kanasimi/wikibot|wikibot|link=hidden}}"
},
"inconsistency-between-traditional-and-simplified-chinese": {
"message": "繁簡不符匹配而失效的網頁錨點",
"original_message_language_code": "cmn-Hant-TW",
"notes": "Use in edit summaries. 用於編輯註解。編集の要約。",
"references": "{{GitHub|kanasimi/wikibot/blob/master/routine/20201008.fix_anchor.js#L1282}}",
"references": "{{GitHub|kanasimi/wikibot/blob/master/routine/20201008.fix_anchor.js#L1281}}",
"repositories": "{{GitHub|kanasimi/wikibot|wikibot|link=hidden}}"
},
"very-different": {
"message": "差異極大",
"original_message_language_code": "cmn-Hant-TW",
"notes": "Use in edit summaries to mark edits that need special attention. Too different to be regarded as the same meaning. 用於編輯註解以標註特別需要注意的編輯。編集の要約。",
"references": "{{GitHub|kanasimi/wikibot/blob/master/routine/20201008.fix_anchor.js#L1294}}",
"references": "{{GitHub|kanasimi/wikibot/blob/master/routine/20201008.fix_anchor.js#L1293}}",
"repositories": "{{GitHub|kanasimi/wikibot|wikibot|link=hidden}}"
},
"please-help-to-check-this-edit": {
"message": "請幫忙檢核此次編輯。",
"original_message_language_code": "cmn-Hant-TW",
"notes": "Use in edit summaries. 用於編輯註解。應採用不存在的頁面名稱,將用紅色連結顯示以突顯警告效果。編集の要約。",
"references": "{{GitHub|kanasimi/wikibot/blob/master/routine/20201008.fix_anchor.js#L1347}}",
"references": "{{GitHub|kanasimi/wikibot/blob/master/routine/20201008.fix_anchor.js#L1346}}",
"repositories": "{{GitHub|kanasimi/wikibot|wikibot|link=hidden}}"
},
"$1→most-alike-anchor-$2": {
"message": "%1→當前最近似的網頁錨點%2",
"original_message_language_code": "cmn-Hant-TW",
"parameters": "%1: original anchor, %2: target anchor",
"notes": "Use in edit summaries. 用於編輯註解。編集の要約。",
"references": "{{GitHub|kanasimi/wikibot/blob/master/routine/20201008.fix_anchor.js#L1355}}",
"references": "{{GitHub|kanasimi/wikibot/blob/master/routine/20201008.fix_anchor.js#L1354}}",
"repositories": "{{GitHub|kanasimi/wikibot|wikibot|link=hidden}}"
},
"archiving-operation": {
Expand Down
4 changes: 2 additions & 2 deletions application/locale/resources/ru-RU.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion application/net/wiki/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -420,9 +420,10 @@ function module_code(library_namespace) {
// 暫時debug [[Template:Bulletin]]
if (title === 'Template:Bulletin') {
Error.stackTraceLimit = Infinity;
console.trace('Edit Template:Bulletin!');
console.trace(options);
Error.stackTraceLimit = 10;
throw new Error('Edit Template:Bulletin!');
// throw new Error('Edit Template:Bulletin!');
}

// 造出可 modify 的 options。
Expand Down
Loading

0 comments on commit 90fa1b4

Please sign in to comment.