https://github.com/shobhit-nagpal/marksmith
npm library to convert Markdown strings to HTML, written in TypeScript
https://github.com/shobhit-nagpal/marksmith
markdown markdown-to-html npm npm-package typescript
Last synced: 5 months ago
JSON representation
npm library to convert Markdown strings to HTML, written in TypeScript
- Host: GitHub
- URL: https://github.com/shobhit-nagpal/marksmith
- Owner: Shobhit-Nagpal
- Created: 2024-05-05T15:45:49.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-16T18:10:50.000Z (over 1 year ago)
- Last Synced: 2025-04-25T07:53:10.683Z (6 months ago)
- Topics: markdown, markdown-to-html, npm, npm-package, typescript
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/marksmithjs
- Size: 71.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Marksmith
**Marksmith** is a lightweight npm library written in TypeScript for converting Markdown documents into HTML. It provides a simple and efficient way to seamlessly integrate Markdown parsing and HTML generation into your JavaScript or TypeScript projects.
## Features
- Convert Markdown documents to HTML with ease.
- Fully written in TypeScript for improved type safety and developer experience.
- Lightweight and dependency-free, ensuring minimal impact on your project's bundle size.## Supported Markdown Elements
**Marksmith** currently supports the elements mentioned below. With further releases, it'll support more markdown elements.
Note: Currently, there's only one level of parsing of bold, italic, code tags. Nested parsing will be supported in future versions.
- Headings (`#`, `##`, `###`, etc.)
- Bold (`**text**`)
- Italic (`*text*`)
- Code (\`code\`)
- Links (`[text](url)`)
- Images (``)
- Lists (both ordered and unordered)
- Blockquotes (`> text`)
- Horizontal rules (`---`)
- Inline code (`` `code` ``)
- Table## Installation
You can install **Marksmith** via npm:
```bash
npm i marksmithjs
```## Usage
```typescript
import { markdownToHtml } from 'marksmithjs';const markdownText = '# Hello, World!\n\nThis is a *Markdown* example.';
try {
const htmlOutput = markdownToHtml(markdownText);
console.log(htmlOutput);
} catch (err) {
console.error("Markdown syntax not valid");
}
```The output will be a div tag with all the markdown converted to HTML within the tag.
An error is thrown when the input markdown does not follow markdown rules such as incomplete bold / italic / code tags.
## Contributing
Contributions are welcome! Feel free to open an issue or submit a pull request.