From 69c8e86245b59ff6ea8e496982d646a6b4eb4daf Mon Sep 17 00:00:00 2001 From: ocavue Date: Thu, 6 Feb 2025 15:56:08 +1100 Subject: [PATCH] fix: support sugar-high v9 (#75) --- package.json | 4 ++-- pnpm-lock.yaml | 10 +++++----- src/sugar-high.ts | 19 ++----------------- 3 files changed, 9 insertions(+), 24 deletions(-) diff --git a/package.json b/package.json index 09d9e1f..147437c 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,7 @@ "prosemirror-view": "^1.32.4", "refractor": "^4.8.1", "shiki": "^1.9.0 || ^2.0.0", - "sugar-high": "^0.6.1 || ^0.7.0 || ^0.8.0" + "sugar-high": "^0.6.1 || ^0.7.0 || ^0.8.0 || ^0.9.0" }, "peerDependenciesMeta": { "@types/hast": { @@ -119,7 +119,7 @@ "prosemirror-view": "^1.37.2", "refractor": "^4.8.1", "shiki": "^2.1.0", - "sugar-high": "^0.8.2", + "sugar-high": "^0.9.2", "tsup": "^8.3.5", "typescript": "^5.7.2", "vite": "^6.0.11", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b611089..c4b472b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -60,8 +60,8 @@ importers: specifier: ^2.1.0 version: 2.1.0 sugar-high: - specifier: ^0.8.2 - version: 0.8.2 + specifier: ^0.9.2 + version: 0.9.2 tsup: specifier: ^8.3.5 version: 8.3.5(postcss@8.5.1)(typescript@5.7.3) @@ -2401,8 +2401,8 @@ packages: engines: {node: '>=16 || 14 >=14.17'} hasBin: true - sugar-high@0.8.2: - resolution: {integrity: sha512-u/U1idCsHBMG9p5z88XYdEh9bxU19o5kueS0a3TKBYSFbTqtRqSyVqdbkFNXv/sDc9WYALCFT56EosyA0k1+3Q==} + sugar-high@0.9.2: + resolution: {integrity: sha512-jqbFM/pR6KlanZw87kBQZd0DO+C2mX8PML2q9VrTc3gz1c/jQtF2cZpBCnKDR4hRraUb15jS5WIxeRhua6gAXA==} supports-color@5.5.0: resolution: {integrity: sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==} @@ -5548,7 +5548,7 @@ snapshots: pirates: 4.0.5 ts-interface-checker: 0.1.13 - sugar-high@0.8.2: {} + sugar-high@0.9.2: {} supports-color@5.5.0: dependencies: diff --git a/src/sugar-high.ts b/src/sugar-high.ts index 954b641..7941cdb 100644 --- a/src/sugar-high.ts +++ b/src/sugar-high.ts @@ -1,26 +1,11 @@ import { Decoration } from 'prosemirror-view' -import { tokenize } from 'sugar-high' +import { tokenize, SugarHigh } from 'sugar-high' import type { Parser } from './types' export type { Parser } -/** - * Copied from https://github.com/huozhi/sugar-high/blob/v0.6.1/lib/index.js#L80-L107 - */ -const types = [ - 'identifier', - 'keyword', - 'string', - 'class', - 'property', - 'entity', - 'jsxliterals', - 'sign', - 'comment', - 'break', - 'space', -] as const +const types = SugarHigh.TokenTypes export function createParser(): Parser { return function parser({ content, pos }) {