"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.processorWithMath = exports.processor = void 0;
var _unified = require("unified");
var _remarkParse = _interopRequireDefault(require("remark-parse"));
var _remarkGfm = _interopRequireDefault(require("remark-gfm"));
var _remarkMath = _interopRequireDefault(require("remark-math"));
var _remarkBreaks = _interopRequireDefault(require("remark-breaks"));
var _remarkRehype = _interopRequireDefault(require("remark-rehype"));
var _browser = _interopRequireDefault(require("rehype-mathjax/browser"));
var _rehypeSlug = _interopRequireDefault(require("rehype-slug"));
var _rehypeRaw = _interopRequireDefault(require("rehype-raw"));
var _rehypeFormat = _interopRequireDefault(require("rehype-format"));
var _rehypeSanitize = _interopRequireDefault(require("rehype-sanitize"));
var _rehypeStringify = _interopRequireDefault(require("rehype-stringify"));
var _sanitizeSchema = _interopRequireDefault(require("./sanitize-schema"));
// mdString -> mdast -> html ast -> html
const processor = exports.processor = (0, _unified.unified)()
// Handles markdown basic syntax
// https://github.com/remarkjs/remark/tree/main
.use(_remarkParse.default)
// Handle markdown extension syntax
// https://github.com/remarkjs/remark-gfm
.use(_remarkGfm.default)
// https://github.com/remarkjs/remark-breaks
.use(_remarkBreaks.default).use(_remarkRehype.default, {
  allowDangerousHtml: true
}) // convert mdast -> hast
// https://www.npmjs.com/package/rehype-raw
.use(_rehypeRaw.default)
// https://www.npmjs.com/package/rehype-format
.use(_rehypeFormat.default, {
  blanks: ['pre', 'code']
})
// https://github.com/rehypejs/rehype-slug
.use(_rehypeSlug.default)
// https://github.com/rehypejs/rehype-sanitize
.use(_rehypeSanitize.default, _sanitizeSchema.default)
// https://github.com/rehypejs/rehype/tree/main/packages/rehype-stringify
.use(_rehypeStringify.default);

// transform rules: https://github.com/syntax-tree/mdast-util-to-hast

// mdString -> mdast -> html ast -> html
const processorWithMath = exports.processorWithMath = (0, _unified.unified)()
// Handles markdown basic syntax
// https://github.com/remarkjs/remark/tree/main
.use(_remarkParse.default)
// Handle markdown extension syntax
// https://github.com/remarkjs/remark-gfm
.use(_remarkGfm.default)
// https://github.com/remarkjs/remark-math
.use(_remarkMath.default)
// https://github.com/remarkjs/remark-breaks
.use(_remarkBreaks.default).use(_remarkRehype.default, {
  allowDangerousHtml: true
}) // convert mdast -> hast
// https://www.npmjs.com/package/rehype-mathjax
.use(_browser.default, {
  displayMath: ['$$', '$$']
})
// https://www.npmjs.com/package/rehype-raw
.use(_rehypeRaw.default)
// https://www.npmjs.com/package/rehype-format
.use(_rehypeFormat.default, {
  blanks: ['pre', 'code']
})
// https://github.com/rehypejs/rehype-slug
.use(_rehypeSlug.default)
// https://github.com/rehypejs/rehype-sanitize
.use(_rehypeSanitize.default, _sanitizeSchema.default)
// https://github.com/rehypejs/rehype/tree/main/packages/rehype-stringify
.use(_rehypeStringify.default);