Refactor rowheaders table rewrite plugin (#37576)
This commit is contained in:
@@ -23,6 +23,7 @@ import useEnglishHeadings from './plugins/use-english-headings.js'
|
||||
import wrapInElement from './plugins/wrap-in-element.js'
|
||||
import headingLinks from './plugins/heading-links.js'
|
||||
import rewriteTheadThScope from './plugins/rewrite-thead-th-scope.js'
|
||||
import rewriteForRowheaders from './plugins/rewrite-for-rowheaders.js'
|
||||
|
||||
// plugins aren't designed to be used more than once,
|
||||
// this workaround lets us do that
|
||||
@@ -30,17 +31,6 @@ import rewriteTheadThScope from './plugins/rewrite-thead-th-scope.js'
|
||||
const wrapperForImages = () =>
|
||||
wrapInElement({ selector: 'ol > li img', wrapper: 'span.procedural-image-wrapper' })
|
||||
|
||||
const wrapperForRowheadersTbody = () =>
|
||||
wrapInElement({
|
||||
selector: '.rowheaders tbody tr td:first-child',
|
||||
wrapper: 'th',
|
||||
// This moves what it finds in the selector inside the wrapper.
|
||||
rewrite: true,
|
||||
wrapperAdditionalAttributes: {
|
||||
scope: 'row',
|
||||
},
|
||||
})
|
||||
|
||||
export default function createProcessor(context) {
|
||||
return unified()
|
||||
.use(process.env.COMMONMARK ? markdownNext : markdown)
|
||||
@@ -58,7 +48,7 @@ export default function createProcessor(context) {
|
||||
.use(raw)
|
||||
.use(wrapperForImages)
|
||||
.use(rewriteTheadThScope)
|
||||
.use(wrapperForRowheadersTbody)
|
||||
.use(rewriteForRowheaders)
|
||||
.use(rewriteImgSources)
|
||||
.use(rewriteAssetImgTags)
|
||||
.use(rewriteLocalLinks, context)
|
||||
|
||||
Reference in New Issue
Block a user