forked from github/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create-processor.js
33 lines (32 loc) · 1.44 KB
/
create-processor.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const unified = require('unified')
const markdown = require('remark-parse')
const emoji = require('remark-gemoji-to-emoji')
const remark2rehype = require('remark-rehype')
const raw = require('rehype-raw')
const slug = require('rehype-slug')
const autolinkHeadings = require('rehype-autolink-headings')
const highlight = require('rehype-highlight')
const html = require('rehype-stringify')
const graphql = require('highlightjs-graphql').definer
const remarkCodeExtra = require('remark-code-extra')
const codeHeader = require('./plugins/code-header')
const rewriteLocalLinks = require('./plugins/rewrite-local-links')
const useEnglishHeadings = require('./plugins/use-english-headings')
const rewriteLegacyAssetPaths = require('./plugins/rewrite-legacy-asset-paths')
const wrapInElement = require('./plugins/wrap-in-element')
module.exports = function createProcessor (context) {
return unified()
.use(markdown)
.use(remarkCodeExtra, { transform: codeHeader })
.use(emoji)
.use(remark2rehype, { allowDangerousHTML: true })
.use(slug)
.use(useEnglishHeadings, context)
.use(autolinkHeadings, { behavior: 'wrap' })
.use(highlight, { languages: { graphql }, subset: false })
.use(raw)
.use(rewriteLegacyAssetPaths, context)
.use(wrapInElement, { selector: 'ol > li img', wrapper: 'span.procedural-image-wrapper' })
.use(rewriteLocalLinks, { languageCode: context.currentLanguage, version: context.currentVersion })
.use(html)
}