Skip to content

Commit

Permalink
fix(desc-text): properly patch linkify-it
Browse files Browse the repository at this point in the history
  • Loading branch information
brc-dd committed Sep 27, 2024
1 parent 9b41390 commit e035e7f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module.exports = {
],

rules: {
'vue/no-template-shadow': 'off'
'vue/no-template-shadow': 'off',
'no-console': 'warn'
}
}
26 changes: 20 additions & 6 deletions config/vite.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/

import { fileURLToPath } from 'node:url'
import MagicString from 'magic-string'
import icons from 'unplugin-icons/vite'
import { mergeConfig } from 'vite'

Expand All @@ -23,18 +24,27 @@ export const baseConfig = {
enforce: 'pre',
name: 'sefirot:patch-linkify-it',
transform(code, id) {
if (id.includes('markdown-it')) {
return code.replace(
'const text_separators = "[><\uFF5C]"',
'const text_separators = "[><\uFF00-\uFFEF]"' // https://www.fileformat.info/info/unicode/block/halfwidth_and_fullwidth_forms/index.htm
)
if (id.includes('linkify-it/lib/re.mjs')) {
const s = new MagicString(code)

const search = 'const text_separators = \'[><\\uff5c]\''
const replace = 'const text_separators = \'[><\\uff00-\\uffef]\''

const index = code.indexOf(search)
if (index !== -1) {
s.overwrite(index, index + search.length, replace)
}

return { code: s.toString(), map: s.generateMap({ source: id }) }
}
}
}
],

resolve: {
alias: { 'sefirot/': fileURLToPath(new URL('../lib/', import.meta.url)) },
alias: {
'sefirot/': fileURLToPath(new URL('../lib/', import.meta.url))
},

dedupe: [
'@sentry/browser',
Expand Down Expand Up @@ -69,6 +79,10 @@ export const baseConfig = {
'dayjs/plugin/relativeTime',
'dayjs/plugin/timezone',
'dayjs/plugin/utc',
'markdown-it > argparse',
'markdown-it > entities'
],
exclude: [
'markdown-it'
]
}
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"@types/file-saver": "^2.0.7",
"@types/qs": "^6.9.15",
"file-saver": "^2.0.5",
"magic-string": "^0.30.11",
"ofetch": "^1.3.4",
"qs": "^6.13.0",
"unplugin-icons": "^0.19.2"
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e035e7f

Please sign in to comment.