shahneshan
v2.0.1
Published
A markdown parser that converts to HTML.
Downloads
32
Maintainers
Readme
شهنشان (ShahNeshan)
این یک تجزیهگر Markdown قابل تنظیم است که میتواند با افزونهها و گزینههای پیکربندی گسترش یابد.
استفاده در مرورگر (CDN)
برای استفاده مستقیم در مرورگر بدون نصب از طریق npm:
<script src="https://unpkg.com/[email protected]/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 منتشر میشود.
ShahNeshan
A customizable Markdown parser that supports plugins and configuration.
Usage via CDN
To use ShahNeshan directly in a browser via CDN (no build tools required):
<script src="https://unpkg.com/[email protected]/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.
Installation (npm)
npm install shahneshanConfiguration
You 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:');Plugin System
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] });Custom Styles
Use customStyles in configuration:
configure({
customStyles: `
h1 { font-size: 2em; color: darkgreen; }
.highlight { background-color: yellow; }
`
});License
Originally licensed under MIT, this project is now released under the GNU GPLv3.
