v0.0.2
This commit is contained in:
parent
d086c1d493
commit
0f1d41a991
30 changed files with 1013 additions and 1536 deletions
16
markdown.js
16
markdown.js
|
@ -1,7 +1,9 @@
|
|||
const hljs = require('highlight.js')
|
||||
const { marked } = require('marked')
|
||||
const { markedHighlight } = require('marked-highlight')
|
||||
const matter = require('gray-matter')
|
||||
import hljs from 'highlight.js'
|
||||
import { marked } from 'marked'
|
||||
import { markedHighlight } from 'marked-highlight'
|
||||
import matter from 'gray-matter'
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
|
||||
marked.use(markedHighlight({
|
||||
langPrefix: 'hljs language-',
|
||||
|
@ -11,7 +13,7 @@ marked.use(markedHighlight({
|
|||
}
|
||||
}))
|
||||
|
||||
function parseMD(file) {
|
||||
export function parseMD(file) {
|
||||
|
||||
const fileContents = fs.readFileSync(path.join("./", file), 'utf8')
|
||||
|
||||
|
@ -25,13 +27,13 @@ function parseMD(file) {
|
|||
}
|
||||
}
|
||||
|
||||
const renderer = new marked.Renderer();
|
||||
const renderer = new marked.Renderer()
|
||||
renderer.paragraph = (text) => {
|
||||
return text.text
|
||||
}
|
||||
|
||||
|
||||
function parseMarkdown(obj) {
|
||||
export function parseMarkdown(obj) {
|
||||
for (let key in obj) {
|
||||
if (typeof obj[key] === 'object' && obj[key] !== null) {
|
||||
if (Array.isArray(obj[key])) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue