{"id":15013605,"url":"https://github.com/terasum/js-mdict","last_synced_at":"2025-05-16T12:07:01.777Z","repository":{"id":29738994,"uuid":"122514112","full_name":"terasum/js-mdict","owner":"terasum","description":"*.mdx/*.mdd interpreter js implements, support mdict index file","archived":false,"fork":false,"pushed_at":"2025-03-15T09:32:57.000Z","size":1988,"stargazers_count":167,"open_issues_count":3,"forks_count":19,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-12T06:15:39.216Z","etag":null,"topics":["dictionary","es6","glodendict","javascript","mdd","mdict","mdx","npm-package"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/terasum.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-02-22T17:51:43.000Z","updated_at":"2025-04-04T10:12:37.000Z","dependencies_parsed_at":"2023-01-14T15:45:21.697Z","dependency_job_id":"3eba9cb1-2303-42c4-a243-7f5cacaeeb65","html_url":"https://github.com/terasum/js-mdict","commit_stats":{"total_commits":114,"total_committers":5,"mean_commits":22.8,"dds":"0.17543859649122806","last_synced_commit":"9e75236725aad5a1edca9fff428c79ea16ca108c"},"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terasum%2Fjs-mdict","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terasum%2Fjs-mdict/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terasum%2Fjs-mdict/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terasum%2Fjs-mdict/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/terasum","download_url":"https://codeload.github.com/terasum/js-mdict/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248525138,"owners_count":21118619,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dictionary","es6","glodendict","javascript","mdd","mdict","mdx","npm-package"],"created_at":"2024-09-24T19:44:33.610Z","updated_at":"2025-04-12T06:15:52.834Z","avatar_url":"https://github.com/terasum.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# js-mdict\n\n[![npm version](https://badge.fury.io/js/js-mdict.svg)](https://badge.fury.io/js/js-mdict)\n[![GitHub issues](https://img.shields.io/github/issues/terasum/js-mdict.svg)](https://github.com/terasum/js-mdict/issues)\n[![GitHub forks](https://img.shields.io/github/forks/terasum/js-mdict.svg)](https://github.com/terasum/js-mdict/network)\n[![GitHub stars](https://img.shields.io/github/stars/terasum/js-mdict.svg)](https://github.com/terasum/js-mdict/stargazers)\n[![GitHub license](https://img.shields.io/github/license/terasum/js-mdict.svg)](https://github.com/terasum/js-mdict/blob/develop/LICENSE)\n\nmdict (\\*.mdd \\*.mdx) file reader based on [jeka-kiselyov/mdict](https://github.com/jeka-kiselyov/mdict) .\n\nThanks to [fengdh](https://github.com/fengdh/mdict-js) and [jeka-kiselyov](https://github.com/jeka-kiselyov/mdict).\n\n## Latest Version\n\nv6.0.7 (2025-03-15)\n\n## Usage\n\n```bash\nnpm install js-mdict\n```\n\n### ESM\n\n```javascript\nimport { MDX } from \"js-mdict\";\n\nconst mdict = new MDX(\"resources/oald7.mdx\");\n\nconst def = mdict.lookup(\"ask\");\nconsole.log(def.definition);\n\n\n/*\n\u003chead\u003e\u003clink rel=\"stylesheet\" type=\"text/css\" href=\"O7.css\"/\u003e\u003c/head\u003e\u003cbody\u003e\u003cspan class=\"hw\"\u003e ask \u003c/span hw\u003e\u003cspan class=\"i_g\"\u003e \u003cimg src=\"key.gif\"/\u003e  /\u003ca class=\"i_phon\" href=\"sound://aask_ggv_r1_oa013910.spx\"\u003eɑ:sk\u003c/a i_phon\u003e\u003cspan class=\"z\"\u003e; \u003c/span z\u003e\u003ci\u003eNAmE\u003c/i\u003e \u003ca class=\"y_phon\" href=\"sound://aask_ggx_r1_wpu01057.spx\"\u003eæsk\u003c/a y_phon\u003e​/ \u003c/span i_g\u003e\u003cspan class=\"cls\"\u003e verb\u003c/span cls\u003e\u003cbr\u003e\u003cspan class=\"sd\"\u003eQUESTION\u003cspan class=\"chn\"\u003e 问题\u003c/span chn\u003e\u003c/span sd\u003e\n\u003cdiv class=\"define\"\u003e\u003cspan class=\"numb\"\u003e1\u003c/span numb\u003e\u003cspan class=\"cf\"\u003e ~ \u003cspan class=\"bra\"\u003e(\u003c/span bra\u003esb\u003cspan class=\"bra\"\u003e)\u003c/span bra\u003e \u003cspan class=\"bra\"\u003e(\u003c/span bra\u003eabout sb/ sth\u003cspan class=\"bra\"\u003e)\u003c/span bra\u003e \u003c/span cf\u003e\u003cspan class=\"d\"\u003eto say or write sth in the form of a question, in order to get information\u003cspan class=\"chn\"\u003e 问；询问\u003c/span chn\u003e\u003c/span d\u003e\u003c/div define\u003e\n\u003cspan class=\"phrase\"\u003e\u003cspan class=\"pt\"\u003e  [\u003cspan class=\"pt_inside\"\u003eV \u003cspan class=\"pt_bold\"\u003espeech\u003c/span\u003e\u003c/span\u003e\u003cspan\u003e]\u003c/span\u003e \u003c/span pt\u003e\u003c/span phrase\u003e\n\u003cspan class=\"sentence_eng\"\u003e'Where are you going?' she asked. \u003c/span sentence_eng\u003e\n\u003cspan class=\"sentence_chi\"\u003e\"你去哪里？\"她问道。\u003c/span sentence_chi\u003e\n\u003cspan class=\"phrase\"\u003e\u003cspan class=\"pt\"\u003e [\u003cspan class=\"pt_inside\"\u003eVN \u003cspan class=\"pt_bold\"\u003espeech\u003c/span\u003e\u003c/span\u003e\u003cspan\u003e]\u003c/span\u003e \u003c/span pt\u003e\u003c/span phrase\u003e\n\u003cspan class=\"sentence_eng\"\u003e'Are you sure?' he asked her. \u003c/span sentence_eng\u003e\n...\n\u003c/body\u003e\n  */\nimport { MDD } from '../dist/cjs/index.js';\n\nconst mdx = new MDD('./tests/data/oale8.mdd');\nconsole.log(mdx.locate('\\\\Logo.jpg'));\n\n/*\n$ git clone github.com/terasum/js-mdict\n$ cd js-mdict\n$ npx tsx ./example/oale8-mdd-example.ts\n\nNOTE: the mdd's definition is base64 encoded bytes, \nif your target is css/js content, please decode base64 and get the original text\nif your target is images, you can use dataurl to show the images\n\n{\n  keyText: '\\\\Logo.jpg',\n  definition: '/9j/4AAQSkZJRgABAgAAAQABAAD//gAEKgD/4gIcSUNDX1BST0ZJTEUAAQEAAAIMbGNtcwIQ...'\n }\n*/\n\n\n```\n\n### CommonJS\n\n```javascript\nconst { MDX } = require('js-mdict');\n\nconst mdict = new MDX('resources/oald7.mdx');\n\nconst def = mdict.lookup('ask');\nconsole.log(def.definition);\n\n/*\n\u003chead\u003e\u003clink rel=\"stylesheet\" type=\"text/css\" href=\"O7.css\"/\u003e\u003c/head\u003e\u003cbody\u003e\u003cspan class=\"hw\"\u003e ask \u003c/span hw\u003e\u003cspan class=\"i_g\"\u003e \u003cimg src=\"key.gif\"/\u003e  /\u003ca class=\"i_phon\" href=\"sound://aask_ggv_r1_oa013910.spx\"\u003eɑ:sk\u003c/a i_phon\u003e\u003cspan class=\"z\"\u003e; \u003c/span z\u003e\u003ci\u003eNAmE\u003c/i\u003e \u003ca class=\"y_phon\" href=\"sound://aask_ggx_r1_wpu01057.spx\"\u003eæsk\u003c/a y_phon\u003e​/ \u003c/span i_g\u003e\u003cspan class=\"cls\"\u003e verb\u003c/span cls\u003e\u003cbr\u003e\u003cspan class=\"sd\"\u003eQUESTION\u003cspan class=\"chn\"\u003e 问题\u003c/span chn\u003e\u003c/span sd\u003e\n\u003cdiv class=\"define\"\u003e\u003cspan class=\"numb\"\u003e1\u003c/span numb\u003e\u003cspan class=\"cf\"\u003e ~ \u003cspan class=\"bra\"\u003e(\u003c/span bra\u003esb\u003cspan class=\"bra\"\u003e)\u003c/span bra\u003e \u003cspan class=\"bra\"\u003e(\u003c/span bra\u003eabout sb/ sth\u003cspan class=\"bra\"\u003e)\u003c/span bra\u003e \u003c/span cf\u003e\u003cspan class=\"d\"\u003eto say or write sth in the form of a question, in order to get information\u003cspan class=\"chn\"\u003e 问；询问\u003c/span chn\u003e\u003c/span d\u003e\u003c/div define\u003e\n\u003cspan class=\"phrase\"\u003e\u003cspan class=\"pt\"\u003e  [\u003cspan class=\"pt_inside\"\u003eV \u003cspan class=\"pt_bold\"\u003espeech\u003c/span\u003e\u003c/span\u003e\u003cspan\u003e]\u003c/span\u003e \u003c/span pt\u003e\u003c/span phrase\u003e\n\u003cspan class=\"sentence_eng\"\u003e'Where are you going?' she asked. \u003c/span sentence_eng\u003e\n\u003cspan class=\"sentence_chi\"\u003e\"你去哪里？\"她问道。\u003c/span sentence_chi\u003e\n\u003cspan class=\"phrase\"\u003e\u003cspan class=\"pt\"\u003e [\u003cspan class=\"pt_inside\"\u003eVN \u003cspan class=\"pt_bold\"\u003espeech\u003c/span\u003e\u003c/span\u003e\u003cspan\u003e]\u003c/span\u003e \u003c/span pt\u003e\u003c/span phrase\u003e\n\u003cspan class=\"sentence_eng\"\u003e'Are you sure?' he asked her. \u003c/span sentence_eng\u003e\n...\n\u003c/body\u003e\n  */\n```\n\n### Command Line\n\n``` bash\nnpm install -g js-mdict\n\n\u003e js-mdict ~/Downloads/uu89ug_folder/大辞泉202304.mdx 新語      \n\u003e \u003chead\u003e\u003cmeta charset=\"utf-8\"\u003e\u003clink rel=\"stylesheet\" type=\"text/css\" href=\"srej.css\"\u003e\u003cscript src=\"srej.js\"\u003e\u003c/script\u003e\u003c/head\u003e\u003csrejm class=\"srejm\"\u003e☞\u003ca href=\"entry://しんご【新語】\"\u003eしんご【新語】\u003c/a\u003e\u003chr/\u003e☞\u003ca href=\"entry://しんご【新語】［書名］\"\u003eしんご【新語】［書名］\u003c/a\u003e\u003c/srejm\u003e\n\n\u003e js-mdict ~/Downloads/uu89ug_folder/大辞泉202304.mdd \\\\srej.css\n\u003e dGFibGUuc3JlansgbWFyZ2luOjAgYXV0bztib3JkZXItY29sbGFwc2U6Y29sbGFwc2U7Ym9yZGVyLXN0eWxlOmhpZGRlbiB9DQp0...(total: 3976.97265625 KB)\n```\n\n## Benchmark\n\n```angular2html\nMdict#loading time: 0 sec\nMdict#lookup x 20,288 ops/sec ±0.44% (93 runs sampled)\nMdict#prefix x 3,279 ops/sec ±17.69% (92 runs sampled)\nMdict#associate x 6,436 ops/sec ±0.40% (98 runs sampled)\nMdict#loadDict\naverage load time:0.0522899 s\nMdict#decodeRecordBlock\naverage decode time:0.19147 s\n```\n## Tested Passed Dictionaries\n\n| File Path | Title | Version | Encoding | 'arose' Definition's Length |\n| --------- | ----- | ------- | -------- | --------------------------- |\n|dict-01-袖珍葡汉汉葡词典(简体版).mdx|Title (No HTML code allowed)|2.0|UTF-16|181|\n|dict-02-红葡汉词典.mdx|Title (No HTML code allowed)|2.0|UTF-16|135|\n|dict-03-ptDict_KeyCaseSensitive.mdx|Title (No HTML code allowed)|2.0|UTF-16|207|\n|new-oxford-en-ch-dict.mdx|新牛津英汉双解大词典|2.0|UTF-8|285|\n|oald7.mdx|Oxford Advanced Learner\u0026apos;s Dictionary 7th|1.2|UTF-8|220|\n|oale8.mdd|OALECD8e|2.0||1513|\n|oale8.mdx||2.0|UTF-8|1549|\n|Collins COBUILD Advanced Learner's English-Chinese Dictionary.mdd|柯林斯高阶英汉双解学习词典|2.0||13014|\n|Collins COBUILD Advanced Learner's English-Chinese Dictionary.mdx|Collins COBUILD Advanced Learner\u0026apos;s English-Chinese Dictionary|1.2|UTF-8|495|\n|Oxford Advanced Learner's Dictionary 7th.mdd|O7|2.0||2295|\n|Oxford Advanced Learner's Dictionary 7th.mdx|Oxford Advanced Learner\u0026apos;s Dictionary 7th|1.2|UTF-8|220|\n|The American Heritage Dictionary of English Language.mdd|undefined|1.2|undefined|1141|\n|The American Heritage Dictionary of English Language.mdx|The American Heritage Dictionary of English Language|1.2|UTF-16|1823|\n|Macmillan English Dictionary.mdd|Macmillan English Dictionary|2.0||44697|\n|Macmillan English Dictionary.mdx|Macmillan English Dictionary|2.0|UTF-8|517|\n|Oxford Collocations Dictionary for students of English 2nd.mdd|Oxford Collocations Dictionary for students of English|2.0||43791|\n|Oxford Collocations Dictionary for students of English 2nd.mdx|Oxford Collocations Dictionary for students of English|2.0|UTF-8|386|\n|Oxford Dictionary of English 2005 2nd.mdx|Oxford Dictionary of English|2.0|UTF-8|1081|\n|Vocabulary.com Dictionary.mdd|Vocabulary.com Dictionary|2.0||145|\n|Vocabulary.com Dictionary.mdx|Vocabulary.com Dictionary|2.0|UTF-8|2501|\n\n\n\n## Release\n\n### v6.0.6 (2025-01-06)\n1. fix mdd not found case bug\n\n### v6.0.5 (2025-01-04)\n1. fix fuzzy_word search method\n\n### v6.0.4 (2025-01-04)\n1. add example\n\n### v6.0.3 (2025-01-04)\n1. fix tests and benchmarks\n\n### v6.0.2\n\n1. implements with TypeScript\n2. fix some overflow bug\n3. resort the keyword order internally (may cost more memory), search word precisely\n\nBREAKING:\n1. the `Mdict` class don't provide the `lookup` method now, you should use `MDX/MDD` class \n\n## MDX/MDD Layout\n### v1.2-v2.0\n![layout](./docs/mdict-format.svg)\n\n\u003e this is from [@ikey4u/wikit](https://github.com/ikey4u/wikit)\n\n### v3.0\n![layout-v3.0](./docs/mdict-v3.0-format.svg)\n\n\u003e this is from [xwang/mdict-analysis](https://bitbucket.org/xwang/mdict-analysis/src/master/MDict3.svg)\n\ncode by terasum with ❤️\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fterasum%2Fjs-mdict","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fterasum%2Fjs-mdict","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fterasum%2Fjs-mdict/lists"}