Skip to content

Edict2: add option to create links from references to other words#679

Merged
ilius merged 7 commits into
ilius:masterfrom
benfl:add-links
Oct 13, 2025
Merged

Edict2: add option to create links from references to other words#679
ilius merged 7 commits into
ilius:masterfrom
benfl:add-links

Conversation

@benfl

@benfl benfl commented Oct 13, 2025

Copy link
Copy Markdown
Contributor

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 一塊.
yikuair

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.

Comment thread doc/p/__index__.md Outdated
| 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) |

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove .txt, many many formats are text files. We use extension to detect format for convenience. Tabfiles are the most generic and common.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

@ilius

ilius commented Oct 13, 2025

Copy link
Copy Markdown
Owner

Please don't mix changes to multiple plugins.
Move it to a different PR.

@benfl

benfl commented Oct 13, 2025

Copy link
Copy Markdown
Contributor Author

I removed the changes to the html_dir plugin; I'll move them to a new PR.

@ilius ilius merged commit 7bd59e8 into ilius:master Oct 13, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants