Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
7bbebb4574
|
|||
5c05a87981
|
|||
60826941fa
|
|||
29aab733b0
|
|||
7bb0e3a072
|
2
.npmignore
Normal file
2
.npmignore
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
src
|
||||||
|
node_modules
|
4
package-lock.json
generated
4
package-lock.json
generated
@@ -29,7 +29,7 @@
|
|||||||
"@types/qrcode": "^1.5.0",
|
"@types/qrcode": "^1.5.0",
|
||||||
"typescript": "^5.0.4"
|
"typescript": "^5.0.4"
|
||||||
},
|
},
|
||||||
"version": "0.1.1"
|
"version": "0.1.3"
|
||||||
},
|
},
|
||||||
"node_modules/@tootallnate/once": {
|
"node_modules/@tootallnate/once": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
@@ -3483,5 +3483,5 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"version": "0.1.1"
|
"version": "0.1.3"
|
||||||
}
|
}
|
||||||
|
@@ -1,16 +1,17 @@
|
|||||||
{
|
{
|
||||||
"name": "@doc-utils/markdown2html",
|
"name": "@doc-utils/markdown2html",
|
||||||
"version": "0.1.1",
|
"version": "0.1.3",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"registry": "https://gitea.home.jbrumond.me/api/packages/doc-utils/npm/"
|
"registry": "https://gitea.home.jbrumond.me/api/packages/doc-utils/npm/"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"tsc": "tsc"
|
"tsc": "tsc",
|
||||||
|
"clean": "rm -rf ./build"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"markdown2html": "./bin/markdown2html"
|
"markdown2html": "./bin/markdown2html"
|
||||||
},
|
},
|
||||||
"exports": "./build/index.js",
|
"main": "./src/index.ts",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/dompurify": "^2.3.3",
|
"@types/dompurify": "^2.3.3",
|
||||||
"@types/jsdom": "^20.0.0",
|
"@types/jsdom": "^20.0.0",
|
||||||
|
15
readme.md
15
readme.md
@@ -22,8 +22,11 @@ These are the primary projects used to render various types of content:
|
|||||||
# Update project npm config to refer to correct registry for the @doc-utils scope
|
# Update project npm config to refer to correct registry for the @doc-utils scope
|
||||||
echo '@doc-utils:registry=https://gitea.jbrumond.me/api/packages/doc-utils/npm/' >> ./.npmrc
|
echo '@doc-utils:registry=https://gitea.jbrumond.me/api/packages/doc-utils/npm/' >> ./.npmrc
|
||||||
|
|
||||||
# Install package
|
# Install package for programatic use
|
||||||
npm install --save @doc-utils/markdown2html
|
npm install --save @doc-utils/markdown2html
|
||||||
|
|
||||||
|
# Install globally for CLI usage
|
||||||
|
npm install --global @doc-utils/markdown2html
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@@ -50,13 +53,13 @@ async function main() {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Handling Frontmatter
|
### Handling front matter
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { process_frontmatter } from '@doc-utils/markdown2html';
|
import { process_frontmatter } from '@doc-utils/markdown2html';
|
||||||
|
|
||||||
const raw_content = `---
|
const raw_content = `---
|
||||||
title: Example Markdown with Frontmatter
|
title: Example Markdown with front matter
|
||||||
foo:
|
foo:
|
||||||
- bar
|
- bar
|
||||||
- baz
|
- baz
|
||||||
@@ -67,7 +70,7 @@ foo:
|
|||||||
|
|
||||||
const { frontmatter, markdown } = process_frontmatter(raw_content);
|
const { frontmatter, markdown } = process_frontmatter(raw_content);
|
||||||
|
|
||||||
console.log(frontmatter.title); // "Example Markdown with Frontmatter"
|
console.log(frontmatter.title); // "Example Markdown with front matter"
|
||||||
console.log(frontmatter.foo); // [ "bar", "baz" ]
|
console.log(frontmatter.foo); // [ "bar", "baz" ]
|
||||||
console.log(markdown); // "\n# This is some markdown\n"
|
console.log(markdown); // "\n# This is some markdown\n"
|
||||||
```
|
```
|
||||||
@@ -80,11 +83,11 @@ console.log(markdown); // "\n# This is some markdown\n"
|
|||||||
echo '# This is some markdown' | ./bin/markdown2html --base-url 'https://example.com' > output.html
|
echo '# This is some markdown' | ./bin/markdown2html --base-url 'https://example.com' > output.html
|
||||||
```
|
```
|
||||||
|
|
||||||
### Handling Frontmatter
|
### Handling front matter
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
filecontents="---
|
filecontents="---
|
||||||
title: Example Markdown with Frontmatter
|
title: Example Markdown with front matter
|
||||||
foo:
|
foo:
|
||||||
- bar
|
- bar
|
||||||
- baz
|
- baz
|
||||||
|
Reference in New Issue
Block a user