Skip to content

Commit

Permalink
fix typescript errors, fix subpath exports (#4)
Browse files Browse the repository at this point in the history
* fix typescript errors

* add changelog entry
  • Loading branch information
KonnorRogers authored Sep 17, 2024
1 parent a3ef460 commit d400427
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Prism Changelog

## 1.29.0-fix.5 (09/17/2024)

- Fixed subpath exports for CDNs like JSPM.io and TS errors with regexes. [#4](https://github.com/KonnorRogers/prism-esm/pull/4)

## 1.29.0-fix.2 (11-28-2023)

- Added `.d.ts` types.
Expand Down
5 changes: 5 additions & 0 deletions components/prism-cshtml.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,30 +83,35 @@ export function loader (Prism, options) {
/[^<]/.source +
'|' +
// all tags that are not the start tag
// @ts-expect-error
// eslint-disable-next-line regexp/strict
/<\/?(?!\1\b)/.source + tagContent +
'|' +
// nested start tag
nested(
// @ts-expect-error
// eslint-disable-next-line regexp/strict
/<\1/.source + tagAttrs + /\s*>/.source +
'(?:' +
(
/[^<]/.source +
'|' +
// all tags that are not the start tag
// @ts-expect-error
// eslint-disable-next-line regexp/strict
/<\/?(?!\1\b)/.source + tagContent +
'|' +
'<self>'
) +
')*' +
// @ts-expect-error
// eslint-disable-next-line regexp/strict
/<\/\1\s*>/.source,
2
)
) +
')*' +
// @ts-expect-error
// eslint-disable-next-line regexp/strict
/<\/\1\s*>/.source +
'|' +
Expand Down
6 changes: 6 additions & 0 deletions components/prism-cue.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,19 @@ export function loader (Prism, options) {
}
// https://cuelang.org/docs/references/spec/

// @ts-expect-error
// eslint-disable-next-line regexp/strict
var stringEscape = /\\(?:(?!\2)|\2(?:[^()\r\n]|\([^()]*\)))/.source;
// @ts-expect-error
// eslint-disable-next-line regexp/strict
var stringTypes = /"""(?:[^\\"]|"(?!""\2)|<esc>)*"""/.source +
// @ts-expect-error
// eslint-disable-next-line regexp/strict
'|' + /'''(?:[^\\']|'(?!''\2)|<esc>)*'''/.source +
// @ts-expect-error
// eslint-disable-next-line regexp/strict
'|' + /"(?:[^\\\r\n"]|"(?!\2)|<esc>)*"/.source +
// @ts-expect-error
// eslint-disable-next-line regexp/strict
'|' + /'(?:[^\\\r\n']|'(?!\2)|<esc>)*'/.source;
var stringLiteral = '(?:' + stringTypes.replace(/<esc>/g, stringEscape) + ')';
Expand All @@ -27,6 +32,7 @@ export function loader (Prism, options) {
greedy: true
},
'string-literal': {
// @ts-expect-error
// eslint-disable-next-line regexp/strict
pattern: RegExp(/(^|[^#"'\\])(#*)/.source + stringLiteral + /(?!["'])\2/.source),
lookbehind: true,
Expand Down
2 changes: 2 additions & 0 deletions components/prism-d.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ export function loader (Prism, options) {
/\bq"((?!\d)\w+)$[\s\S]*?^\1"/.source,

// q"//", q"||", etc.
// @ts-expect-error
// eslint-disable-next-line regexp/strict
/\bq"(.)[\s\S]*?\2"/.source,

// @ts-expect-error
// eslint-disable-next-line regexp/strict
/(["`])(?:\\[\s\S]|(?!\3)[^\\])*\3[cwd]?/.source
].join('|'), 'm'),
Expand Down
1 change: 1 addition & 0 deletions components/prism-markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ export function loader (Prism, options) {
'strike': {
// ~~strike through~~
// ~strike~
// @ts-expect-error
// eslint-disable-next-line regexp/strict
pattern: createInline(/(~~?)(?:(?!~)<inner>)+\2/.source),
lookbehind: true,
Expand Down
4 changes: 4 additions & 0 deletions components/prism-perl.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export function loader (Prism, options) {
/([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1/.source,

// q a...a
// @ts-expect-error
// eslint-disable-next-line regexp/strict
/([a-zA-Z0-9])(?:(?!\2)[^\\]|\\[\s\S])*\2/.source,

Expand Down Expand Up @@ -71,6 +72,7 @@ export function loader (Prism, options) {
/([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1/.source,

// m a...a
// @ts-expect-error
// eslint-disable-next-line regexp/strict
/([a-zA-Z0-9])(?:(?!\2)[^\\]|\\[\s\S])*\2/.source,

Expand All @@ -93,10 +95,12 @@ export function loader (Prism, options) {
'(?:' +
[
// s/.../.../
// @ts-expect-error
// eslint-disable-next-line regexp/strict
/([^a-zA-Z0-9\s{(\[<])(?:(?!\2)[^\\]|\\[\s\S])*\2(?:(?!\2)[^\\]|\\[\s\S])*\2/.source,

// s a...a...a
// @ts-expect-error
// eslint-disable-next-line regexp/strict
/([a-zA-Z0-9])(?:(?!\3)[^\\]|\\[\s\S])*\3(?:(?!\3)[^\\]|\\[\s\S])*\3/.source,

Expand Down
20 changes: 20 additions & 0 deletions package-lock.json

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

7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
"engines": {
"node": ">=6"
},
"exports": {
".": "./prism.js",
"./*": "./*"
},
"files": [
"components/**/*.js",
"components/**/*.d.ts",
Expand Down Expand Up @@ -86,6 +90,7 @@
"regexpp": "^3.2.0",
"scslre": "^0.1.6",
"simple-git": "^3.3.0",
"typescript": "^5.6.2",
"webfont": "^9.0.0",
"yargs": "^17.7.2"
},
Expand All @@ -106,4 +111,4 @@
"prism-core.d.ts"
]
}
}
}

0 comments on commit d400427

Please sign in to comment.