feat: usage of ESM modules imports (instead of CommonJS)

Fixes #10

BREAKING CHANGE: This package is now pure ESM

BREAKING CHANGE: minimum supported Node.js >= 22.0.0
This commit is contained in:
2024-12-28 22:52:51 +01:00
parent b4a04d2e8e
commit aa24db4fac
13 changed files with 1322 additions and 1143 deletions

View File

@@ -14,7 +14,7 @@
* @param {(token: MarkdownItToken) => void} handler Callback function.
* @returns {void}
*/
const filterTokens = (params, type, handler) => {
export const filterTokens = (params, type, handler) => {
for (const token of params.parsers.markdownit.tokens) {
if (token.type === type) {
handler(token)
@@ -28,11 +28,6 @@ const filterTokens = (params, type, handler) => {
* @param {string} name HTML attribute name.
* @returns {RegExp} Regular Expression for matching.
*/
const getHtmlAttributeRe = (name) => {
export const getHtmlAttributeRe = (name) => {
return new RegExp(`\\s${name}\\s*=\\s*['"]?([^'"\\s>]*)`, "iu")
}
module.exports = {
filterTokens,
getHtmlAttributeRe,
}