src/pipelines/markdown.js
import engine from 'remark'
import yamlConfig from 'remark-yaml-config'
import commentConfig from 'remark-comment-config'
import normalizeHeadings from 'remark-normalize-headings'
import squeezeParagraphs from 'remark-squeeze-paragraphs'
import annotations from 'remark-yaml-annotations'
import html from 'remark-html'
const remark = engine({gfm: true, yaml: true})
.use(yamlConfig)
.use(commentConfig)
.use(normalizeHeadings)
.use(squeezeParagraphs)
.use(annotations)
.use(commentConfig)
.use(html)
export class MarkdownPipeline {
constructor (file) {
Object.defineProperty(this, 'file', {
enumerable: false,
get: (() => file)
})
}
get ast() {
return remark.parse(this.file.contents)
}
get html() {
return remark.process(this.file.contents)
}
}
export default MarkdownPipeline