{"id":20419361,"url":"https://github.com/xsynaptic/rehype-wrap-cjk","last_synced_at":"2025-09-24T06:32:06.816Z","repository":{"id":218538119,"uuid":"733981792","full_name":"xsynaptic/rehype-wrap-cjk","owner":"xsynaptic","description":"Rehype plugin for wrapping CJK character sequences","archived":false,"fork":false,"pushed_at":"2025-09-08T13:25:55.000Z","size":467,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-08T15:26:43.159Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xsynaptic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-12-20T15:24:01.000Z","updated_at":"2025-09-08T13:26:00.000Z","dependencies_parsed_at":"2025-09-08T15:13:40.884Z","dependency_job_id":null,"html_url":"https://github.com/xsynaptic/rehype-wrap-cjk","commit_stats":null,"previous_names":["xsynaptic/rehype-wrap-cjk"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/xsynaptic/rehype-wrap-cjk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xsynaptic%2Frehype-wrap-cjk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xsynaptic%2Frehype-wrap-cjk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xsynaptic%2Frehype-wrap-cjk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xsynaptic%2Frehype-wrap-cjk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xsynaptic","download_url":"https://codeload.github.com/xsynaptic/rehype-wrap-cjk/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xsynaptic%2Frehype-wrap-cjk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276707582,"owners_count":25690052,"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","status":"online","status_checked_at":"2025-09-24T02:00:09.776Z","response_time":97,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-11-15T06:36:42.758Z","updated_at":"2025-09-24T06:32:06.521Z","avatar_url":"https://github.com/xsynaptic.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rehype-wrap-cjk\n\nThis package is a [unified][]/[rehype][] plugin to wrap [CJK character][cjk-wiki] sequences in an element (defaulting to `span`) with a `lang` attribute, useful for applying different CSS styling rules in multilingual contexts.\n\nNote: this plugin is distributed in ESM and CJS.\n\n## Install\n\n```sh\nnpm install rehype-wrap-cjk\n```\n\n## Use\n\nA typical pipeline transforming Markdown into HTML with [remark][] and [rehype][]:\n\n```ts\nimport rehypeSanitize from 'rehype-sanitize';\nimport rehypeStringify from 'rehype-stringify';\nimport rehypeCjkWrap from 'rehype-wrap-cjk';\nimport remarkParse from 'remark-parse';\nimport remarkRehype from 'remark-rehype';\nimport { unified } from 'unified';\n\nexport function processMarkdown(markdownContent: string): string {\n\tconst htmlOutput = unified()\n\t\t.use(remarkParse)\n\t\t.use(remarkRehype)\n\t\t.use(rehypeCjkWrap)\n\t\t.use(rehypeSanitize)\n\t\t.use(rehypeStringify)\n\t\t.processSync(markdownContent);\n\n\treturn String(htmlOutput);\n}\n```\n\nExample plain text input:\n\n```text\nSample text with CJK characters (中日韓字符) interspersed. 中文 can appear anywhere in the text and will be appropriately wrapped.\n```\n\nExample HTML output: \n\n```html\nSample text with CJK characters (\u003cspan lang=\"zh\"\u003e中日韓字符\u003c/span\u003e) interspersed. \u003cspan lang=\"zh\"\u003e中文\u003c/span\u003e can appear anywhere in the text and will be appropriately wrapped.\n```\n\nExample CSS rules (for you to implement in your own projects):\n\n```css\nhtml:not([lang^='zh']) span[lang^='zh'] {\n\tfont-style: normal !important;\n\ttext-decoration: none !important;\n\tword-break: keep-all !important;\n}\n```\n\n## Reference\n\n- [CJK Unified Ideographs][cjk-unified-ideographs]\n- [CJK Ideographs in Unicode][cjk-ideographs-in-unicode]\n- [Halfwidth and Fullwidth Forms][halfwidth-and-fullwidth-forms]\n- [HTMLElement lang property][html-element-lang-property]\n- [word-break CSS property][wordbreak-css-property]\n\n## License\n\n[MIT][mit-license]\n\n[cjk-wiki]: https://en.wikipedia.org/wiki/CJK_characters\n\n[cjk-unified-ideographs]: https://en.wikipedia.org/wiki/CJK_Unified_Ideographs\n\n[cjk-ideographs-in-unicode]: https://en.wikipedia.org/wiki/Template:CJK_ideographs_in_Unicode\n\n[halfwidth-and-fullwidth-forms]: https://en.wikipedia.org/wiki/Halfwidth_and_Fullwidth_Forms_(Unicode_block)\n\n[html-element-lang-property]: https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/lang\n\n[mit-license]: https://opensource.org/licenses/MIT\n\n[rehype]: https://github.com/rehypejs/rehype\n\n[remark]: https://github.com/remarkjs/remark\n\n[unified]: https://github.com/unifiedjs/unified\n\n[wordbreak-css-property]: https://developer.mozilla.org/en-US/docs/Web/CSS/word-break","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxsynaptic%2Frehype-wrap-cjk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxsynaptic%2Frehype-wrap-cjk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxsynaptic%2Frehype-wrap-cjk/lists"}