@supermanzm/streamdown-cjk 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +34 -0
- package/dist/index.js +1 -0
- package/package.json +50 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Pluggable } from 'unified';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Plugin for CJK text handling
|
|
5
|
+
*/
|
|
6
|
+
interface CjkPlugin {
|
|
7
|
+
name: "cjk";
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated Use remarkPluginsBefore and remarkPluginsAfter instead
|
|
10
|
+
* All remark plugins (for backwards compatibility)
|
|
11
|
+
*/
|
|
12
|
+
remarkPlugins: Pluggable[];
|
|
13
|
+
/**
|
|
14
|
+
* Remark plugins that must run AFTER remarkGfm
|
|
15
|
+
* (e.g., autolink boundary splitting, strikethrough enhancements)
|
|
16
|
+
*/
|
|
17
|
+
remarkPluginsAfter: Pluggable[];
|
|
18
|
+
/**
|
|
19
|
+
* Remark plugins that must run BEFORE remarkGfm
|
|
20
|
+
* (e.g., remark-cjk-friendly which modifies emphasis handling)
|
|
21
|
+
*/
|
|
22
|
+
remarkPluginsBefore: Pluggable[];
|
|
23
|
+
type: "cjk";
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Create a CJK plugin
|
|
27
|
+
*/
|
|
28
|
+
declare function createCjkPlugin(): CjkPlugin;
|
|
29
|
+
/**
|
|
30
|
+
* Pre-configured CJK plugin with default settings
|
|
31
|
+
*/
|
|
32
|
+
declare const cjk: CjkPlugin;
|
|
33
|
+
|
|
34
|
+
export { type CjkPlugin, cjk, createCjkPlugin };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import c from'remark-cjk-friendly';import a from'remark-cjk-friendly-gfm-strikethrough';import {visit}from'unist-util-visit';var k=new Set(["\u3002","\uFF0E","\uFF0C","\u3001","\uFF1F","\uFF01","\uFF1A","\uFF1B","\uFF08","\uFF09","\u3010","\u3011","\u300C","\u300D","\u300E","\u300F","\u3008","\u3009","\u300A","\u300B"]),m=/^(https?:\/\/|mailto:|www\.)/i,f=t=>{if(t.children.length!==1)return false;let r=t.children[0];return r.type==="text"&&r.value===t.url},P=t=>{let r=0;for(let e of t){if(k.has(e))return r;r+=e.length;}return null},p=(t,r)=>({...r,url:t,children:[{type:"text",value:t}]}),d=t=>({type:"text",value:t}),y=()=>t=>{visit(t,"link",(r,e,i)=>{if(!i||typeof e!="number"||!f(r)||!m.test(r.url))return;let n=P(r.url);if(n===null||n===0)return;let l=r.url.slice(0,n),u=r.url.slice(n),o=p(l,r),s=d(u);return i.children.splice(e,1,o,s),e+1});};function b(){let t=[c],r=[y,a],e=[...t,...r];return {name:"cjk",type:"cjk",remarkPluginsBefore:t,remarkPluginsAfter:r,remarkPlugins:e}}var A=b();export{A as cjk,b as createCjkPlugin};
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@supermanzm/streamdown-cjk",
|
|
3
|
+
"version": "1.0.3",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsup",
|
|
19
|
+
"test": "vitest run",
|
|
20
|
+
"test:coverage": "vitest --coverage run"
|
|
21
|
+
},
|
|
22
|
+
"peerDependencies": {
|
|
23
|
+
"react": "^18.0.0 || ^19.0.0"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"remark-cjk-friendly": "^2.0.1",
|
|
27
|
+
"remark-cjk-friendly-gfm-strikethrough": "^2.0.1",
|
|
28
|
+
"unist-util-visit": "^5.0.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/mdast": "^4.0.4",
|
|
32
|
+
"@vitest/coverage-v8": "^4.0.15",
|
|
33
|
+
"@types/unist": "^3.0.3",
|
|
34
|
+
"remark-gfm": "^4.0.1",
|
|
35
|
+
"remark-parse": "^11.0.0",
|
|
36
|
+
"remark-stringify": "^11.0.0",
|
|
37
|
+
"tsup": "^8.5.1",
|
|
38
|
+
"typescript": "^5.9.3",
|
|
39
|
+
"unified": "^11.0.5",
|
|
40
|
+
"vitest": "^4.0.15"
|
|
41
|
+
},
|
|
42
|
+
"author": "Hayden Bleasel <hayden.bleasel@vercel.com>",
|
|
43
|
+
"license": "Apache-2.0",
|
|
44
|
+
"description": "CJK text handling plugin for Streamdown",
|
|
45
|
+
"repository": {
|
|
46
|
+
"type": "git",
|
|
47
|
+
"url": "git+https://github.com/vercel/streamdown.git",
|
|
48
|
+
"directory": "packages/streamdown-cjk"
|
|
49
|
+
}
|
|
50
|
+
}
|