1
0
mirror of synced 2025-12-20 02:19:14 -05:00

Refactor Thead Th scope Markdown plugin (#37299)

This commit is contained in:
Peter Bengtsson
2023-05-30 11:06:08 -04:00
committed by GitHub
parent 63959daf83
commit 76ddf3a70c
4 changed files with 39 additions and 26 deletions

View File

@@ -22,6 +22,7 @@ import rewriteAssetImgTags from './plugins/rewrite-asset-img-tags.js'
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'
// plugins aren't designed to be used more than once,
// this workaround lets us do that
@@ -29,28 +30,6 @@ import headingLinks from './plugins/heading-links.js'
const wrapperForImages = () =>
wrapInElement({ selector: 'ol > li img', wrapper: 'span.procedural-image-wrapper' })
const wrapperForTheadThScope = () =>
wrapInElement({
selector: 'thead th',
wrapper: 'th',
// This moves what it finds in the selector inside the wrapper.
rewrite: true,
wrapperAdditionalAttributes: {
scope: 'col',
},
})
const wrapperForTbodyThScope = () =>
wrapInElement({
selector: 'thead th',
wrapper: 'th',
// This moves what it finds in the selector inside the wrapper.
rewrite: true,
wrapperAdditionalAttributes: {
scope: 'col',
},
})
const wrapperForRowheadersTbody = () =>
wrapInElement({
selector: '.rowheaders tbody tr td:first-child',
@@ -78,8 +57,7 @@ export default function createProcessor(context) {
})
.use(raw)
.use(wrapperForImages)
.use(wrapperForTheadThScope)
.use(wrapperForTbodyThScope)
.use(rewriteTheadThScope)
.use(wrapperForRowheadersTbody)
.use(rewriteImgSources)
.use(rewriteAssetImgTags)