@xsynaptic/unified-tools 0.0.1
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/chunk-5RPJUYTO.js +2 -0
- package/dist/chunk-5RPJUYTO.js.map +1 -0
- package/dist/chunk-7QE4BXN4.js +2 -0
- package/dist/chunk-7QE4BXN4.js.map +1 -0
- package/dist/chunk-CDY2GI2P.js +2 -0
- package/dist/chunk-CDY2GI2P.js.map +1 -0
- package/dist/chunk-EGSAYCRK.js +2 -0
- package/dist/chunk-EGSAYCRK.js.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/sanitize-html.cjs +2 -0
- package/dist/sanitize-html.cjs.map +1 -0
- package/dist/sanitize-html.d.cts +6 -0
- package/dist/sanitize-html.d.ts +6 -0
- package/dist/sanitize-html.js +2 -0
- package/dist/sanitize-html.js.map +1 -0
- package/dist/stylize-text.cjs +2 -0
- package/dist/stylize-text.cjs.map +1 -0
- package/dist/stylize-text.d.cts +5 -0
- package/dist/stylize-text.d.ts +5 -0
- package/dist/stylize-text.js +2 -0
- package/dist/stylize-text.js.map +1 -0
- package/dist/transform-markdown.cjs +2 -0
- package/dist/transform-markdown.cjs.map +1 -0
- package/dist/transform-markdown.d.cts +3 -0
- package/dist/transform-markdown.d.ts +3 -0
- package/dist/transform-markdown.js +2 -0
- package/dist/transform-markdown.js.map +1 -0
- package/dist/wrap-cjk.cjs +2 -0
- package/dist/wrap-cjk.cjs.map +1 -0
- package/dist/wrap-cjk.d.cts +3 -0
- package/dist/wrap-cjk.d.ts +3 -0
- package/dist/wrap-cjk.js +2 -0
- package/dist/wrap-cjk.js.map +1 -0
- package/package.json +77 -0
- package/readme.md +4 -0
- package/src/__tests__/sanitize-html.test.ts +22 -0
- package/src/index.ts +5 -0
- package/src/sanitize-html.ts +25 -0
- package/src/stylize-text.ts +13 -0
- package/src/transform-markdown.ts +20 -0
- package/src/wrap-cjk.ts +16 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/stylize-text.ts"],"names":["stylizeText","input","options","output","retext","retextSmartypants"],"mappings":"8DAKO,SAASA,CAAAA,CACdC,CACAC,CAAAA,CAAAA,CACQ,CACR,IAAMC,EAASC,MAAO,EAAA,CAAE,GAAIC,CAAAA,CAAAA,CAAmBH,CAAO,CAAA,CAAE,WAAYD,CAAAA,CAAK,CAEzE,CAAA,OAAO,MAAOE,CAAAA,CAAM,CACtB","file":"chunk-5RPJUYTO.js","sourcesContent":["import { retext } from 'retext';\nimport retextSmartypants from 'retext-smartypants';\n\nimport type { Options as RetextSmartypantsOptions } from 'retext-smartypants';\n\nexport function stylizeText(\n input: string,\n options?: RetextSmartypantsOptions\n): string {\n const output = retext().use(retextSmartypants, options).processSync(input);\n\n return String(output);\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import r from'rehype-parse';import n from'rehype-sanitize';import p from'rehype-stringify';import {unified}from'unified';function o(t,e){let i=unified().use(r,{fragment:true}).use(n,e).use(p).processSync(t);return String(i)}var g=(t,e)=>o(t,{...e,tagNames:[]});export{o as a,g as b};//# sourceMappingURL=chunk-7QE4BXN4.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-7QE4BXN4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/sanitize-html.ts"],"names":["sanitizeHtml","input","options","output","unified","rehypeParse","rehypeSanitize","rehypeStringify","stripTags"],"mappings":"yHAOO,SAASA,EACdC,CACAC,CAAAA,CAAAA,CACQ,CACR,IAAMC,CAASC,CAAAA,OAAAA,EACZ,CAAA,GAAA,CAAIC,CAAa,CAAA,CAAE,QAAU,CAAA,IAAK,CAAC,CAAA,CACnC,IAAIC,CAAgBJ,CAAAA,CAAO,CAC3B,CAAA,GAAA,CAAIK,CAAe,CAAA,CACnB,WAAYN,CAAAA,CAAK,CAEpB,CAAA,OAAO,MAAOE,CAAAA,CAAM,CACtB,KAGaK,CAAY,CAAA,CACvBP,CACAC,CAAAA,CAAAA,GACWF,CAAaC,CAAAA,CAAAA,CAAO,CAAE,GAAGC,CAAS,CAAA,QAAA,CAAU,EAAG,CAAC","file":"chunk-7QE4BXN4.js","sourcesContent":["import rehypeParse from 'rehype-parse';\nimport rehypeSanitize from 'rehype-sanitize';\nimport rehypeStringify from 'rehype-stringify';\nimport { unified } from 'unified';\n\nimport type { Options as RehypeSanitizeOptions } from 'rehype-sanitize';\n\nexport function sanitizeHtml(\n input: string,\n options?: RehypeSanitizeOptions\n): string {\n const output = unified()\n .use(rehypeParse, { fragment: true })\n .use(rehypeSanitize, options)\n .use(rehypeStringify)\n .processSync(input);\n\n return String(output);\n}\n\n// Handy shortcut for when you just want to strip tags from text\nexport const stripTags = (\n input: string,\n options?: RehypeSanitizeOptions\n): string => sanitizeHtml(input, { ...options, tagNames: [] });\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import o from'rehype-sanitize';import t from'rehype-stringify';import m from'rehype-wrap-cjk';import i from'remark-parse';import p from'remark-rehype';import n from'remark-smartypants';import {unified}from'unified';function g(r){let e=unified().use(i).use(n).use(p).use(m).use(o).use(t).processSync(r);return String(e)}export{g as a};//# sourceMappingURL=chunk-CDY2GI2P.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-CDY2GI2P.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/transform-markdown.ts"],"names":["transformMarkdown","input","output","unified","remarkParse","remarkSmartyPants","remarkRehype","rehypeWrapCjk","rehypeSanitize","rehypeStringify"],"mappings":"uNAQO,SAASA,CAAkBC,CAAAA,CAAAA,CAAuB,CACvD,IAAMC,EAASC,OAAQ,EAAA,CACpB,GAAIC,CAAAA,CAAW,CACf,CAAA,GAAA,CAAIC,CAAiB,CACrB,CAAA,GAAA,CAAIC,CAAY,CAAA,CAChB,GAAIC,CAAAA,CAAa,EACjB,GAAIC,CAAAA,CAAc,CAClB,CAAA,GAAA,CAAIC,CAAe,CAAA,CACnB,WAAYR,CAAAA,CAAK,CAEpB,CAAA,OAAO,MAAOC,CAAAA,CAAM,CACtB","file":"chunk-CDY2GI2P.js","sourcesContent":["import rehypeSanitize from 'rehype-sanitize';\nimport rehypeStringify from 'rehype-stringify';\nimport rehypeWrapCjk from 'rehype-wrap-cjk';\nimport remarkParse from 'remark-parse';\nimport remarkRehype from 'remark-rehype';\nimport remarkSmartyPants from 'remark-smartypants';\nimport { unified } from 'unified';\n\nexport function transformMarkdown(input: string): string {\n const output = unified()\n .use(remarkParse)\n .use(remarkSmartyPants)\n .use(remarkRehype)\n .use(rehypeWrapCjk)\n .use(rehypeSanitize)\n .use(rehypeStringify)\n .processSync(input);\n\n return String(output);\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import t from'rehype-parse';import i from'rehype-sanitize';import o from'rehype-stringify';import p from'rehype-wrap-cjk';import {unified}from'unified';function a(r){let e=unified().use(t,{fragment:true}).use(p).use(i).use(o).processSync(r);return String(e)}export{a};//# sourceMappingURL=chunk-EGSAYCRK.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-EGSAYCRK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/wrap-cjk.ts"],"names":["wrapCjk","input","output","unified","rehypeParse","rehypeWrapCjk","rehypeSanitize","rehypeStringify"],"mappings":"wJAMO,SAASA,EAAQC,CAAuB,CAAA,CAC7C,IAAMC,CAASC,CAAAA,OAAAA,GACZ,GAAIC,CAAAA,CAAAA,CAAa,CAAE,QAAU,CAAA,IAAK,CAAC,CACnC,CAAA,GAAA,CAAIC,CAAa,CACjB,CAAA,GAAA,CAAIC,CAAc,CAClB,CAAA,GAAA,CAAIC,CAAe,CACnB,CAAA,WAAA,CAAYN,CAAK,CAEpB,CAAA,OAAO,MAAOC,CAAAA,CAAM,CACtB","file":"chunk-EGSAYCRK.js","sourcesContent":["import rehypeParse from 'rehype-parse';\nimport rehypeSanitize from 'rehype-sanitize';\nimport rehypeStringify from 'rehype-stringify';\nimport rehypeWrapCjk from 'rehype-wrap-cjk';\nimport { unified } from 'unified';\n\nexport function wrapCjk(input: string): string {\n const output = unified()\n .use(rehypeParse, { fragment: true })\n .use(rehypeWrapCjk)\n .use(rehypeSanitize)\n .use(rehypeStringify)\n .processSync(input);\n\n return String(output);\n}\n"]}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var i=require('rehype-parse'),p=require('rehype-sanitize'),n=require('rehype-stringify'),unified=require('unified'),retext=require('retext'),f=require('retext-smartypants'),S=require('rehype-wrap-cjk'),c=require('remark-parse'),x=require('remark-rehype'),h=require('remark-smartypants');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var i__default=/*#__PURE__*/_interopDefault(i);var p__default=/*#__PURE__*/_interopDefault(p);var n__default=/*#__PURE__*/_interopDefault(n);var f__default=/*#__PURE__*/_interopDefault(f);var S__default=/*#__PURE__*/_interopDefault(S);var c__default=/*#__PURE__*/_interopDefault(c);var x__default=/*#__PURE__*/_interopDefault(x);var h__default=/*#__PURE__*/_interopDefault(h);function o(r,t){let e=unified.unified().use(i__default.default,{fragment:true}).use(p__default.default,t).use(n__default.default).processSync(r);return String(e)}var m=(r,t)=>o(r,{...t,tagNames:[]});function u(r,t){let e=retext.retext().use(f__default.default,t).processSync(r);return String(e)}function k(r){let t=unified.unified().use(c__default.default).use(h__default.default).use(x__default.default).use(S__default.default).use(p__default.default).use(n__default.default).processSync(r);return String(t)}function w(r){let t=unified.unified().use(i__default.default,{fragment:true}).use(S__default.default).use(p__default.default).use(n__default.default).processSync(r);return String(t)}Object.defineProperty(exports,"defaultSchema",{enumerable:true,get:function(){return p.defaultSchema}});exports.sanitizeHtml=o;exports.stripTags=m;exports.stylizeText=u;exports.transformMarkdown=k;exports.wrapCjk=w;//# sourceMappingURL=index.cjs.map
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/sanitize-html.ts","../src/stylize-text.ts","../src/transform-markdown.ts","../src/wrap-cjk.ts"],"names":["sanitizeHtml","input","options","output","unified","rehypeParse","rehypeSanitize","rehypeStringify","stripTags","stylizeText","retext","retextSmartypants","transformMarkdown","remarkParse","remarkSmartyPants","remarkRehype","rehypeWrapCjk","wrapCjk"],"mappings":"quBAOO,SAASA,EACdC,CACAC,CAAAA,CAAAA,CACQ,CACR,IAAMC,CAAAA,CAASC,iBACZ,CAAA,GAAA,CAAIC,mBAAa,CAAE,QAAA,CAAU,IAAK,CAAC,CAAA,CACnC,IAAIC,kBAAgBJ,CAAAA,CAAO,EAC3B,GAAIK,CAAAA,kBAAe,EACnB,WAAYN,CAAAA,CAAK,EAEpB,OAAO,MAAA,CAAOE,CAAM,CACtB,CAGaK,IAAAA,CAAAA,CAAY,CACvBP,CAAAA,CACAC,IACWF,CAAaC,CAAAA,CAAAA,CAAO,CAAE,GAAGC,CAAAA,CAAS,SAAU,EAAG,CAAC,ECnBtD,SAASO,CACdR,CAAAA,CAAAA,CACAC,EACQ,CACR,IAAMC,EAASO,aAAO,EAAA,CAAE,IAAIC,kBAAmBT,CAAAA,CAAO,EAAE,WAAYD,CAAAA,CAAK,EAEzE,OAAO,MAAA,CAAOE,CAAM,CACtB,CCJO,SAASS,CAAkBX,CAAAA,CAAAA,CAAuB,CACvD,IAAME,CAAAA,CAASC,iBACZ,CAAA,GAAA,CAAIS,kBAAW,CACf,CAAA,GAAA,CAAIC,kBAAiB,CACrB,CAAA,GAAA,CAAIC,kBAAY,CAChB,CAAA,GAAA,CAAIC,kBAAa,CACjB,CAAA,GAAA,CAAIV,kBAAc,CAClB,CAAA,GAAA,CAAIC,kBAAe,CACnB,CAAA,WAAA,CAAYN,CAAK,CAEpB,CAAA,OAAO,OAAOE,CAAM,CACtB,CCbO,SAASc,CAAAA,CAAQhB,EAAuB,CAC7C,IAAME,EAASC,eAAQ,EAAA,CACpB,IAAIC,kBAAa,CAAA,CAAE,SAAU,IAAK,CAAC,EACnC,GAAIW,CAAAA,kBAAa,EACjB,GAAIV,CAAAA,kBAAc,EAClB,GAAIC,CAAAA,kBAAe,EACnB,WAAYN,CAAAA,CAAK,EAEpB,OAAO,MAAA,CAAOE,CAAM,CACtB","file":"index.cjs","sourcesContent":["import rehypeParse from 'rehype-parse';\nimport rehypeSanitize from 'rehype-sanitize';\nimport rehypeStringify from 'rehype-stringify';\nimport { unified } from 'unified';\n\nimport type { Options as RehypeSanitizeOptions } from 'rehype-sanitize';\n\nexport function sanitizeHtml(\n input: string,\n options?: RehypeSanitizeOptions\n): string {\n const output = unified()\n .use(rehypeParse, { fragment: true })\n .use(rehypeSanitize, options)\n .use(rehypeStringify)\n .processSync(input);\n\n return String(output);\n}\n\n// Handy shortcut for when you just want to strip tags from text\nexport const stripTags = (\n input: string,\n options?: RehypeSanitizeOptions\n): string => sanitizeHtml(input, { ...options, tagNames: [] });\n","import { retext } from 'retext';\nimport retextSmartypants from 'retext-smartypants';\n\nimport type { Options as RetextSmartypantsOptions } from 'retext-smartypants';\n\nexport function stylizeText(\n input: string,\n options?: RetextSmartypantsOptions\n): string {\n const output = retext().use(retextSmartypants, options).processSync(input);\n\n return String(output);\n}\n","import rehypeSanitize from 'rehype-sanitize';\nimport rehypeStringify from 'rehype-stringify';\nimport rehypeWrapCjk from 'rehype-wrap-cjk';\nimport remarkParse from 'remark-parse';\nimport remarkRehype from 'remark-rehype';\nimport remarkSmartyPants from 'remark-smartypants';\nimport { unified } from 'unified';\n\nexport function transformMarkdown(input: string): string {\n const output = unified()\n .use(remarkParse)\n .use(remarkSmartyPants)\n .use(remarkRehype)\n .use(rehypeWrapCjk)\n .use(rehypeSanitize)\n .use(rehypeStringify)\n .processSync(input);\n\n return String(output);\n}\n","import rehypeParse from 'rehype-parse';\nimport rehypeSanitize from 'rehype-sanitize';\nimport rehypeStringify from 'rehype-stringify';\nimport rehypeWrapCjk from 'rehype-wrap-cjk';\nimport { unified } from 'unified';\n\nexport function wrapCjk(input: string): string {\n const output = unified()\n .use(rehypeParse, { fragment: true })\n .use(rehypeWrapCjk)\n .use(rehypeSanitize)\n .use(rehypeStringify)\n .processSync(input);\n\n return String(output);\n}\n"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { sanitizeHtml, stripTags } from './sanitize-html.cjs';
|
|
2
|
+
export { stylizeText } from './stylize-text.cjs';
|
|
3
|
+
export { transformMarkdown } from './transform-markdown.cjs';
|
|
4
|
+
export { wrapCjk } from './wrap-cjk.cjs';
|
|
5
|
+
export { defaultSchema } from 'rehype-sanitize';
|
|
6
|
+
import 'retext-smartypants';
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { sanitizeHtml, stripTags } from './sanitize-html.js';
|
|
2
|
+
export { stylizeText } from './stylize-text.js';
|
|
3
|
+
export { transformMarkdown } from './transform-markdown.js';
|
|
4
|
+
export { wrapCjk } from './wrap-cjk.js';
|
|
5
|
+
export { defaultSchema } from 'rehype-sanitize';
|
|
6
|
+
import 'retext-smartypants';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export{a as sanitizeHtml,b as stripTags}from'./chunk-7QE4BXN4.js';export{a as stylizeText}from'./chunk-5RPJUYTO.js';export{a as transformMarkdown}from'./chunk-CDY2GI2P.js';export{a as wrapCjk}from'./chunk-EGSAYCRK.js';export{defaultSchema}from'rehype-sanitize';//# sourceMappingURL=index.js.map
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js","sourcesContent":[]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var r=require('rehype-parse'),n=require('rehype-sanitize'),p=require('rehype-stringify'),unified=require('unified');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var r__default=/*#__PURE__*/_interopDefault(r);var n__default=/*#__PURE__*/_interopDefault(n);var p__default=/*#__PURE__*/_interopDefault(p);function o(t,e){let i=unified.unified().use(r__default.default,{fragment:true}).use(n__default.default,e).use(p__default.default).processSync(t);return String(i)}var g=(t,e)=>o(t,{...e,tagNames:[]});exports.sanitizeHtml=o;exports.stripTags=g;//# sourceMappingURL=sanitize-html.cjs.map
|
|
2
|
+
//# sourceMappingURL=sanitize-html.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/sanitize-html.ts"],"names":["sanitizeHtml","input","options","output","unified","rehypeParse","rehypeSanitize","rehypeStringify","stripTags"],"mappings":"+UAOO,SAASA,EACdC,CACAC,CAAAA,CAAAA,CACQ,CACR,IAAMC,CAASC,CAAAA,eAAAA,EACZ,CAAA,GAAA,CAAIC,kBAAa,CAAA,CAAE,QAAU,CAAA,IAAK,CAAC,CAAA,CACnC,IAAIC,kBAAgBJ,CAAAA,CAAO,CAC3B,CAAA,GAAA,CAAIK,kBAAe,CAAA,CACnB,WAAYN,CAAAA,CAAK,CAEpB,CAAA,OAAO,MAAOE,CAAAA,CAAM,CACtB,KAGaK,CAAY,CAAA,CACvBP,CACAC,CAAAA,CAAAA,GACWF,CAAaC,CAAAA,CAAAA,CAAO,CAAE,GAAGC,CAAS,CAAA,QAAA,CAAU,EAAG,CAAC","file":"sanitize-html.cjs","sourcesContent":["import rehypeParse from 'rehype-parse';\nimport rehypeSanitize from 'rehype-sanitize';\nimport rehypeStringify from 'rehype-stringify';\nimport { unified } from 'unified';\n\nimport type { Options as RehypeSanitizeOptions } from 'rehype-sanitize';\n\nexport function sanitizeHtml(\n input: string,\n options?: RehypeSanitizeOptions\n): string {\n const output = unified()\n .use(rehypeParse, { fragment: true })\n .use(rehypeSanitize, options)\n .use(rehypeStringify)\n .processSync(input);\n\n return String(output);\n}\n\n// Handy shortcut for when you just want to strip tags from text\nexport const stripTags = (\n input: string,\n options?: RehypeSanitizeOptions\n): string => sanitizeHtml(input, { ...options, tagNames: [] });\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"sanitize-html.js"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var retext=require('retext'),n=require('retext-smartypants');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var n__default=/*#__PURE__*/_interopDefault(n);function i(t,r){let e=retext.retext().use(n__default.default,r).processSync(t);return String(e)}exports.stylizeText=i;//# sourceMappingURL=stylize-text.cjs.map
|
|
2
|
+
//# sourceMappingURL=stylize-text.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/stylize-text.ts"],"names":["stylizeText","input","options","output","retext","retextSmartypants"],"mappings":"0LAKO,SAASA,CAAAA,CACdC,CACAC,CAAAA,CAAAA,CACQ,CACR,IAAMC,EAASC,aAAO,EAAA,CAAE,GAAIC,CAAAA,kBAAAA,CAAmBH,CAAO,CAAA,CAAE,WAAYD,CAAAA,CAAK,CAEzE,CAAA,OAAO,MAAOE,CAAAA,CAAM,CACtB","file":"stylize-text.cjs","sourcesContent":["import { retext } from 'retext';\nimport retextSmartypants from 'retext-smartypants';\n\nimport type { Options as RetextSmartypantsOptions } from 'retext-smartypants';\n\nexport function stylizeText(\n input: string,\n options?: RetextSmartypantsOptions\n): string {\n const output = retext().use(retextSmartypants, options).processSync(input);\n\n return String(output);\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"stylize-text.js"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var o=require('rehype-sanitize'),t=require('rehype-stringify'),m=require('rehype-wrap-cjk'),i=require('remark-parse'),p=require('remark-rehype'),n=require('remark-smartypants'),unified=require('unified');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var o__default=/*#__PURE__*/_interopDefault(o);var t__default=/*#__PURE__*/_interopDefault(t);var m__default=/*#__PURE__*/_interopDefault(m);var i__default=/*#__PURE__*/_interopDefault(i);var p__default=/*#__PURE__*/_interopDefault(p);var n__default=/*#__PURE__*/_interopDefault(n);function g(r){let e=unified.unified().use(i__default.default).use(n__default.default).use(p__default.default).use(m__default.default).use(o__default.default).use(t__default.default).processSync(r);return String(e)}exports.transformMarkdown=g;//# sourceMappingURL=transform-markdown.cjs.map
|
|
2
|
+
//# sourceMappingURL=transform-markdown.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/transform-markdown.ts"],"names":["transformMarkdown","input","output","unified","remarkParse","remarkSmartyPants","remarkRehype","rehypeWrapCjk","rehypeSanitize","rehypeStringify"],"mappings":"ojBAQO,SAASA,CAAkBC,CAAAA,CAAAA,CAAuB,CACvD,IAAMC,EAASC,eAAQ,EAAA,CACpB,GAAIC,CAAAA,kBAAW,CACf,CAAA,GAAA,CAAIC,kBAAiB,CACrB,CAAA,GAAA,CAAIC,kBAAY,CAAA,CAChB,GAAIC,CAAAA,kBAAa,EACjB,GAAIC,CAAAA,kBAAc,CAClB,CAAA,GAAA,CAAIC,kBAAe,CAAA,CACnB,WAAYR,CAAAA,CAAK,CAEpB,CAAA,OAAO,MAAOC,CAAAA,CAAM,CACtB","file":"transform-markdown.cjs","sourcesContent":["import rehypeSanitize from 'rehype-sanitize';\nimport rehypeStringify from 'rehype-stringify';\nimport rehypeWrapCjk from 'rehype-wrap-cjk';\nimport remarkParse from 'remark-parse';\nimport remarkRehype from 'remark-rehype';\nimport remarkSmartyPants from 'remark-smartypants';\nimport { unified } from 'unified';\n\nexport function transformMarkdown(input: string): string {\n const output = unified()\n .use(remarkParse)\n .use(remarkSmartyPants)\n .use(remarkRehype)\n .use(rehypeWrapCjk)\n .use(rehypeSanitize)\n .use(rehypeStringify)\n .processSync(input);\n\n return String(output);\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"transform-markdown.js"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var t=require('rehype-parse'),i=require('rehype-sanitize'),o=require('rehype-stringify'),p=require('rehype-wrap-cjk'),unified=require('unified');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var t__default=/*#__PURE__*/_interopDefault(t);var i__default=/*#__PURE__*/_interopDefault(i);var o__default=/*#__PURE__*/_interopDefault(o);var p__default=/*#__PURE__*/_interopDefault(p);function a(r){let e=unified.unified().use(t__default.default,{fragment:true}).use(p__default.default).use(i__default.default).use(o__default.default).processSync(r);return String(e)}exports.wrapCjk=a;//# sourceMappingURL=wrap-cjk.cjs.map
|
|
2
|
+
//# sourceMappingURL=wrap-cjk.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/wrap-cjk.ts"],"names":["wrapCjk","input","output","unified","rehypeParse","rehypeWrapCjk","rehypeSanitize","rehypeStringify"],"mappings":"2ZAMO,SAASA,EAAQC,CAAuB,CAAA,CAC7C,IAAMC,CAASC,CAAAA,eAAAA,GACZ,GAAIC,CAAAA,kBAAAA,CAAa,CAAE,QAAU,CAAA,IAAK,CAAC,CACnC,CAAA,GAAA,CAAIC,kBAAa,CACjB,CAAA,GAAA,CAAIC,kBAAc,CAClB,CAAA,GAAA,CAAIC,kBAAe,CACnB,CAAA,WAAA,CAAYN,CAAK,CAEpB,CAAA,OAAO,MAAOC,CAAAA,CAAM,CACtB","file":"wrap-cjk.cjs","sourcesContent":["import rehypeParse from 'rehype-parse';\nimport rehypeSanitize from 'rehype-sanitize';\nimport rehypeStringify from 'rehype-stringify';\nimport rehypeWrapCjk from 'rehype-wrap-cjk';\nimport { unified } from 'unified';\n\nexport function wrapCjk(input: string): string {\n const output = unified()\n .use(rehypeParse, { fragment: true })\n .use(rehypeWrapCjk)\n .use(rehypeSanitize)\n .use(rehypeStringify)\n .processSync(input);\n\n return String(output);\n}\n"]}
|
package/dist/wrap-cjk.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"wrap-cjk.js"}
|
package/package.json
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@xsynaptic/unified-tools",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "A common set of tools for transforming and manipulating markup and text",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": {
|
|
7
|
+
"import": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"default": "./dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"require": {
|
|
12
|
+
"types": "./dist/index.d.cts",
|
|
13
|
+
"default": "./dist/index.cjs"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"main": "dist/index.js",
|
|
18
|
+
"types": "dist/index.d.ts",
|
|
19
|
+
"sideEffects": false,
|
|
20
|
+
"files": [
|
|
21
|
+
"dist/**/*",
|
|
22
|
+
"src/**/*"
|
|
23
|
+
],
|
|
24
|
+
"type": "module",
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "tsup",
|
|
27
|
+
"build-tsc": "tsc --build",
|
|
28
|
+
"check-types": "tsc --project tsconfig.json --noemit",
|
|
29
|
+
"lint": "eslint",
|
|
30
|
+
"test": "vitest",
|
|
31
|
+
"prepublishOnly": "pnpm build"
|
|
32
|
+
},
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "git+https://github.com/xsynaptic/unified-tools.git"
|
|
36
|
+
},
|
|
37
|
+
"keywords": [
|
|
38
|
+
"unified",
|
|
39
|
+
"rehype",
|
|
40
|
+
"rehype-plugin",
|
|
41
|
+
"remark",
|
|
42
|
+
"remark-plugin"
|
|
43
|
+
],
|
|
44
|
+
"author": "Alexander Synaptic <x@synapticism.com>",
|
|
45
|
+
"bugs": {
|
|
46
|
+
"url": "https://github.com/xsynaptic/unified-tools/issues"
|
|
47
|
+
},
|
|
48
|
+
"homepage": "https://github.com/xsynaptic/unified-tools#readme",
|
|
49
|
+
"license": "MIT",
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"rehype-parse": "^9.0.1",
|
|
52
|
+
"rehype-sanitize": "^6.0.0",
|
|
53
|
+
"rehype-stringify": "^10.0.1",
|
|
54
|
+
"rehype-wrap-cjk": "^0.2.3",
|
|
55
|
+
"remark-parse": "^11.0.0",
|
|
56
|
+
"remark-rehype": "^11.1.1",
|
|
57
|
+
"remark-smartypants": "^3.0.2",
|
|
58
|
+
"retext": "^9.0.0",
|
|
59
|
+
"retext-smartypants": "^6.2.0",
|
|
60
|
+
"unified": "^11.0.5"
|
|
61
|
+
},
|
|
62
|
+
"devDependencies": {
|
|
63
|
+
"@eslint/js": "^9.18.0",
|
|
64
|
+
"@types/eslint__js": "^8.42.3",
|
|
65
|
+
"@types/jest": "^29.5.14",
|
|
66
|
+
"eslint": "^9.18.0",
|
|
67
|
+
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
68
|
+
"eslint-plugin-unicorn": "^56.0.1",
|
|
69
|
+
"globals": "^15.14.0",
|
|
70
|
+
"prettier": "^3.4.2",
|
|
71
|
+
"tsup": "^8.3.5",
|
|
72
|
+
"typescript": "^5.7.3",
|
|
73
|
+
"typescript-eslint": "^8.21.0",
|
|
74
|
+
"vitest": "^3.0.2"
|
|
75
|
+
},
|
|
76
|
+
"packageManager": "pnpm@9.15.0+sha512.76e2379760a4328ec4415815bcd6628dee727af3779aaa4c914e3944156c4299921a89f976381ee107d41f12cfa4b66681ca9c718f0668fa0831ed4c6d8ba56c"
|
|
77
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
# Unified Tools
|
|
2
|
+
|
|
3
|
+
A set of Unified tools and pipelines for markup and text manipulation. This isn't meant to be a public library others install; it is a common library for several of my own projects, but you're welcome to lift some code if there's anything interesting in here.
|
|
4
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { stripTags } from '../sanitize-html.js';
|
|
2
|
+
|
|
3
|
+
const sampleText = [
|
|
4
|
+
[`No change to plain text`, `No change to plain text`],
|
|
5
|
+
[`Emphasis <em>should</em> be removed`, `Emphasis should be removed`],
|
|
6
|
+
[
|
|
7
|
+
`This <a href="https://example.com">link</a> should be stripped`,
|
|
8
|
+
`This link should be stripped`,
|
|
9
|
+
],
|
|
10
|
+
[
|
|
11
|
+
`The following MDX component should not appear at all: <Img src="./test1.jpg" />`,
|
|
12
|
+
`The following MDX component should not appear at all: `,
|
|
13
|
+
],
|
|
14
|
+
] as const;
|
|
15
|
+
|
|
16
|
+
describe('html tags should be stripped', () => {
|
|
17
|
+
for (const [input, output] of sampleText) {
|
|
18
|
+
test(input, () => {
|
|
19
|
+
expect(stripTags(input)).toEqual(output);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
});
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import rehypeParse from 'rehype-parse';
|
|
2
|
+
import rehypeSanitize from 'rehype-sanitize';
|
|
3
|
+
import rehypeStringify from 'rehype-stringify';
|
|
4
|
+
import { unified } from 'unified';
|
|
5
|
+
|
|
6
|
+
import type { Options as RehypeSanitizeOptions } from 'rehype-sanitize';
|
|
7
|
+
|
|
8
|
+
export function sanitizeHtml(
|
|
9
|
+
input: string,
|
|
10
|
+
options?: RehypeSanitizeOptions
|
|
11
|
+
): string {
|
|
12
|
+
const output = unified()
|
|
13
|
+
.use(rehypeParse, { fragment: true })
|
|
14
|
+
.use(rehypeSanitize, options)
|
|
15
|
+
.use(rehypeStringify)
|
|
16
|
+
.processSync(input);
|
|
17
|
+
|
|
18
|
+
return String(output);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Handy shortcut for when you just want to strip tags from text
|
|
22
|
+
export const stripTags = (
|
|
23
|
+
input: string,
|
|
24
|
+
options?: RehypeSanitizeOptions
|
|
25
|
+
): string => sanitizeHtml(input, { ...options, tagNames: [] });
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { retext } from 'retext';
|
|
2
|
+
import retextSmartypants from 'retext-smartypants';
|
|
3
|
+
|
|
4
|
+
import type { Options as RetextSmartypantsOptions } from 'retext-smartypants';
|
|
5
|
+
|
|
6
|
+
export function stylizeText(
|
|
7
|
+
input: string,
|
|
8
|
+
options?: RetextSmartypantsOptions
|
|
9
|
+
): string {
|
|
10
|
+
const output = retext().use(retextSmartypants, options).processSync(input);
|
|
11
|
+
|
|
12
|
+
return String(output);
|
|
13
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import rehypeSanitize from 'rehype-sanitize';
|
|
2
|
+
import rehypeStringify from 'rehype-stringify';
|
|
3
|
+
import rehypeWrapCjk from 'rehype-wrap-cjk';
|
|
4
|
+
import remarkParse from 'remark-parse';
|
|
5
|
+
import remarkRehype from 'remark-rehype';
|
|
6
|
+
import remarkSmartyPants from 'remark-smartypants';
|
|
7
|
+
import { unified } from 'unified';
|
|
8
|
+
|
|
9
|
+
export function transformMarkdown(input: string): string {
|
|
10
|
+
const output = unified()
|
|
11
|
+
.use(remarkParse)
|
|
12
|
+
.use(remarkSmartyPants)
|
|
13
|
+
.use(remarkRehype)
|
|
14
|
+
.use(rehypeWrapCjk)
|
|
15
|
+
.use(rehypeSanitize)
|
|
16
|
+
.use(rehypeStringify)
|
|
17
|
+
.processSync(input);
|
|
18
|
+
|
|
19
|
+
return String(output);
|
|
20
|
+
}
|
package/src/wrap-cjk.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import rehypeParse from 'rehype-parse';
|
|
2
|
+
import rehypeSanitize from 'rehype-sanitize';
|
|
3
|
+
import rehypeStringify from 'rehype-stringify';
|
|
4
|
+
import rehypeWrapCjk from 'rehype-wrap-cjk';
|
|
5
|
+
import { unified } from 'unified';
|
|
6
|
+
|
|
7
|
+
export function wrapCjk(input: string): string {
|
|
8
|
+
const output = unified()
|
|
9
|
+
.use(rehypeParse, { fragment: true })
|
|
10
|
+
.use(rehypeWrapCjk)
|
|
11
|
+
.use(rehypeSanitize)
|
|
12
|
+
.use(rehypeStringify)
|
|
13
|
+
.processSync(input);
|
|
14
|
+
|
|
15
|
+
return String(output);
|
|
16
|
+
}
|