این یک تجزیهگر Markdown قابل تنظیم است که میتواند با افزونهها و گزینههای پیکربندی گسترش یابد.
برای استفاده مستقیم در مرورگر بدون نصب از طریق npm:
<script src="https://unpkg.com/shahneshan@2.0.0/dist/shahneshan.umd.js"></script>
<script>
const markdown = '# سلام دنیا!';
const html = shahneshan.markdownToOutput(markdown);
document.body.innerHTML = html;
</script>شما میتوانید این کتابخانه را با فراخوانی تابع configure تنظیم و سفارشیسازی کنید. به عنوان مثال:
shahneshan.configure({
customStyles: `
h1 { color: blue; }
mark { background-color: yellow; }
`,
plugins: [
{
name: "moreEmoji",
beforeParse: (text) => text.replace(/:khande:/g, "😊")
}
]
});
const html = shahneshan.markdownToOutput('# سلام! :khande:');از سال ۲۰۲۵ به بعد، این پروژه تحت مجوز GNU GPLv3 منتشر میشود.
A customizable Markdown parser that supports plugins and configuration.
To use ShahNeshan directly in a browser via CDN (no build tools required):
<script src="https://unpkg.com/shahneshan@2.0.0/dist/shahneshan.umd.js"></script>
<script>
const markdown = '# Hello, world!';
const html = shahneshan.markdownToOutput(markdown);
document.body.innerHTML = html;
</script>The library is exposed globally as shahneshan.
npm install shahneshanYou can configure the parser using configure():
import { configure, markdownToOutput } from 'shahneshan';
configure({
customStyles: `
h1 { color: blue; }
mark { background-color: yellow; }
`,
plugins: [
{
name: "moreEmoji",
beforeParse: (text) => text.replace(/:khande:/g, "😊")
}
]
});
const html = markdownToOutput('# Hello! :khande:');Each plugin can define the following hooks:
beforeParse(text)nodeTransform(node)afterParse(html)
Example:
const emojiPlugin = {
name: "moreEmoji",
beforeParse: (text) => text.replace(/:heart:/g, "❤️")
};
configure({ plugins: [emojiPlugin] });Use customStyles in configuration:
configure({
customStyles: `
h1 { font-size: 2em; color: darkgreen; }
.highlight { background-color: yellow; }
`
});Originally licensed under MIT, this project is now released under the GNU GPLv3.