@changerawr/markdown 1.0.3 → 1.0.5
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/README.md +1 -1
- package/dist/index.d.mts +233 -8
- package/dist/index.d.ts +233 -8
- package/dist/index.js +462 -36
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +435 -36
- package/dist/index.mjs.map +1 -1
- package/dist/react/index.js +0 -1
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +0 -2
- package/dist/react/index.mjs.map +1 -1
- package/dist/standalone.browser.js +2547 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use client";
|
|
2
1
|
"use strict";
|
|
3
2
|
var __create = Object.create;
|
|
4
3
|
var __defProp = Object.defineProperty;
|
|
@@ -39,19 +38,43 @@ __export(index_exports, {
|
|
|
39
38
|
MarkdownParser: () => MarkdownParser,
|
|
40
39
|
MarkdownRenderer: () => MarkdownRenderer,
|
|
41
40
|
PerformanceTimer: () => PerformanceTimer,
|
|
41
|
+
astToJSONString: () => astToJSONString,
|
|
42
|
+
astToTokens: () => astToTokens,
|
|
43
|
+
basicSanitize: () => basicSanitize,
|
|
44
|
+
compareTokens: () => compareTokens,
|
|
45
|
+
createCumEngine: () => createCumEngine,
|
|
42
46
|
createCustomEngine: () => createCustomEngine,
|
|
43
47
|
createDebugEngine: () => createDebugEngine,
|
|
44
48
|
createEngine: () => createEngine,
|
|
49
|
+
createEngineWithPreset: () => createEngineWithPreset,
|
|
45
50
|
createHTMLEngine: () => createHTMLEngine,
|
|
46
51
|
createMinimalEngine: () => createMinimalEngine,
|
|
47
52
|
createTailwindEngine: () => createTailwindEngine,
|
|
53
|
+
debounce: () => debounce,
|
|
54
|
+
deepMerge: () => deepMerge,
|
|
48
55
|
default: () => index_default,
|
|
56
|
+
defaultTailwindClasses: () => defaultTailwindClasses,
|
|
49
57
|
escapeHtml: () => escapeHtml,
|
|
50
58
|
extractDomain: () => extractDomain,
|
|
51
59
|
generateId: () => generateId,
|
|
60
|
+
getASTStats: () => getASTStats,
|
|
61
|
+
getTokenStats: () => getTokenStats,
|
|
62
|
+
isBrowser: () => isBrowser,
|
|
63
|
+
isNode: () => isNode,
|
|
64
|
+
isValidUrl: () => isValidUrl,
|
|
52
65
|
markdown: () => markdown2,
|
|
66
|
+
minimalClasses: () => minimalClasses,
|
|
67
|
+
parseASTFromJSON: () => parseASTFromJSON,
|
|
68
|
+
parseCum: () => parseCum,
|
|
53
69
|
parseMarkdown: () => parseMarkdown,
|
|
54
70
|
parseOptions: () => parseOptions,
|
|
71
|
+
parseTokensFromJSON: () => parseTokensFromJSON,
|
|
72
|
+
presets: () => presets,
|
|
73
|
+
proseClasses: () => proseClasses,
|
|
74
|
+
renderCum: () => renderCum,
|
|
75
|
+
renderCumToHtml: () => renderCumToHtml,
|
|
76
|
+
renderCumToJson: () => renderCumToJson,
|
|
77
|
+
renderCumToTailwind: () => renderCumToTailwind,
|
|
55
78
|
renderMarkdown: () => renderMarkdown,
|
|
56
79
|
renderToAST: () => renderToAST,
|
|
57
80
|
renderToHTML: () => renderToHTML,
|
|
@@ -61,7 +84,9 @@ __export(index_exports, {
|
|
|
61
84
|
renderToTailwind: () => renderToTailwind,
|
|
62
85
|
renderToTailwindWithClasses: () => renderToTailwindWithClasses,
|
|
63
86
|
renderToTailwindWithConfig: () => renderToTailwindWithConfig,
|
|
64
|
-
sanitizeHtml: () => sanitizeHtml
|
|
87
|
+
sanitizeHtml: () => sanitizeHtml,
|
|
88
|
+
tokensToAST: () => tokensToAST,
|
|
89
|
+
tokensToJSONString: () => tokensToJSONString
|
|
65
90
|
});
|
|
66
91
|
module.exports = __toCommonJS(index_exports);
|
|
67
92
|
|
|
@@ -610,6 +635,38 @@ function sanitizeHtml(html) {
|
|
|
610
635
|
function basicSanitize(html) {
|
|
611
636
|
return html.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "").replace(/on\w+\s*=\s*"[^"]*"/gi, "").replace(/on\w+\s*=\s*'[^']*'/gi, "").replace(/javascript:/gi, "");
|
|
612
637
|
}
|
|
638
|
+
function isBrowser() {
|
|
639
|
+
return typeof window !== "undefined" && typeof document !== "undefined";
|
|
640
|
+
}
|
|
641
|
+
function isNode() {
|
|
642
|
+
return typeof process !== "undefined" && process.versions != null && process.versions.node != null;
|
|
643
|
+
}
|
|
644
|
+
function debounce(func, wait) {
|
|
645
|
+
let timeout;
|
|
646
|
+
return function executedFunction(...args) {
|
|
647
|
+
const later = () => {
|
|
648
|
+
clearTimeout(timeout);
|
|
649
|
+
func(...args);
|
|
650
|
+
};
|
|
651
|
+
clearTimeout(timeout);
|
|
652
|
+
timeout = setTimeout(later, wait);
|
|
653
|
+
};
|
|
654
|
+
}
|
|
655
|
+
function deepMerge(target, source) {
|
|
656
|
+
const output = { ...target };
|
|
657
|
+
for (const key in source) {
|
|
658
|
+
if (source[key] && typeof source[key] === "object" && !Array.isArray(source[key])) {
|
|
659
|
+
if (key in target && typeof target[key] === "object" && !Array.isArray(target[key])) {
|
|
660
|
+
output[key] = deepMerge(target[key], source[key]);
|
|
661
|
+
} else {
|
|
662
|
+
output[key] = source[key];
|
|
663
|
+
}
|
|
664
|
+
} else {
|
|
665
|
+
output[key] = source[key];
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
return output;
|
|
669
|
+
}
|
|
613
670
|
function extractDomain(url) {
|
|
614
671
|
try {
|
|
615
672
|
return new URL(url).hostname;
|
|
@@ -617,6 +674,14 @@ function extractDomain(url) {
|
|
|
617
674
|
return url;
|
|
618
675
|
}
|
|
619
676
|
}
|
|
677
|
+
function isValidUrl(url) {
|
|
678
|
+
try {
|
|
679
|
+
new URL(url);
|
|
680
|
+
return true;
|
|
681
|
+
} catch {
|
|
682
|
+
return false;
|
|
683
|
+
}
|
|
684
|
+
}
|
|
620
685
|
function parseOptions(options) {
|
|
621
686
|
const parsed = {};
|
|
622
687
|
if (!options) return parsed;
|
|
@@ -1585,37 +1650,6 @@ function renderToHTMLUnsafe(markdown3) {
|
|
|
1585
1650
|
});
|
|
1586
1651
|
}
|
|
1587
1652
|
|
|
1588
|
-
// src/outputs/tailwind.ts
|
|
1589
|
-
function renderToTailwind(markdown3, config) {
|
|
1590
|
-
const engine = new ChangerawrMarkdown({
|
|
1591
|
-
...config,
|
|
1592
|
-
renderer: {
|
|
1593
|
-
format: "tailwind",
|
|
1594
|
-
sanitize: true,
|
|
1595
|
-
allowUnsafeHtml: false
|
|
1596
|
-
}
|
|
1597
|
-
});
|
|
1598
|
-
return engine.toHtml(markdown3);
|
|
1599
|
-
}
|
|
1600
|
-
function renderToTailwindWithClasses(markdown3, customClasses) {
|
|
1601
|
-
const engine = new ChangerawrMarkdown({
|
|
1602
|
-
renderer: {
|
|
1603
|
-
format: "tailwind",
|
|
1604
|
-
...customClasses && { customClasses }
|
|
1605
|
-
}
|
|
1606
|
-
});
|
|
1607
|
-
return engine.toHtml(markdown3);
|
|
1608
|
-
}
|
|
1609
|
-
function renderToTailwindWithConfig(markdown3, rendererConfig) {
|
|
1610
|
-
const engine = new ChangerawrMarkdown({
|
|
1611
|
-
renderer: {
|
|
1612
|
-
format: "tailwind",
|
|
1613
|
-
...rendererConfig
|
|
1614
|
-
}
|
|
1615
|
-
});
|
|
1616
|
-
return engine.toHtml(markdown3);
|
|
1617
|
-
}
|
|
1618
|
-
|
|
1619
1653
|
// src/outputs/json.ts
|
|
1620
1654
|
function renderToJSON(markdown3, config) {
|
|
1621
1655
|
const engine = new ChangerawrMarkdown(config);
|
|
@@ -1697,9 +1731,305 @@ function tokensToAST(tokens) {
|
|
|
1697
1731
|
}
|
|
1698
1732
|
return ast;
|
|
1699
1733
|
}
|
|
1734
|
+
function astToTokens(ast) {
|
|
1735
|
+
const tokens = [];
|
|
1736
|
+
function processNode(node) {
|
|
1737
|
+
if (node.children && node.children.length > 0) {
|
|
1738
|
+
if (node.type === "list" || node.type === "task-list" || node.type === "blockquote-group") {
|
|
1739
|
+
node.children.forEach(processNode);
|
|
1740
|
+
return;
|
|
1741
|
+
}
|
|
1742
|
+
if (node.type === "paragraph") {
|
|
1743
|
+
node.children.forEach((child, index) => {
|
|
1744
|
+
const token2 = {
|
|
1745
|
+
type: child.type,
|
|
1746
|
+
content: child.content,
|
|
1747
|
+
raw: child.content,
|
|
1748
|
+
...child.attributes && { attributes: child.attributes }
|
|
1749
|
+
};
|
|
1750
|
+
tokens.push(token2);
|
|
1751
|
+
if (index < node.children.length - 1 && isInlineToken(child)) {
|
|
1752
|
+
tokens.push({
|
|
1753
|
+
type: "soft-break",
|
|
1754
|
+
content: " ",
|
|
1755
|
+
raw: " "
|
|
1756
|
+
});
|
|
1757
|
+
}
|
|
1758
|
+
});
|
|
1759
|
+
tokens.push({
|
|
1760
|
+
type: "paragraph-break",
|
|
1761
|
+
content: "",
|
|
1762
|
+
raw: "\n\n"
|
|
1763
|
+
});
|
|
1764
|
+
return;
|
|
1765
|
+
}
|
|
1766
|
+
}
|
|
1767
|
+
const token = {
|
|
1768
|
+
type: node.type,
|
|
1769
|
+
content: node.content,
|
|
1770
|
+
raw: node.content,
|
|
1771
|
+
...node.attributes && { attributes: node.attributes }
|
|
1772
|
+
};
|
|
1773
|
+
tokens.push(token);
|
|
1774
|
+
}
|
|
1775
|
+
ast.forEach(processNode);
|
|
1776
|
+
return tokens;
|
|
1777
|
+
}
|
|
1778
|
+
function tokensToJSONString(tokens, pretty = true) {
|
|
1779
|
+
if (pretty) {
|
|
1780
|
+
return JSON.stringify(tokens, null, 2);
|
|
1781
|
+
}
|
|
1782
|
+
return JSON.stringify(tokens);
|
|
1783
|
+
}
|
|
1784
|
+
function astToJSONString(ast, pretty = true) {
|
|
1785
|
+
if (pretty) {
|
|
1786
|
+
return JSON.stringify(ast, null, 2);
|
|
1787
|
+
}
|
|
1788
|
+
return JSON.stringify(ast);
|
|
1789
|
+
}
|
|
1790
|
+
function parseTokensFromJSON(jsonString) {
|
|
1791
|
+
try {
|
|
1792
|
+
const parsed = JSON.parse(jsonString);
|
|
1793
|
+
if (!Array.isArray(parsed)) {
|
|
1794
|
+
throw new Error("JSON must be an array of tokens");
|
|
1795
|
+
}
|
|
1796
|
+
for (const token of parsed) {
|
|
1797
|
+
if (!token.type || typeof token.type !== "string") {
|
|
1798
|
+
throw new Error("Invalid token structure: missing or invalid type");
|
|
1799
|
+
}
|
|
1800
|
+
if (token.content === void 0 && token.raw === void 0) {
|
|
1801
|
+
throw new Error("Invalid token structure: missing content and raw");
|
|
1802
|
+
}
|
|
1803
|
+
}
|
|
1804
|
+
return parsed;
|
|
1805
|
+
} catch (error) {
|
|
1806
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1807
|
+
throw new Error(`Failed to parse tokens from JSON: ${message}`);
|
|
1808
|
+
}
|
|
1809
|
+
}
|
|
1810
|
+
function parseASTFromJSON(jsonString) {
|
|
1811
|
+
try {
|
|
1812
|
+
const parsed = JSON.parse(jsonString);
|
|
1813
|
+
if (!Array.isArray(parsed)) {
|
|
1814
|
+
throw new Error("JSON must be an array of AST nodes");
|
|
1815
|
+
}
|
|
1816
|
+
for (const node of parsed) {
|
|
1817
|
+
if (!node.type || typeof node.type !== "string") {
|
|
1818
|
+
throw new Error("Invalid AST node: missing or invalid type");
|
|
1819
|
+
}
|
|
1820
|
+
}
|
|
1821
|
+
return parsed;
|
|
1822
|
+
} catch (error) {
|
|
1823
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1824
|
+
throw new Error(`Failed to parse AST from JSON: ${message}`);
|
|
1825
|
+
}
|
|
1826
|
+
}
|
|
1827
|
+
function getTokenStats(tokens) {
|
|
1828
|
+
const tokenTypes = {};
|
|
1829
|
+
const extensionTokens = {};
|
|
1830
|
+
let totalContent = 0;
|
|
1831
|
+
let totalRaw = 0;
|
|
1832
|
+
let tokensWithAttributes = 0;
|
|
1833
|
+
for (const token of tokens) {
|
|
1834
|
+
tokenTypes[token.type] = (tokenTypes[token.type] || 0) + 1;
|
|
1835
|
+
if (["alert", "button", "embed"].includes(token.type)) {
|
|
1836
|
+
extensionTokens[token.type] = (extensionTokens[token.type] || 0) + 1;
|
|
1837
|
+
}
|
|
1838
|
+
totalContent += (token.content || "").length;
|
|
1839
|
+
totalRaw += (token.raw || "").length;
|
|
1840
|
+
if (token.attributes && Object.keys(token.attributes).length > 0) {
|
|
1841
|
+
tokensWithAttributes++;
|
|
1842
|
+
}
|
|
1843
|
+
}
|
|
1844
|
+
const totalTokens = tokens.length;
|
|
1845
|
+
return {
|
|
1846
|
+
totalTokens,
|
|
1847
|
+
tokenTypes,
|
|
1848
|
+
extensionTokens,
|
|
1849
|
+
totalContent,
|
|
1850
|
+
totalRaw,
|
|
1851
|
+
tokensWithAttributes,
|
|
1852
|
+
averageContentLength: totalTokens > 0 ? Math.round(totalContent / totalTokens) : 0,
|
|
1853
|
+
averageRawLength: totalTokens > 0 ? Math.round(totalRaw / totalTokens) : 0,
|
|
1854
|
+
attributeUsageRate: totalTokens > 0 ? Math.round(tokensWithAttributes / totalTokens * 100) : 0
|
|
1855
|
+
};
|
|
1856
|
+
}
|
|
1857
|
+
function getASTStats(ast) {
|
|
1858
|
+
let totalNodes = 0;
|
|
1859
|
+
let maxDepth = 0;
|
|
1860
|
+
let nodesWithChildren = 0;
|
|
1861
|
+
let totalChildren = 0;
|
|
1862
|
+
const nodeTypes = {};
|
|
1863
|
+
function analyzeNode(node, depth = 0) {
|
|
1864
|
+
totalNodes++;
|
|
1865
|
+
maxDepth = Math.max(maxDepth, depth);
|
|
1866
|
+
nodeTypes[node.type] = (nodeTypes[node.type] || 0) + 1;
|
|
1867
|
+
if (node.children && node.children.length > 0) {
|
|
1868
|
+
nodesWithChildren++;
|
|
1869
|
+
totalChildren += node.children.length;
|
|
1870
|
+
node.children.forEach((child) => analyzeNode(child, depth + 1));
|
|
1871
|
+
}
|
|
1872
|
+
}
|
|
1873
|
+
ast.forEach((node) => analyzeNode(node));
|
|
1874
|
+
return {
|
|
1875
|
+
totalNodes,
|
|
1876
|
+
maxDepth,
|
|
1877
|
+
nodesWithChildren,
|
|
1878
|
+
totalChildren,
|
|
1879
|
+
nodeTypes,
|
|
1880
|
+
averageChildrenPerParent: nodesWithChildren > 0 ? Math.round(totalChildren / nodesWithChildren) : 0,
|
|
1881
|
+
hierarchyComplexity: maxDepth > 0 ? Math.round(totalChildren / totalNodes * maxDepth) : 0
|
|
1882
|
+
};
|
|
1883
|
+
}
|
|
1884
|
+
function compareTokens(tokensA, tokensB) {
|
|
1885
|
+
const differences = [];
|
|
1886
|
+
const maxLength = Math.max(tokensA.length, tokensB.length);
|
|
1887
|
+
for (let i = 0; i < maxLength; i++) {
|
|
1888
|
+
const tokenA = tokensA[i];
|
|
1889
|
+
const tokenB = tokensB[i];
|
|
1890
|
+
if (!tokenA && tokenB) {
|
|
1891
|
+
differences.push({
|
|
1892
|
+
index: i,
|
|
1893
|
+
type: "added",
|
|
1894
|
+
tokenB
|
|
1895
|
+
});
|
|
1896
|
+
} else if (tokenA && !tokenB) {
|
|
1897
|
+
differences.push({
|
|
1898
|
+
index: i,
|
|
1899
|
+
type: "removed",
|
|
1900
|
+
tokenA
|
|
1901
|
+
});
|
|
1902
|
+
} else if (tokenA && tokenB) {
|
|
1903
|
+
if (tokenA.type !== tokenB.type || tokenA.content !== tokenB.content) {
|
|
1904
|
+
differences.push({
|
|
1905
|
+
index: i,
|
|
1906
|
+
type: "modified",
|
|
1907
|
+
tokenA,
|
|
1908
|
+
tokenB
|
|
1909
|
+
});
|
|
1910
|
+
}
|
|
1911
|
+
}
|
|
1912
|
+
}
|
|
1913
|
+
return {
|
|
1914
|
+
identical: differences.length === 0,
|
|
1915
|
+
differences,
|
|
1916
|
+
addedCount: differences.filter((d) => d.type === "added").length,
|
|
1917
|
+
removedCount: differences.filter((d) => d.type === "removed").length,
|
|
1918
|
+
modifiedCount: differences.filter((d) => d.type === "modified").length
|
|
1919
|
+
};
|
|
1920
|
+
}
|
|
1700
1921
|
function isParagraphContent(token) {
|
|
1701
1922
|
return ["text", "bold", "italic", "code", "link", "soft-break"].includes(token.type);
|
|
1702
1923
|
}
|
|
1924
|
+
function isInlineToken(node) {
|
|
1925
|
+
return ["bold", "italic", "code", "link"].includes(node.type);
|
|
1926
|
+
}
|
|
1927
|
+
|
|
1928
|
+
// src/outputs/tailwind.ts
|
|
1929
|
+
function renderToTailwind(markdown3, config) {
|
|
1930
|
+
const engine = new ChangerawrMarkdown({
|
|
1931
|
+
...config,
|
|
1932
|
+
renderer: {
|
|
1933
|
+
format: "tailwind",
|
|
1934
|
+
sanitize: true,
|
|
1935
|
+
allowUnsafeHtml: false
|
|
1936
|
+
}
|
|
1937
|
+
});
|
|
1938
|
+
return engine.toHtml(markdown3);
|
|
1939
|
+
}
|
|
1940
|
+
function renderToTailwindWithClasses(markdown3, customClasses) {
|
|
1941
|
+
const engine = new ChangerawrMarkdown({
|
|
1942
|
+
renderer: {
|
|
1943
|
+
format: "tailwind",
|
|
1944
|
+
...customClasses && { customClasses }
|
|
1945
|
+
}
|
|
1946
|
+
});
|
|
1947
|
+
return engine.toHtml(markdown3);
|
|
1948
|
+
}
|
|
1949
|
+
function renderToTailwindWithConfig(markdown3, rendererConfig) {
|
|
1950
|
+
const engine = new ChangerawrMarkdown({
|
|
1951
|
+
renderer: {
|
|
1952
|
+
format: "tailwind",
|
|
1953
|
+
...rendererConfig
|
|
1954
|
+
}
|
|
1955
|
+
});
|
|
1956
|
+
return engine.toHtml(markdown3);
|
|
1957
|
+
}
|
|
1958
|
+
var defaultTailwindClasses = {
|
|
1959
|
+
// Typography
|
|
1960
|
+
"heading-1": "text-3xl font-bold mt-8 mb-4",
|
|
1961
|
+
"heading-2": "text-2xl font-semibold mt-6 mb-3",
|
|
1962
|
+
"heading-3": "text-xl font-medium mt-5 mb-3",
|
|
1963
|
+
"heading-4": "text-lg font-medium mt-4 mb-2",
|
|
1964
|
+
"heading-5": "text-base font-medium mt-3 mb-2",
|
|
1965
|
+
"heading-6": "text-sm font-medium mt-3 mb-2",
|
|
1966
|
+
"paragraph": "leading-7 mb-4",
|
|
1967
|
+
"blockquote": "pl-4 py-2 border-l-2 border-border italic text-muted-foreground my-4",
|
|
1968
|
+
// Code
|
|
1969
|
+
"code-inline": "bg-muted px-1.5 py-0.5 rounded text-sm font-mono",
|
|
1970
|
+
"code-block": "bg-muted p-4 rounded-md overflow-x-auto my-4",
|
|
1971
|
+
// Links and buttons
|
|
1972
|
+
"link": "text-primary hover:underline inline-flex items-center gap-1",
|
|
1973
|
+
"button": "inline-flex items-center justify-center font-medium rounded-lg transition-all duration-200",
|
|
1974
|
+
// Lists
|
|
1975
|
+
"list": "list-disc list-inside space-y-1",
|
|
1976
|
+
"list-item": "ml-4",
|
|
1977
|
+
// Images and media
|
|
1978
|
+
"image": "max-w-full h-auto rounded-lg my-4",
|
|
1979
|
+
"embed": "rounded-lg border bg-card text-card-foreground shadow-sm mb-6 overflow-hidden",
|
|
1980
|
+
// Alerts
|
|
1981
|
+
"alert": "border-l-4 p-4 mb-4 rounded-md transition-colors duration-200",
|
|
1982
|
+
"alert-info": "bg-blue-500/10 border-blue-500/30 text-blue-600 border-l-blue-500",
|
|
1983
|
+
"alert-warning": "bg-amber-500/10 border-amber-500/30 text-amber-600 border-l-amber-500",
|
|
1984
|
+
"alert-error": "bg-red-500/10 border-red-500/30 text-red-600 border-l-red-500",
|
|
1985
|
+
"alert-success": "bg-green-500/10 border-green-500/30 text-green-600 border-l-green-500"
|
|
1986
|
+
};
|
|
1987
|
+
var proseClasses = {
|
|
1988
|
+
"heading-1": "text-4xl font-bold tracking-tight mt-10 mb-6",
|
|
1989
|
+
"heading-2": "text-3xl font-semibold tracking-tight mt-8 mb-4",
|
|
1990
|
+
"heading-3": "text-2xl font-medium tracking-tight mt-6 mb-3",
|
|
1991
|
+
"paragraph": "text-lg leading-8 mb-6",
|
|
1992
|
+
"blockquote": "border-l-4 border-gray-300 pl-6 py-2 italic text-gray-700 my-6",
|
|
1993
|
+
"code-inline": "bg-gray-100 text-gray-800 px-2 py-1 rounded text-sm font-mono",
|
|
1994
|
+
"code-block": "bg-gray-900 text-gray-100 p-6 rounded-lg overflow-x-auto my-6 text-sm",
|
|
1995
|
+
"link": "text-blue-600 hover:text-blue-800 underline decoration-2 underline-offset-2"
|
|
1996
|
+
};
|
|
1997
|
+
var minimalClasses = {
|
|
1998
|
+
"heading-1": "text-2xl font-semibold mb-4",
|
|
1999
|
+
"heading-2": "text-xl font-medium mb-3",
|
|
2000
|
+
"heading-3": "text-lg font-medium mb-2",
|
|
2001
|
+
"paragraph": "mb-4",
|
|
2002
|
+
"blockquote": "border-l-2 border-gray-300 pl-4 italic mb-4",
|
|
2003
|
+
"code-inline": "bg-gray-100 px-1 rounded font-mono text-sm",
|
|
2004
|
+
"code-block": "bg-gray-100 p-3 rounded font-mono text-sm mb-4",
|
|
2005
|
+
"link": "text-blue-600 hover:underline"
|
|
2006
|
+
};
|
|
2007
|
+
|
|
2008
|
+
// src/standalone.ts
|
|
2009
|
+
function renderCum(markdown3, config) {
|
|
2010
|
+
const engine = new ChangerawrMarkdown(config);
|
|
2011
|
+
return engine.toHtml(markdown3);
|
|
2012
|
+
}
|
|
2013
|
+
function parseCum(markdown3, config) {
|
|
2014
|
+
const engine = new ChangerawrMarkdown(config);
|
|
2015
|
+
return engine.parse(markdown3);
|
|
2016
|
+
}
|
|
2017
|
+
function createCumEngine(config) {
|
|
2018
|
+
return new ChangerawrMarkdown(config);
|
|
2019
|
+
}
|
|
2020
|
+
function renderCumToHtml(markdown3) {
|
|
2021
|
+
return renderCum(markdown3, {
|
|
2022
|
+
renderer: { format: "html" }
|
|
2023
|
+
});
|
|
2024
|
+
}
|
|
2025
|
+
function renderCumToTailwind(markdown3) {
|
|
2026
|
+
return renderCum(markdown3, {
|
|
2027
|
+
renderer: { format: "tailwind" }
|
|
2028
|
+
});
|
|
2029
|
+
}
|
|
2030
|
+
function renderCumToJson(markdown3) {
|
|
2031
|
+
return parseCum(markdown3);
|
|
2032
|
+
}
|
|
1703
2033
|
|
|
1704
2034
|
// src/index.ts
|
|
1705
2035
|
function createEngine(config) {
|
|
@@ -1711,7 +2041,8 @@ function createHTMLEngine(config) {
|
|
|
1711
2041
|
renderer: {
|
|
1712
2042
|
format: "html",
|
|
1713
2043
|
sanitize: true,
|
|
1714
|
-
allowUnsafeHtml: false
|
|
2044
|
+
allowUnsafeHtml: false,
|
|
2045
|
+
...config?.parser
|
|
1715
2046
|
}
|
|
1716
2047
|
});
|
|
1717
2048
|
}
|
|
@@ -1721,7 +2052,8 @@ function createTailwindEngine(config) {
|
|
|
1721
2052
|
renderer: {
|
|
1722
2053
|
format: "tailwind",
|
|
1723
2054
|
sanitize: true,
|
|
1724
|
-
allowUnsafeHtml: false
|
|
2055
|
+
allowUnsafeHtml: false,
|
|
2056
|
+
...config?.parser
|
|
1725
2057
|
}
|
|
1726
2058
|
});
|
|
1727
2059
|
}
|
|
@@ -1779,6 +2111,9 @@ var markdown2 = {
|
|
|
1779
2111
|
createDebugEngine,
|
|
1780
2112
|
createMinimalEngine,
|
|
1781
2113
|
createCustomEngine,
|
|
2114
|
+
// Standalone functions
|
|
2115
|
+
renderCum,
|
|
2116
|
+
parseCum,
|
|
1782
2117
|
// Main class
|
|
1783
2118
|
ChangerawrMarkdown,
|
|
1784
2119
|
// Extensions
|
|
@@ -1799,6 +2134,71 @@ var markdown2 = {
|
|
|
1799
2134
|
}
|
|
1800
2135
|
};
|
|
1801
2136
|
var index_default = markdown2;
|
|
2137
|
+
var presets = {
|
|
2138
|
+
/**
|
|
2139
|
+
* Blog/article preset with prose-friendly styling
|
|
2140
|
+
*/
|
|
2141
|
+
blog: {
|
|
2142
|
+
renderer: {
|
|
2143
|
+
format: "tailwind",
|
|
2144
|
+
customClasses: {
|
|
2145
|
+
"heading-1": "text-4xl font-bold tracking-tight mt-10 mb-6",
|
|
2146
|
+
"heading-2": "text-3xl font-semibold tracking-tight mt-8 mb-4",
|
|
2147
|
+
"heading-3": "text-2xl font-medium tracking-tight mt-6 mb-3",
|
|
2148
|
+
"paragraph": "text-lg leading-8 mb-6",
|
|
2149
|
+
"blockquote": "border-l-4 border-gray-300 pl-6 py-2 italic text-gray-700 my-6",
|
|
2150
|
+
"code-inline": "bg-gray-100 text-gray-800 px-2 py-1 rounded text-sm font-mono",
|
|
2151
|
+
"code-block": "bg-gray-900 text-gray-100 p-6 rounded-lg overflow-x-auto my-6 text-sm"
|
|
2152
|
+
}
|
|
2153
|
+
}
|
|
2154
|
+
},
|
|
2155
|
+
/**
|
|
2156
|
+
* Documentation preset with clean, technical styling
|
|
2157
|
+
*/
|
|
2158
|
+
docs: {
|
|
2159
|
+
renderer: {
|
|
2160
|
+
format: "tailwind",
|
|
2161
|
+
customClasses: {
|
|
2162
|
+
"heading-1": "text-3xl font-bold border-b border-gray-200 pb-2 mb-6",
|
|
2163
|
+
"heading-2": "text-2xl font-semibold mt-8 mb-4",
|
|
2164
|
+
"heading-3": "text-xl font-medium mt-6 mb-3",
|
|
2165
|
+
"paragraph": "leading-7 mb-4",
|
|
2166
|
+
"code-inline": "bg-blue-50 text-blue-800 px-2 py-1 rounded text-sm font-mono",
|
|
2167
|
+
"code-block": "bg-gray-50 border border-gray-200 p-4 rounded-lg overflow-x-auto my-4 text-sm",
|
|
2168
|
+
"alert": "border border-blue-200 bg-blue-50 text-blue-800 p-4 rounded-lg mb-4"
|
|
2169
|
+
}
|
|
2170
|
+
}
|
|
2171
|
+
},
|
|
2172
|
+
/**
|
|
2173
|
+
* Minimal preset with basic styling
|
|
2174
|
+
*/
|
|
2175
|
+
minimal: {
|
|
2176
|
+
renderer: {
|
|
2177
|
+
format: "html",
|
|
2178
|
+
sanitize: true
|
|
2179
|
+
}
|
|
2180
|
+
},
|
|
2181
|
+
/**
|
|
2182
|
+
* Performance preset with minimal processing
|
|
2183
|
+
*/
|
|
2184
|
+
fast: {
|
|
2185
|
+
parser: {
|
|
2186
|
+
validateMarkdown: false,
|
|
2187
|
+
maxIterations: 1e3
|
|
2188
|
+
},
|
|
2189
|
+
renderer: {
|
|
2190
|
+
format: "html",
|
|
2191
|
+
sanitize: false
|
|
2192
|
+
}
|
|
2193
|
+
}
|
|
2194
|
+
};
|
|
2195
|
+
function createEngineWithPreset(presetName, additionalConfig) {
|
|
2196
|
+
const preset = presets[presetName];
|
|
2197
|
+
return new ChangerawrMarkdown({
|
|
2198
|
+
...preset,
|
|
2199
|
+
...additionalConfig
|
|
2200
|
+
});
|
|
2201
|
+
}
|
|
1802
2202
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1803
2203
|
0 && (module.exports = {
|
|
1804
2204
|
AlertExtension,
|
|
@@ -1809,18 +2209,42 @@ var index_default = markdown2;
|
|
|
1809
2209
|
MarkdownParser,
|
|
1810
2210
|
MarkdownRenderer,
|
|
1811
2211
|
PerformanceTimer,
|
|
2212
|
+
astToJSONString,
|
|
2213
|
+
astToTokens,
|
|
2214
|
+
basicSanitize,
|
|
2215
|
+
compareTokens,
|
|
2216
|
+
createCumEngine,
|
|
1812
2217
|
createCustomEngine,
|
|
1813
2218
|
createDebugEngine,
|
|
1814
2219
|
createEngine,
|
|
2220
|
+
createEngineWithPreset,
|
|
1815
2221
|
createHTMLEngine,
|
|
1816
2222
|
createMinimalEngine,
|
|
1817
2223
|
createTailwindEngine,
|
|
2224
|
+
debounce,
|
|
2225
|
+
deepMerge,
|
|
2226
|
+
defaultTailwindClasses,
|
|
1818
2227
|
escapeHtml,
|
|
1819
2228
|
extractDomain,
|
|
1820
2229
|
generateId,
|
|
2230
|
+
getASTStats,
|
|
2231
|
+
getTokenStats,
|
|
2232
|
+
isBrowser,
|
|
2233
|
+
isNode,
|
|
2234
|
+
isValidUrl,
|
|
1821
2235
|
markdown,
|
|
2236
|
+
minimalClasses,
|
|
2237
|
+
parseASTFromJSON,
|
|
2238
|
+
parseCum,
|
|
1822
2239
|
parseMarkdown,
|
|
1823
2240
|
parseOptions,
|
|
2241
|
+
parseTokensFromJSON,
|
|
2242
|
+
presets,
|
|
2243
|
+
proseClasses,
|
|
2244
|
+
renderCum,
|
|
2245
|
+
renderCumToHtml,
|
|
2246
|
+
renderCumToJson,
|
|
2247
|
+
renderCumToTailwind,
|
|
1824
2248
|
renderMarkdown,
|
|
1825
2249
|
renderToAST,
|
|
1826
2250
|
renderToHTML,
|
|
@@ -1830,6 +2254,8 @@ var index_default = markdown2;
|
|
|
1830
2254
|
renderToTailwind,
|
|
1831
2255
|
renderToTailwindWithClasses,
|
|
1832
2256
|
renderToTailwindWithConfig,
|
|
1833
|
-
sanitizeHtml
|
|
2257
|
+
sanitizeHtml,
|
|
2258
|
+
tokensToAST,
|
|
2259
|
+
tokensToJSONString
|
|
1834
2260
|
});
|
|
1835
2261
|
//# sourceMappingURL=index.js.map
|