@changerawr/markdown 1.0.2 → 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.mts +8 -233
- package/dist/index.d.ts +8 -233
- package/dist/index.js +35 -462
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -435
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -39,43 +39,19 @@ __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,
|
|
47
42
|
createCustomEngine: () => createCustomEngine,
|
|
48
43
|
createDebugEngine: () => createDebugEngine,
|
|
49
44
|
createEngine: () => createEngine,
|
|
50
|
-
createEngineWithPreset: () => createEngineWithPreset,
|
|
51
45
|
createHTMLEngine: () => createHTMLEngine,
|
|
52
46
|
createMinimalEngine: () => createMinimalEngine,
|
|
53
47
|
createTailwindEngine: () => createTailwindEngine,
|
|
54
|
-
debounce: () => debounce,
|
|
55
|
-
deepMerge: () => deepMerge,
|
|
56
48
|
default: () => index_default,
|
|
57
|
-
defaultTailwindClasses: () => defaultTailwindClasses,
|
|
58
49
|
escapeHtml: () => escapeHtml,
|
|
59
50
|
extractDomain: () => extractDomain,
|
|
60
51
|
generateId: () => generateId,
|
|
61
|
-
getASTStats: () => getASTStats,
|
|
62
|
-
getTokenStats: () => getTokenStats,
|
|
63
|
-
isBrowser: () => isBrowser,
|
|
64
|
-
isNode: () => isNode,
|
|
65
|
-
isValidUrl: () => isValidUrl,
|
|
66
52
|
markdown: () => markdown2,
|
|
67
|
-
minimalClasses: () => minimalClasses,
|
|
68
|
-
parseASTFromJSON: () => parseASTFromJSON,
|
|
69
|
-
parseCum: () => parseCum,
|
|
70
53
|
parseMarkdown: () => parseMarkdown,
|
|
71
54
|
parseOptions: () => parseOptions,
|
|
72
|
-
parseTokensFromJSON: () => parseTokensFromJSON,
|
|
73
|
-
presets: () => presets,
|
|
74
|
-
proseClasses: () => proseClasses,
|
|
75
|
-
renderCum: () => renderCum,
|
|
76
|
-
renderCumToHtml: () => renderCumToHtml,
|
|
77
|
-
renderCumToJson: () => renderCumToJson,
|
|
78
|
-
renderCumToTailwind: () => renderCumToTailwind,
|
|
79
55
|
renderMarkdown: () => renderMarkdown,
|
|
80
56
|
renderToAST: () => renderToAST,
|
|
81
57
|
renderToHTML: () => renderToHTML,
|
|
@@ -85,9 +61,7 @@ __export(index_exports, {
|
|
|
85
61
|
renderToTailwind: () => renderToTailwind,
|
|
86
62
|
renderToTailwindWithClasses: () => renderToTailwindWithClasses,
|
|
87
63
|
renderToTailwindWithConfig: () => renderToTailwindWithConfig,
|
|
88
|
-
sanitizeHtml: () => sanitizeHtml
|
|
89
|
-
tokensToAST: () => tokensToAST,
|
|
90
|
-
tokensToJSONString: () => tokensToJSONString
|
|
64
|
+
sanitizeHtml: () => sanitizeHtml
|
|
91
65
|
});
|
|
92
66
|
module.exports = __toCommonJS(index_exports);
|
|
93
67
|
|
|
@@ -636,38 +610,6 @@ function sanitizeHtml(html) {
|
|
|
636
610
|
function basicSanitize(html) {
|
|
637
611
|
return html.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "").replace(/on\w+\s*=\s*"[^"]*"/gi, "").replace(/on\w+\s*=\s*'[^']*'/gi, "").replace(/javascript:/gi, "");
|
|
638
612
|
}
|
|
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
|
-
}
|
|
671
613
|
function extractDomain(url) {
|
|
672
614
|
try {
|
|
673
615
|
return new URL(url).hostname;
|
|
@@ -675,14 +617,6 @@ function extractDomain(url) {
|
|
|
675
617
|
return url;
|
|
676
618
|
}
|
|
677
619
|
}
|
|
678
|
-
function isValidUrl(url) {
|
|
679
|
-
try {
|
|
680
|
-
new URL(url);
|
|
681
|
-
return true;
|
|
682
|
-
} catch {
|
|
683
|
-
return false;
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
620
|
function parseOptions(options) {
|
|
687
621
|
const parsed = {};
|
|
688
622
|
if (!options) return parsed;
|
|
@@ -1651,6 +1585,37 @@ function renderToHTMLUnsafe(markdown3) {
|
|
|
1651
1585
|
});
|
|
1652
1586
|
}
|
|
1653
1587
|
|
|
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
|
+
|
|
1654
1619
|
// src/outputs/json.ts
|
|
1655
1620
|
function renderToJSON(markdown3, config) {
|
|
1656
1621
|
const engine = new ChangerawrMarkdown(config);
|
|
@@ -1732,305 +1697,9 @@ function tokensToAST(tokens) {
|
|
|
1732
1697
|
}
|
|
1733
1698
|
return ast;
|
|
1734
1699
|
}
|
|
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
|
-
}
|
|
1922
1700
|
function isParagraphContent(token) {
|
|
1923
1701
|
return ["text", "bold", "italic", "code", "link", "soft-break"].includes(token.type);
|
|
1924
1702
|
}
|
|
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
|
-
}
|
|
2034
1703
|
|
|
2035
1704
|
// src/index.ts
|
|
2036
1705
|
function createEngine(config) {
|
|
@@ -2042,8 +1711,7 @@ function createHTMLEngine(config) {
|
|
|
2042
1711
|
renderer: {
|
|
2043
1712
|
format: "html",
|
|
2044
1713
|
sanitize: true,
|
|
2045
|
-
allowUnsafeHtml: false
|
|
2046
|
-
...config?.parser
|
|
1714
|
+
allowUnsafeHtml: false
|
|
2047
1715
|
}
|
|
2048
1716
|
});
|
|
2049
1717
|
}
|
|
@@ -2053,8 +1721,7 @@ function createTailwindEngine(config) {
|
|
|
2053
1721
|
renderer: {
|
|
2054
1722
|
format: "tailwind",
|
|
2055
1723
|
sanitize: true,
|
|
2056
|
-
allowUnsafeHtml: false
|
|
2057
|
-
...config?.parser
|
|
1724
|
+
allowUnsafeHtml: false
|
|
2058
1725
|
}
|
|
2059
1726
|
});
|
|
2060
1727
|
}
|
|
@@ -2112,9 +1779,6 @@ var markdown2 = {
|
|
|
2112
1779
|
createDebugEngine,
|
|
2113
1780
|
createMinimalEngine,
|
|
2114
1781
|
createCustomEngine,
|
|
2115
|
-
// Standalone functions
|
|
2116
|
-
renderCum,
|
|
2117
|
-
parseCum,
|
|
2118
1782
|
// Main class
|
|
2119
1783
|
ChangerawrMarkdown,
|
|
2120
1784
|
// Extensions
|
|
@@ -2135,71 +1799,6 @@ var markdown2 = {
|
|
|
2135
1799
|
}
|
|
2136
1800
|
};
|
|
2137
1801
|
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
|
-
}
|
|
2203
1802
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2204
1803
|
0 && (module.exports = {
|
|
2205
1804
|
AlertExtension,
|
|
@@ -2210,42 +1809,18 @@ function createEngineWithPreset(presetName, additionalConfig) {
|
|
|
2210
1809
|
MarkdownParser,
|
|
2211
1810
|
MarkdownRenderer,
|
|
2212
1811
|
PerformanceTimer,
|
|
2213
|
-
astToJSONString,
|
|
2214
|
-
astToTokens,
|
|
2215
|
-
basicSanitize,
|
|
2216
|
-
compareTokens,
|
|
2217
|
-
createCumEngine,
|
|
2218
1812
|
createCustomEngine,
|
|
2219
1813
|
createDebugEngine,
|
|
2220
1814
|
createEngine,
|
|
2221
|
-
createEngineWithPreset,
|
|
2222
1815
|
createHTMLEngine,
|
|
2223
1816
|
createMinimalEngine,
|
|
2224
1817
|
createTailwindEngine,
|
|
2225
|
-
debounce,
|
|
2226
|
-
deepMerge,
|
|
2227
|
-
defaultTailwindClasses,
|
|
2228
1818
|
escapeHtml,
|
|
2229
1819
|
extractDomain,
|
|
2230
1820
|
generateId,
|
|
2231
|
-
getASTStats,
|
|
2232
|
-
getTokenStats,
|
|
2233
|
-
isBrowser,
|
|
2234
|
-
isNode,
|
|
2235
|
-
isValidUrl,
|
|
2236
1821
|
markdown,
|
|
2237
|
-
minimalClasses,
|
|
2238
|
-
parseASTFromJSON,
|
|
2239
|
-
parseCum,
|
|
2240
1822
|
parseMarkdown,
|
|
2241
1823
|
parseOptions,
|
|
2242
|
-
parseTokensFromJSON,
|
|
2243
|
-
presets,
|
|
2244
|
-
proseClasses,
|
|
2245
|
-
renderCum,
|
|
2246
|
-
renderCumToHtml,
|
|
2247
|
-
renderCumToJson,
|
|
2248
|
-
renderCumToTailwind,
|
|
2249
1824
|
renderMarkdown,
|
|
2250
1825
|
renderToAST,
|
|
2251
1826
|
renderToHTML,
|
|
@@ -2255,8 +1830,6 @@ function createEngineWithPreset(presetName, additionalConfig) {
|
|
|
2255
1830
|
renderToTailwind,
|
|
2256
1831
|
renderToTailwindWithClasses,
|
|
2257
1832
|
renderToTailwindWithConfig,
|
|
2258
|
-
sanitizeHtml
|
|
2259
|
-
tokensToAST,
|
|
2260
|
-
tokensToJSONString
|
|
1833
|
+
sanitizeHtml
|
|
2261
1834
|
});
|
|
2262
1835
|
//# sourceMappingURL=index.js.map
|