How to use remark-html - 1 common examples

To help you get started, we’ve selected a few remark-html examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gatsbyjs / gatsby / packages / gatsby / lib / schema / markdown.js View on Github external
} from "graphql"

import {
  connectionFromArray,
  connectionArgs,
  connectionDefinitions,
} from "graphql-relay"

import inferGraphQLType from "./infer-graphql-type"
import { nodeInterface } from "./node"
import createPath from "../bootstrap/create-path"

// Setup Markdown parsing.
const remark = remarkAbstract({ commonmark: true })
const thing = {}
remarkHtmlAbstract(thing)

module.exports = directory =>
  new Promise((resolve, reject) => {
    let pages = []
    glob(`${directory}/**/*.md`, (err, files) => {
      if (err) return reject(err)
      _.each(files, file => {
        const page = {}
        page.src = fs.readFileSync(file, `utf-8`)
        const ast = remark.parse(page.src)
        page.ast = ast
        page.bodyHTML = thing.Compiler.prototype.compile(page.ast)
        page.headings = select(ast, `heading`).map(heading => ({
          value: _.first(select(heading, `text`).map(text => text.value)),
          depth: heading.depth,
        }))

remark-html

remark plugin to compile Markdown to HTML

MIT
Latest version published 1 year ago

Package Health Score

63 / 100
Full package analysis

Popular remark-html functions