{"_id":"@1-/mdtrim","_rev":"4-7578c6f464d6e142d68afc22dceaf35a","name":"@1-/mdtrim","dist-tags":{"latest":"0.1.3"},"versions":{"0.1.0":{"name":"@1-/mdtrim","version":"0.1.0","keywords":["markdown","localization","i18n","code-extraction","documentation"],"author":{"name":"x-at-01@googlegroups.com"},"license":"MulanPSL-2.0","_id":"@1-/mdtrim@0.1.0","maintainers":[{"name":"i18n-now","email":"i18n.site@gmail.com"}],"homepage":"https://github.com/webc-site/npm/tree/main/mdtrim","bugs":{"url":"https://github.com/webc-site/npm/issues"},"dist":{"shasum":"bb92e886e953e0abb923d7c76e26565252d041ab","tarball":"https://registry.npmjs.org/@1-/mdtrim/-/mdtrim-0.1.0.tgz","fileCount":42,"integrity":"sha512-WtS2IVYEBKo504UNHPZdzR2L4IgaVUPIE3fDzlMSZVKU0Fx1KxVM/pTLFdcDM7n2+6OqVjFPU4OsA8RkX1IANA==","signatures":[{"sig":"MEQCIGeQjOa1kelOw26djbpt5t1hsaHpc2wSWvUkB8RdngHRAiAbjwFtGY7VYw9u4Dyqi4LdSXhvOfJEen9usE/M4hMxmg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":41907},"type":"module","exports":{"./*":"./*"},"_npmUser":{"name":"i18n-now","email":"i18n.site@gmail.com"},"repository":{"url":"git+https://github.com/webc-site/npm.git","type":"git"},"_npmVersion":"11.16.0","description":"Extract translatable content from Markdown code blocks. 从 Markdown 代码块中提取可翻译内容","directories":{},"_nodeVersion":"26.2.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/mdtrim_0.1.0_1781211523354_0.14967253823487892","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@1-/mdtrim","version":"0.1.1","keywords":["code-extraction","documentation","i18n","localization","markdown"],"author":{"name":"x-at-01@googlegroups.com"},"license":"MulanPSL-2.0","_id":"@1-/mdtrim@0.1.1","maintainers":[{"name":"i18n-now","email":"i18n.site@gmail.com"}],"homepage":"https://github.com/webc-site/npm/tree/main/mdtrim","bugs":{"url":"https://github.com/webc-site/npm/issues"},"dist":{"shasum":"65de5cce8c6aeba1a28c4b63cd083b5ee7c5e6be","tarball":"https://registry.npmjs.org/@1-/mdtrim/-/mdtrim-0.1.1.tgz","fileCount":42,"integrity":"sha512-BSIkAOrp8U9SjpQHxKgfqMG9GRytcHzA3H1EHSFZWrzOk2UfnKrCZI0tjB9U4UFMqyuc6156Tx3cn8qV3genyA==","signatures":[{"sig":"MEUCIEmpxDdexXzkfNRPHZLeBX6BCQiMjla5K6um3BPfOHm/AiEAgbXPyCSWDACrwYyIFRkSfQven9hoKVlbtIe2jmNu82M=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":41539},"type":"module","exports":{"./*":"./*"},"_npmUser":{"name":"i18n-now","email":"i18n.site@gmail.com"},"repository":{"url":"git+https://github.com/webc-site/npm.git","type":"git"},"_npmVersion":"11.16.0","description":"Extract translatable content from Markdown code blocks. 从 Markdown 代码块中提取可翻译内容","directories":{},"_nodeVersion":"26.2.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/mdtrim_0.1.1_1781213538210_0.7912449763836638","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@1-/mdtrim","version":"0.1.2","keywords":["markdown","translation","localization","i18n","text-extraction"],"author":{"name":"x-at-01@googlegroups.com"},"license":"MulanPSL-2.0","_id":"@1-/mdtrim@0.1.2","maintainers":[{"name":"i18n-now","email":"i18n.site@gmail.com"}],"homepage":"https://github.com/webc-site/npm/tree/main/mdtrim","bugs":{"url":"https://github.com/webc-site/npm/issues"},"dist":{"shasum":"7b8f6cec3bb592246ecdc805788bce2125f372d0","tarball":"https://registry.npmjs.org/@1-/mdtrim/-/mdtrim-0.1.2.tgz","fileCount":10,"integrity":"sha512-ScK+qxOKDomrvroVSNyFGxWViVbWqwBtrMgytT9yNhl/6Wr6z56eKzHuhJ2y/tIaMnjZBgFcDDC/HMNDcRtVyQ==","signatures":[{"sig":"MEYCIQDQpXH5oVQuEw6g7f48yHgmcQoM+hZg38FBY8XvP0/5oAIhAOYgjYdGOAj48+yDlScU9LNAbY1WftbOLJbOf5LHG0/s","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":11790},"type":"module","exports":{"./*":"./*"},"_npmUser":{"name":"i18n-now","email":"i18n.site@gmail.com"},"repository":{"url":"git+https://github.com/webc-site/npm.git","type":"git"},"_npmVersion":"11.16.0","description":"Extract translatable text from Markdown while preserving structure for translation. Restore translated content into original Markdown format.","directories":{},"_nodeVersion":"26.2.0","dependencies":{"@1-/md":"^0.1.4"},"_hasShrinkwrap":false,"description_zh":"提取 Markdown 中可翻译文本同时保留结构以支持翻译。将翻译后的内容还原到原始 Markdown 格式中。","_npmOperationalInternal":{"tmp":"tmp/mdtrim_0.1.2_1781239859904_0.2595878427565992","host":"s3://npm-registry-packages-npm-production"}},"0.1.3":{"name":"@1-/mdtrim","version":"0.1.3","description":"Extract translatable text from Markdown while preserving structure for translation. Restore translated content into original Markdown format.","description_zh":"提取 Markdown 中可翻译文本同时保留结构以支持翻译。将翻译后的内容还原到原始 Markdown 格式中。","keywords":["markdown","translation","localization","i18n","text-extraction"],"homepage":"https://github.com/webc-site/npm/tree/main/mdtrim","license":"MulanPSL-2.0","author":{"name":"x-at-01@googlegroups.com"},"repository":{"type":"git","url":"git+https://github.com/webc-site/npm.git"},"type":"module","exports":{"./*":"./*"},"dependencies":{"@1-/md":"^0.1.4"},"_id":"@1-/mdtrim@0.1.3","bugs":{"url":"https://github.com/webc-site/npm/issues"},"_nodeVersion":"26.2.0","_npmVersion":"11.16.0","dist":{"integrity":"sha512-ws88JWsdoaMoLMNY9hREWX1cJocWtrXKRMhSev3sXWbDFyfdw8RxtZHycxCFBq0XA4y5n9grq6chVygcbk5TOA==","shasum":"d02068c556224518eac646369b7a0c9ff0ed1e55","tarball":"https://registry.npmjs.org/@1-/mdtrim/-/mdtrim-0.1.3.tgz","fileCount":10,"unpackedSize":11964,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCpNVSw7IW7Az3h1kRmMZuoo5mn8M/bj0z/c+UX8jmYeAIhAKqiv8BZ1OkFFlK48FQry0XAwhxJ03HuGgzcw0/E9oJA"}]},"_npmUser":{"name":"i18n-now","email":"i18n.site@gmail.com"},"directories":{},"maintainers":[{"name":"i18n-now","email":"i18n.site@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/mdtrim_0.1.3_1781240019954_0.5173307236950613"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-11T20:58:43.239Z","modified":"2026-06-12T04:53:40.185Z","0.1.0":"2026-06-11T20:58:43.483Z","0.1.1":"2026-06-11T21:32:18.407Z","0.1.2":"2026-06-12T04:51:00.040Z","0.1.3":"2026-06-12T04:53:40.079Z"},"bugs":{"url":"https://github.com/webc-site/npm/issues"},"author":{"name":"x-at-01@googlegroups.com"},"license":"MulanPSL-2.0","homepage":"https://github.com/webc-site/npm/tree/main/mdtrim","keywords":["markdown","translation","localization","i18n","text-extraction"],"repository":{"type":"git","url":"git+https://github.com/webc-site/npm.git"},"description":"Extract translatable text from Markdown while preserving structure for translation. Restore translated content into original Markdown format.","maintainers":[{"name":"i18n-now","email":"i18n.site@gmail.com"}],"readme":"[English](#en) | [中文](#zh)\n\n---\n\n<a id=\"en\"></a>\n# @1-/mdtrim : Extract and restore Markdown text for translation\n\n- [@1-/mdtrim : Extract and restore Markdown text for translation](#1-mdtrim-extract-and-restore-markdown-text-for-translation)\n  - [Functionality](#functionality)\n  - [Usage demonstration](#usage-demonstration)\n  - [Design rationale](#design-rationale)\n  - [Technology stack](#technology-stack)\n  - [Code structure](#code-structure)\n  - [Historical context](#historical-context)\n  - [About](#about)\n\n## Functionality\nExtract translatable text from Markdown while preserving structural prefixes (headers, lists, quotes). Enable content-structure separation for translation, then accurately restore original formatting.\n\n## Usage demonstration\nInstall:\n```bash\nnpm install @1-/mdtrim\n```\n\nExtract text for translation:\n```javascript\nimport mdE from '@1-/mdtrim/src/mdE.js';\n\nconst markdown = '# Header\\n\\nParagraph with **bold** text.\\n\\n- List item\\n- Another item';\nconst [textToTranslate, restoreConfig] = mdE(markdown);\n// textToTranslate = ['Header', 'Paragraph with **bold** text.', 'List item', 'Another item']\n// restoreConfig = [templateTextList, positionMappingList]\n```\n\nRestore translated text:\n```javascript\nimport mdD from '@1-/mdtrim/src/mdD.js';\n\nconst translatedText = ['标题', '带有**粗体**文本的段落。', '列表项', '另一项'];\nconst restoredMarkdown = mdD(translatedText, restoreConfig);\n```\n\n## Design rationale\nUse prefix recognition to separate content from structure. Parse structural prefixes per line (# headers, - lists, > quotes, 1. numbered lists, [x] checkboxes), extract translatable content, and maintain position mapping for precise restoration.\n\n![](https://fastly.jsdelivr.net/gh/webc-fs/-@x7/ANXIRP6hYcDjSs1mM8SQ.svg)\n\n## Technology stack\n- JavaScript (ES modules)\n- Node.js runtime\n- Dependency: @1-/md for Markdown line splitting\n\n## Code structure\n```\nsrc/\n├── mdE.js          # Markdown extractor - separates content from structural prefixes\n├── mdD.js          # Markdown restorer - reconstructs format using position mapping\n└── E/              # Extraction logic\n    ├── rule.js     # Line prefix parsing (headers, lists, quotes, numbered lists, checkboxes)\n    └── lib/        # Helper utilities\n        ├── ascii.js      # ASCII character detection\n        ├── spaceSkip.js  # Skip whitespace characters\n        ├── isSpace.js    # Space character detection\n        ├── charSkip.js   # Skip specific characters\n        └── digitsSkip.js # Skip digit sequences\n```\n\n## Historical context\nMarkdown was created by John Gruber in 2004 to enable plain-text formatting that could be easily converted to HTML. As global content distribution increased, tools emerged to support multilingual translation while preserving document structure integrity. mdtrim addresses this challenge through prefix recognition technology, demonstrating the intersection of text processing, internationalization, and software engineering.\n\n## About\n\nThis library is developed by [WebC.site](https://webc.site).\n\n[WebC.site](https://webc.site): A new paradigm of web development for AI\n\n\n---\n\n<a id=\"zh\"></a>\n# @1-/mdtrim : 提取并还原 Markdown 文本以支持翻译\n\n- [@1-/mdtrim : 提取并还原 Markdown 文本以支持翻译](#1-mdtrim-提取并还原-markdown-文本以支持翻译)\n  - [功能介绍](#功能介绍)\n  - [使用演示](#使用演示)\n  - [设计思路](#设计思路)\n  - [技术栈](#技术栈)\n  - [代码结构](#代码结构)\n  - [历史故事](#历史故事)\n  - [关于](#关于)\n\n## 功能介绍\n提取 Markdown 中可翻译文本，同时保留结构前缀（标题、列表、引用等）。支持将内容与结构分离，便于翻译后准确还原原始格式。\n\n## 使用演示\n安装：\n```bash\nnpm install @1-/mdtrim\n```\n\n提取文本用于翻译：\n```javascript\nimport mdE from '@1-/mdtrim/src/mdE.js';\n\nconst markdown = '# 标题\\n\\n包含**粗体**文本的段落。\\n\\n- 列表项\\n- 另一项';\nconst [待翻译文本, 还原配置] = mdE(markdown);\n// 待翻译文本 = ['标题', '包含**粗体**文本的段落。', '列表项', '另一项']\n// 还原配置 = [文本模板列表, 待翻译文本位置列表]\n```\n\n还原翻译后的文本：\n```javascript\nimport mdD from '@1-/mdtrim/src/mdD.js';\n\nconst 翻译后文本 = ['Header', 'Paragraph with **bold** text.', 'List item', 'Another item'];\nconst 还原后Markdown = mdD(翻译后文本, 还原配置);\n```\n\n## 设计思路\n采用前缀识别策略分离内容与结构。解析每行 Markdown 的结构前缀（# 标题、- 列表、> 引用、1. 编号列表、[x] 复选框），提取可翻译内容，维护位置映射确保精确还原。\n\n![](https://fastly.jsdelivr.net/gh/webc-fs/-@kt/EmtYHWx1iQ3JiP0qR-vg.svg)\n\n## 技术栈\n- JavaScript（ES 模块）\n- Node.js 运行时\n- 依赖：@1-/md 用于 Markdown 行分割\n\n## 代码结构\n```\nsrc/\n├── mdE.js          # Markdown 提取器 - 分离内容与结构前缀\n├── mdD.js          # Markdown 还原器 - 按位置映射重建格式\n└── E/              # 提取逻辑\n    ├── rule.js     # 行前缀解析（标题、列表、引用、编号、复选框）\n    └── lib/        # 辅助工具\n        ├── ascii.js      # ASCII 字符检测\n        ├── spaceSkip.js  # 跳过空白字符\n        ├── isSpace.js    # 空格字符检测\n        ├── charSkip.js   # 跳过特定字符\n        └── digitsSkip.js # 跳过数字序列\n```\n\n## 历史故事\nMarkdown 由 John Gruber 于 2004 年创建，旨在提供一种易于转换为 HTML 的纯文本格式化方法。随着全球化内容需求增长，出现了需要在保持文档结构完整性的同时支持多语言翻译的工具需求。mdtrim 通过前缀识别技术解决这一挑战，体现了文本处理、国际化和软件工程的交叉融合。\n\n## 关于\n\n本库由 [WebC.site](https://webc.site) 开发。\n\n[WebC.site](https://webc.site) : 面向人工智能的网站开发新范式\n\n","readmeFilename":"README.md"}