mirror of
https://github.com/cupcakearmy/markdown-it-import.git
synced 2024-12-21 15:56:26 +00:00
readme
This commit is contained in:
parent
6f59a120ef
commit
003ef89da6
55
README.md
55
README.md
@ -1,6 +1,6 @@
|
||||
# Markdown import plugin
|
||||
|
||||
This is a `markdown-it` plugin to include/import raw files from your filesystem.
|
||||
This is a `markdown-it` plugin to include/import any raw files from your filesystem.
|
||||
|
||||
## Features
|
||||
|
||||
@ -8,6 +8,7 @@ This is a `markdown-it` plugin to include/import raw files from your filesystem.
|
||||
- Recursive import
|
||||
- Import whatever file
|
||||
- Customizable RegEx
|
||||
- Tested
|
||||
|
||||
## Installation
|
||||
|
||||
@ -15,6 +16,58 @@ This is a `markdown-it` plugin to include/import raw files from your filesystem.
|
||||
npm install @nicco.io/markdown-it-import
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Include a whole file
|
||||
|
||||
```md
|
||||
@import(somefile.md)
|
||||
```
|
||||
|
||||
Import specific lines
|
||||
|
||||
```md
|
||||
@import(snippet.ts)[5-10]
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```md
|
||||
<!-- main.md -->
|
||||
|
||||
# Title
|
||||
|
||||
@import(chapter.md)
|
||||
|
||||
<!-- This should be tripple ` -->
|
||||
|
||||
`ts
|
||||
@import(sum.ts)
|
||||
`
|
||||
```
|
||||
|
||||
```md
|
||||
## Chapter
|
||||
|
||||
I will be included
|
||||
```
|
||||
|
||||
```ts
|
||||
// sum.ts
|
||||
export function sum(a: number, b: number): number {
|
||||
return a + b
|
||||
}
|
||||
```
|
||||
|
||||
```ts
|
||||
import MarkdownIt from 'markdown-it'
|
||||
import fs from 'node:fs/promises'
|
||||
import { Options, importPlugin } from '@nicco.io/markdown-it-import'
|
||||
|
||||
const input = await fs.readFile('./main.md', 'utf-8')
|
||||
const html = MarkdownIt().use(importPlugin).render(input)
|
||||
```
|
||||
|
||||
## Similar works
|
||||
|
||||
There are two very similar plugins, which this one is def. inspired by, however while the one can only import `.md` files, the other cannot select single lines.
|
||||
|
Loading…
Reference in New Issue
Block a user