diff --git a/src/main.ts b/src/main.ts index f86856c..161852c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,4 +1,4 @@ -import { Editor, MarkdownView, Notice, Plugin, Menu } from 'obsidian'; +import { Editor, MarkdownView, Notice, Plugin, Menu, Platform } from 'obsidian'; import { Language, TranslationKey, I18n } from './i18n'; import { ContextData, ContextType, DEFAULT_SETTINGS, EasyCopySettings, LinkFormat } from './type'; import { EasyCopySettingTab } from './settingTab'; @@ -96,12 +96,20 @@ export default class EasyCopy extends Plugin { // 根据光标位置解析内容类型 const beforeCursor = curLine.slice(0, curCh); // 光标前的内容 const afterCursor = curLine.slice(curCh); // 光标后的内容 + + + // iOS 16.4 之前不支持后视(Lookbehinds),但支持前视(Lookaheads) + // 所以针对 iOS 平台使用只带前视的正则表达式,其他平台使用完整版本 + const italicRegex = Platform.isIosApp ? + /\*([^*]+)\*(?!\*)/g : // iOS 版本:只使用前视,不使用后视 + /(? 斜体 > 高亮 > 删除线 > 行内代码 > 行内Latex > 块ID const matchers = [ { type: ContextType.BOLD, regex: /\*\*([^*]+)\*\*/g , enable: !this.settings.customizeTargets || this.settings.enableBold}, // 使用前后断言 (?