rehype-prefixwords
v1.1.0
Published
Rehype plugins that assigns classes to emphasised words based on prefixes or suffixes
Downloads
14
Readme
rehype-prefixwords
Rehype plugin to style emphasised (e.g. *word* in MD or <em> in HTML) words depending on specified prefixes or suffixes.
Example Usage
This project is also tested to be compatible with astro markdown
# Header
*transgender*
*transform*
nonrelevant
*non-exclusionary*
*lesbian*
*debian*
import fs from 'node:fs/promises'
import { reporter } from 'vfile-reporter'
import { unified } from 'unified'
import rehypePrefixWords from 'rehype-prefixwords'
import rehypeDocument from 'rehype-document'
import rehypeFormat from 'rehype-format'
import rehypeStringify from 'rehype-stringify'
import remarkRehype from 'remark-rehype'
import remarkParse from 'remark-parse'
const document = await fs.readFile('./src/TEST.md', 'utf8');
const file = await unified()
.use(remarkParse)
.use(remarkRehype)
.use(rehypePrefixWords, {
prefixes: [
["trans", "transgender"],
["non", "nonbinary"]
],
suffixes: [
["bian", "lesbian"]
]})
.use(rehypeDocument)
.use(rehypeFormat)
.use(rehypeStringify)
.process(document)
console.error(reporter(file))
Gradient stolen from gaydient
em.transgender {
background: linear-gradient(to right, rgb(85, 205, 252), rgb(179, 157, 233), rgb(247, 168, 184), rgb(246, 216, 221), rgb(255, 255, 255) 45%, rgb(255, 255, 255), rgb(255, 255, 255) 55%, rgb(246, 216, 221), rgb(247, 168, 184), rgb(179, 157, 233), rgb(85, 205, 252));
background-clip: text;
color: transparent;
font-style: normal;
}
em.nonbinary {
background: linear-gradient(to right, rgb(253, 219, 0), rgb(238, 212, 143), rgb(255, 255, 255) 30%, rgb(255, 255, 255), rgb(255, 255, 255) 36%, rgb(212, 181, 222), rgb(156, 92, 212), rgb(88, 50, 96), rgb(0, 0, 0));
background-clip: text;
color: transparent;
font-style: normal;
}
em.lesbian {
background: linear-gradient(to right, rgb(213, 44, 0), rgb(226, 150, 136), rgb(255, 255, 255) 45%, rgb(255, 255, 255), rgb(255, 255, 255) 55%, rgb(210, 127, 164), rgb(162, 2, 98));
background-clip: text;
color: transparent;
font-style: normal;
}
License
This project is dual-licensed under either the AGPL-3.0 or the OQL-1.1, of your choice