mirror of
https://github.com/utopia-os/utopia-ui.git
synced 2026-02-06 09:55:47 +00:00
chore(lib): add marked dependency and cleanup
This commit is contained in:
parent
df62f39b8f
commit
6f45c47765
@ -118,6 +118,7 @@
|
||||
"leaflet": "^1.9.4",
|
||||
"leaflet.locatecontrol": "^0.79.0",
|
||||
"maplibre-gl": "^5.16.0",
|
||||
"marked": "^16.4.2",
|
||||
"radash": "^12.1.0",
|
||||
"react-colorful": "^5.6.1",
|
||||
"react-dropzone": "^14.3.8",
|
||||
@ -141,5 +142,8 @@
|
||||
"#types/*": "./src/types/*",
|
||||
"#src/*": "./src/*",
|
||||
"#root/*": "./*"
|
||||
},
|
||||
"overrides": {
|
||||
"marked": "^16.3.0"
|
||||
}
|
||||
}
|
||||
|
||||
19
lib/src/Components/TipTap/utils/configureMarked.ts
Normal file
19
lib/src/Components/TipTap/utils/configureMarked.ts
Normal file
@ -0,0 +1,19 @@
|
||||
/**
|
||||
* Configure marked.js with emStrongMask hook to prevent underscores
|
||||
* in hashtags from being interpreted as emphasis delimiters.
|
||||
*/
|
||||
import { Marked } from 'marked'
|
||||
|
||||
import type { marked } from 'marked'
|
||||
|
||||
const HASHTAG_REGEX = /#[a-zA-Z0-9À-ÖØ-öø-ʸ_-]+/g
|
||||
|
||||
function emStrongMask(src: string): string {
|
||||
return src.replace(HASHTAG_REGEX, (match) => match.replace(/_/g, 'a'))
|
||||
}
|
||||
|
||||
export function createConfiguredMarked(): typeof marked {
|
||||
const instance = new Marked()
|
||||
instance.use({ hooks: { emStrongMask } })
|
||||
return instance as unknown as typeof marked
|
||||
}
|
||||
2714
package-lock.json
generated
2714
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -4,5 +4,8 @@
|
||||
"workspaces": [
|
||||
"app",
|
||||
"lib"
|
||||
]
|
||||
],
|
||||
"overrides": {
|
||||
"marked": "^16.3.0"
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user