@blankdotpage/cake 0.1.58 → 0.1.59

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"italic.d.ts","sourceRoot":"","sources":["../../../../src/cake/extensions/italic/italic.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAInB,MAAM,oBAAoB,CAAC;AAsC5B,eAAO,MAAM,eAAe,EAAE,aA+H7B,CAAC"}
1
+ {"version":3,"file":"italic.d.ts","sourceRoot":"","sources":["../../../../src/cake/extensions/italic/italic.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAInB,MAAM,oBAAoB,CAAC;AAuC5B,eAAO,MAAM,eAAe,EAAE,aAkI7B,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { CursorSourceBuilder } from "../../core/mapping/cursor-source-map";
2
+ import { hasInlineMarkerBoundaryBefore } from "../shared/inline-marker-boundary";
2
3
  const ITALIC_KIND = "italic";
3
4
  function findItalicClose(source, start, end, marker) {
4
5
  if (marker === "_") {
@@ -44,6 +45,9 @@ export const italicExtension = (editor) => {
44
45
  if (char !== "_" && char !== "*") {
45
46
  return null;
46
47
  }
48
+ if (char === "_" && !hasInlineMarkerBoundaryBefore(source, start)) {
49
+ return null;
50
+ }
47
51
  // Don't match ** (that's bold)
48
52
  if (char === "*" && source[start + 1] === "*") {
49
53
  return null;
@@ -0,0 +1,2 @@
1
+ export declare function hasInlineMarkerBoundaryBefore(source: string, markerStart: number): boolean;
2
+ //# sourceMappingURL=inline-marker-boundary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inline-marker-boundary.d.ts","sourceRoot":"","sources":["../../../../src/cake/extensions/shared/inline-marker-boundary.ts"],"names":[],"mappings":"AAEA,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAClB,OAAO,CAMT"}
@@ -0,0 +1,7 @@
1
+ const WORD_CHARACTER_PATTERN = /[\p{L}\p{N}_]/u;
2
+ export function hasInlineMarkerBoundaryBefore(source, markerStart) {
3
+ if (markerStart <= 0) {
4
+ return true;
5
+ }
6
+ return !WORD_CHARACTER_PATTERN.test(source[markerStart - 1] ?? "");
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blankdotpage/cake",
3
- "version": "0.1.58",
3
+ "version": "0.1.59",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",