svelte-render-md
Advanced tools
Comparing version 0.0.4 to 0.0.5
import RenderHTML from "./RenderHTML.svelte"; | ||
import { parseContent } from "./md_to_html"; | ||
export { RenderHTML, parseContent }; |
@@ -0,0 +0,0 @@ export function mdToHTML(mdStr: any): any; |
@@ -5,3 +5,5 @@ import * as yaml from 'js-yaml' | ||
function mdToHTML(mdStr) { | ||
let converter = new showdown.Converter(); | ||
let converter = new showdown.Converter({ | ||
tables: true | ||
}); | ||
return converter.makeHtml(mdStr);; | ||
@@ -21,6 +23,6 @@ } | ||
} | ||
return { | ||
frontmatter: yaml.load(yamlStr), | ||
content: mdStr | ||
frontmatter: yaml.load(yamlStr), | ||
content: mdStr | ||
} | ||
@@ -27,0 +29,0 @@ } |
{ | ||
"name": "svelte-render-md", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"exports": { | ||
"./package.json": "./package.json", | ||
".": "./index.js", | ||
"./md_to_html": "./md_to_html.js", | ||
"./RenderHTML.svelte": "./RenderHTML.svelte" | ||
"./RenderHTML.svelte": "./RenderHTML.svelte", | ||
"./md_to_html": "./md_to_html.js" | ||
}, | ||
@@ -10,0 +10,0 @@ "module": "index.js", |
@@ -8,5 +8,11 @@ # svelte-render-md | ||
``` | ||
import { readMDFile } from "svelte-render-md"; | ||
let mdFile = readMDFile("myFile.md"); | ||
let frontmatter = mdFile.frontmatter; | ||
import { parseContent } from "svelte-render-md"; | ||
let mdContent = "---\n | ||
name: 'test'\n | ||
description: 'This is a test'\n | ||
---\n | ||
# Test\n | ||
This is to test the content parser\n"; | ||
let content = parseContent(mdContent); | ||
let frontmatter = content.frontmatter; | ||
``` | ||
@@ -22,8 +28,15 @@ ### Render md as HTML | ||
``` | ||
You can also render an md file as html: | ||
Combine the two to render file content as html and retrieve frontmatter: | ||
``` | ||
<script> | ||
import { RenderHTML, readMDFile } from "svelte-render-md"; | ||
let mdFile = readMDFile("myFile.md"); | ||
let mdStr = mdFile.content; | ||
import { RenderHTML, parseContent } from "svelte-render-md"; | ||
let mdContent = "---\n | ||
name: 'test'\n | ||
description: 'This is a test'\n | ||
---\n | ||
# Test\n | ||
This is to test the content parser\n"; | ||
let content = parseContent(mdContent); | ||
let frontmatter = content.frontmatter; | ||
let mdStr = content.content; | ||
</script> | ||
@@ -30,0 +43,0 @@ |
@@ -0,0 +0,0 @@ /** @typedef {typeof __propDef.props} RenderHtmlProps */ |
Sorry, the diff of this file is not supported yet
4098
60
44