Edict2: add option to create links from references to other words#679
Merged
Conversation
ilius
reviewed
Oct 13, 2025
| | Kobo E-Reader Dictfile (.df) | Dictfile | [kobo_dictfile.md](./kobo_dictfile.md) | | ||
| | Mobipocket (.mobi) E-Book | Mobi | [mobi.md](./mobi.md) | | ||
| | EDICT2 (CEDICT) (.u8) | EDICT2 | [edict2.md](./edict2.md) | | ||
| | EDICT2 (CEDICT) (.u8, .txt) | EDICT2 | [edict2.md](./edict2.md) | |
Owner
There was a problem hiding this comment.
Please remove .txt, many many formats are text files. We use extension to detect format for convenience. Tabfiles are the most generic and common.
Owner
|
Please don't mix changes to multiple plugins. |
Contributor
Author
|
I removed the changes to the html_dir plugin; I'll move them to a new PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add an option link_references to Edict2, which defaults to False. When set to True, any Chinese word found in a definition will link to the definition for that word. For example, the definition of 一塊兒 is "erhua variant of 一塊|一块[yi1 kuai4]"; this adds a link to the definition of 一塊.

I made a few small changes along the way. I added ".txt" as an extension for Edict2, since the dictionaries have been provided as txt files for years at this point. I also discovered a small bug in the HTML directory writer which didn't properly create links when the target was on the same page as the source. I removed two lines, which seems to fix it.
I tested this on the full CEdict word list as well as a smaller version included here:
cedict_sample_links_utf-8_mdbg.txt. When enabling the "link_references" option and using this file as input, there should be a link from the entry for "88" to the entry for "拜拜", and links back and forth between "新儒家" and "当代新儒家". When processing this file, all the entries will be on the same page, which is how I discovered that the HTML directory writer was creating broken links in this case.