TiddlyWiki5/plugins/tiddlywiki
s793016 cda8d7ca8c
Aho-Corasick Freelinks Enhancement for Large Wikis and Non-Latin Titles (#9084)
* Enhance Freelinks with Aho-Corasick for long titles and large wikis

Replaces regex with Aho-Corasick, adds chunking (100 titles/chunk), cache toggle, and Chinese full-width symbol support. Tested with 11,714 tiddlers.

* delete comment

* Create AhoCorasick.js

* Update text.js

* Update text.js

* Update AhoCorasick.js

* Update text.js

* Update text.js

* move AhoCorasick to AhoCorasick.js

* update AhoCorasick.js

* Delete core/modules/utils/AhoCorasick.js

wrong place

* Update text.js

* indentation modify

* remove function {}

* remove function {}

* Rename AhoCorasick.js to aho-corasick.js

correct filename

* Update tiddlywiki.info add freelink

* missing a comma here

* clean up comments & use old style

* try add it to editions/tw5.com-server for testing

* try add it to editions/prerelease for testing

* optimized

* optimized

* add setting for "Persist AhoCorasick cache"

* add  dynamic limits

* remove comment

* revert to 5f0b98d1fd

* try sort alphabet

* try sort alphabet

* try sort alphabet

* typo freelink -> freelinks

* typo freelink -> freelinks

* typo freelink -> freelinks

* Update readme.tid

* Update aho-corasick.js

Dynamically adjust limit parameters to avoid problems caused by hard-coded limits.

* Update text.js

Dynamically adjust limit parameters to avoid problems caused by hard-coded limits.

* Update tiddlywiki.info

remove other plugin for test plugin conflict

* Update tiddlywiki.info

* Update tiddlywiki.info

* Update aho-corasick.js

Description of major changes

Improve state transition logic - Ensure to go back to root node correctly in case of mismatch, and check root node for current character transition 
Fix failed link traversal - Add condition node ! == this.trie to avoid infinite loop at root node 
Enhance output collection - collect output not only from current node, but also from all nodes on failed link path, which is key to Aho-Corasick algorithm 
Add safety limit - collectCount < 10 to prevent failed link loops

Translated with DeepL.com (free version)

* Update aho-corasick.js

Word Boundary Check - The isWordBoundaryMatch function checks if the match is on a word boundary:

Alphanumeric characters [a-zA-Z0-9_] are regarded as unicode characters 
At least one non-unicode character must be present before and after the match for it to be considered valid.

* Update text.js

Word Boundary Check - The isWordBoundaryMatch function checks if the match is on a word boundary:

Alphanumeric characters [a-zA-Z0-9_] are regarded as unicode characters 
At least one non-unicode character must be present before and after the match for it to be considered valid.

* Update settings.tid

Word Boundary Check - The isWordBoundaryMatch function checks if the match is on a word boundary:

Alphanumeric characters [a-zA-Z0-9_] are regarded as unicode characters 
At least one non-unicode character must be present before and after the match for it to be considered valid.

* fix Word Boundary logic

* remove PersistentCache @ text.js

* remove PersistentCache @settings.tid

* Update readme.tid for Word Boundary Check

* Update aho-corasick.js Organize and delete comments

* Initial commit of freelinks plugin

* Update settings.tid Organize and delete comments

* Update tiddlywiki.info add back other plugin

* Update tiddlywiki.info alphabet sort

* Update readme.tid for new future

The plugin supports non-Western language tiddler titles (e.g., Chinese) and prioritizes longer tiddler titles for matching, ensuring accurate linking in diverse contexts. 

Furthermore, the current tiddler title within its own content is excluded from generating links to avoid self-referencing.

* Update readme.tid

* Update plugins/tiddlywiki/freelinks/text.js

Co-authored-by: Mario Pietsch <pmariojo@gmail.com>

* Update plugins/tiddlywiki/freelinks/aho-corasick.js

Co-authored-by: Mario Pietsch <pmariojo@gmail.com>

* Update plugins/tiddlywiki/freelinks/aho-corasick.js

Co-authored-by: Mario Pietsch <pmariojo@gmail.com>

* Update plugins/tiddlywiki/freelinks/text.js

Co-authored-by: Mario Pietsch <pmariojo@gmail.com>

* Update plugins/tiddlywiki/freelinks/aho-corasick.js

Co-authored-by: Mario Pietsch <pmariojo@gmail.com>

* Update text.js

Added locale configuration support - Added LOCALE_CONFIG_TIDDLER constant to make the sorting locale configurable instead of hardcoded "zh"
Optimized title processing - Combined the filtering and escaping logic into a single pass to reduce duplication
Added trim() for ignoreCase - Applied .trim() to the ignore case variable for consistency
Enhanced refresh logic - Added locale configuration tiddler to the refresh check
Improved comments - Added explanation for why sorting is necessary (prioritizing longer titles)

* Update text.js

we don't need to specify 'zh' at all

* Update aho-corasick.js

This single line change would add support for:

Accented letters: á, é, í, ó, ú, à, è, ì, ò, ù, ä, ë, ï, ö, ü, ñ, ç, etc.
Most Western European languages (Spanish, French, German, Italian, Portuguese, etc.)

* Update aho-corasick.js useage

* Update readme.tid for Writing Style

* Update tiddlywiki.info

revert all the changes

* Update tiddlywiki.info

revert all the changes

* Update tiddlywiki.info

revert all the changes

* Update tiddlywiki.info

revert

* Update text.js

plugins/tiddlywiki/freelinks/text.js#L25
[ESLint PR code] reported by reviewdog 🐶
Strings must use doublequote.

* Update aho-corasick.js

plugins/tiddlywiki/freelinks/aho-corasick.js#L193
[ESLint PR code] reported by reviewdog 🐶
Strings must use doublequote.

Raw Output:
{"ruleId":"@stylistic/quotes","severity":2,"message":"Strings must use doublequote.","line":193,"column":50,"nodeType":"Literal","messageId":"wrongQuotes","endLine":193,"endColumn":52,"fix":{"range":[5743,5745],"text":"\"\""}}

---------

Co-authored-by: Mario Pietsch <pmariojo@gmail.com>
2025-10-29 17:41:35 +00:00
..
async Add plugin stability badges (#8198) 2024-05-21 11:22:39 +01:00
aws Remove module function wrapper and add matching configurations for dprint and eslint (#7596) 2025-03-21 17:22:57 +00:00
bibtex Remove module function wrapper and add matching configurations for dprint and eslint (#7596) 2025-03-21 17:22:57 +00:00
browser-sniff Remove module function wrapper and add matching configurations for dprint and eslint (#7596) 2025-03-21 17:22:57 +00:00
browser-storage Remove module function wrapper and add matching configurations for dprint and eslint (#7596) 2025-03-21 17:22:57 +00:00
classictools Remove module function wrapper and add matching configurations for dprint and eslint (#7596) 2025-03-21 17:22:57 +00:00
codemirror Bump codemirror 5 plugin version to 5.65.19 (#9114) 2025-06-28 16:18:42 +01:00
codemirror-autocomplete Bump codemirror 5 plugin version to 5.65.19 (#9114) 2025-06-28 16:18:42 +01:00
codemirror-closebrackets Bump codemirror 5 plugin version to 5.65.19 (#9114) 2025-06-28 16:18:42 +01:00
codemirror-closetag Add plugin stability badges (#8198) 2024-05-21 11:22:39 +01:00
codemirror-fullscreen-editing Bump codemirror 5 plugin version to 5.65.19 (#9114) 2025-06-28 16:18:42 +01:00
codemirror-keymap-emacs Bump codemirror 5 plugin version to 5.65.19 (#9114) 2025-06-28 16:18:42 +01:00
codemirror-keymap-sublime-text Bump codemirror 5 plugin version to 5.65.19 (#9114) 2025-06-28 16:18:42 +01:00
codemirror-keymap-vim Bump codemirror 5 plugin version to 5.65.19 (#9114) 2025-06-28 16:18:42 +01:00
codemirror-mode-css Bump codemirror 5 plugin version to 5.65.19 (#9114) 2025-06-28 16:18:42 +01:00
codemirror-mode-htmlembedded Bump codemirror 5 plugin version to 5.65.19 (#9114) 2025-06-28 16:18:42 +01:00
codemirror-mode-htmlmixed Bump codemirror 5 plugin version to 5.65.19 (#9114) 2025-06-28 16:18:42 +01:00
codemirror-mode-javascript Bump codemirror 5 plugin version to 5.65.19 (#9114) 2025-06-28 16:18:42 +01:00
codemirror-mode-markdown Bump codemirror 5 plugin version to 5.65.19 (#9114) 2025-06-28 16:18:42 +01:00
codemirror-mode-x-tiddlywiki Bump codemirror 5 plugin version to 5.65.19 (#9114) 2025-06-28 16:18:42 +01:00
codemirror-mode-xml Bump codemirror 5 plugin version to 5.65.19 (#9114) 2025-06-28 16:18:42 +01:00
codemirror-search-replace Bump codemirror 5 plugin version to 5.65.19 (#9114) 2025-06-28 16:18:42 +01:00
codemirror-trailingspace Bump codemirror 5 plugin version to 5.65.19 (#9114) 2025-06-28 16:18:42 +01:00
comments Use currentColor to style svg (#9316) 2025-10-07 11:55:26 +01:00
confetti Change experimental plugins to stable 2025-05-18 12:04:08 +01:00
consent-banner Remove module function wrapper and add matching configurations for dprint and eslint (#7596) 2025-03-21 17:22:57 +00:00
dynannotate Fix bug exposed by #9030 2025-04-14 22:17:18 +01:00
dynaview Remove module function wrapper and add matching configurations for dprint and eslint (#7596) 2025-03-21 17:22:57 +00:00
evernote Remove module function wrapper and add matching configurations for dprint and eslint (#7596) 2025-03-21 17:22:57 +00:00
external-attachments Remove module function wrapper and add matching configurations for dprint and eslint (#7596) 2025-03-21 17:22:57 +00:00
filesystem Further improvements for offloading server components (#9288) 2025-09-14 11:21:42 +01:00
freelinks Aho-Corasick Freelinks Enhancement for Large Wikis and Non-Latin Titles (#9084) 2025-10-29 17:41:35 +00:00
geospatial Change experimental plugins to stable 2025-05-18 12:04:08 +01:00
github-fork-ribbon Fix github fork ribbon plugin marked as deprecated & add it back to full edition. (#8656) 2024-10-02 12:42:49 +01:00
googleanalytics [5.4.0] Update eslint target to 2017 and do initial fixes (#9135) 2025-10-01 15:08:00 +01:00
help Update PageControls buttons to use v5.3.2 syntax (#8579) 2024-09-10 12:00:13 +01:00
highlight [5.4.0] Update highlightjs plugin (#9118) 2025-10-29 11:04:53 +00:00
innerwiki Remove function wrappers from plugins (#9030) 2025-04-14 18:28:04 +01:00
internals Add plugin stability badges (#8198) 2024-05-21 11:22:39 +01:00
jasmine Remove module function wrapper and add matching configurations for dprint and eslint (#7596) 2025-03-21 17:22:57 +00:00
jszip Remove module function wrapper and add matching configurations for dprint and eslint (#7596) 2025-03-21 17:22:57 +00:00
katex Remove module function wrapper and add matching configurations for dprint and eslint (#7596) 2025-03-21 17:22:57 +00:00
markdown Markdown: Fix missing inline support and macrocall args parsing error (#9295) 2025-10-10 13:31:11 +01:00
markdown-legacy Remove module function wrapper and add matching configurations for dprint and eslint (#7596) 2025-03-21 17:22:57 +00:00
menubar Use currentColor to style svg (#9316) 2025-10-07 11:55:26 +01:00
pluginlibrary Remove module function wrapper and add matching configurations for dprint and eslint (#7596) 2025-03-21 17:22:57 +00:00
powered-by-tiddlywiki Add plugin stability badges (#8198) 2024-05-21 11:22:39 +01:00
qrcode Remove function wrappers from plugins (#9030) 2025-04-14 18:28:04 +01:00
railroad Remove module function wrapper and add matching configurations for dprint and eslint (#7596) 2025-03-21 17:22:57 +00:00
savetrail Remove module function wrapper and add matching configurations for dprint and eslint (#7596) 2025-03-21 17:22:57 +00:00
sax Add plugin stability badges (#8198) 2024-05-21 11:22:39 +01:00
share Fix some download file types. (#9026) 2025-04-12 15:32:10 +01:00
stacked-view Change experimental plugins to stable 2025-05-18 12:04:08 +01:00
text-slicer Use currentColor to style svg (#9316) 2025-10-07 11:55:26 +01:00
tiddlyweb [v5.4.0] Offload server components from browser builds of TiddlyWiki (#9183) 2025-09-12 15:21:34 +01:00
tour Use currentColor to style svg (#9316) 2025-10-07 11:55:26 +01:00
translators Translator editon update (#8703) 2024-10-29 12:07:12 +00:00
tw2parser Remove module function wrapper and add matching configurations for dprint and eslint (#7596) 2025-03-21 17:22:57 +00:00
tw5.com-docs Change experimental plugins to stable 2025-05-18 12:04:08 +01:00
twitter Remove module function wrapper and add matching configurations for dprint and eslint (#7596) 2025-03-21 17:22:57 +00:00
twitter-archivist [5.4.0] Update eslint target to 2017 and do initial fixes (#9135) 2025-10-01 15:08:00 +01:00
upgrade Use currentColor to style svg (#9316) 2025-10-07 11:55:26 +01:00
xlsx-utils [5.4.0] Update eslint target to 2017 and do initial fixes (#9135) 2025-10-01 15:08:00 +01:00
xmldom Add plugin stability badges (#8198) 2024-05-21 11:22:39 +01:00