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