From 815ff3d6ca927c81ea112e78c0418922be07013d Mon Sep 17 00:00:00 2001 From: seppiabrilla Date: Thu, 4 Jan 2024 16:25:20 +0100 Subject: [PATCH] fixed backslash in regex --- src/Parser.ts | 2 +- tests/Parser.test.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Parser.ts b/src/Parser.ts index 169a4a1..2a94ebf 100644 --- a/src/Parser.ts +++ b/src/Parser.ts @@ -1,7 +1,7 @@ import { MarkdownElement } from './ObsidianElements'; import { Token, MarkdownToken} from './Tokens'; -const REGEX = "([a-zA-Z0-9 \\^\\/,\\.\\*\\!\\@\\#\\%\\^\\&()\\{}_\\-=\\+`~;:'\"<>\\?\\|\\n\\t]+)"; +const REGEX = "([a-zA-Z0-9 \\^\\/,\\.\\*\\!\\@\\#\\%\\^\\&()\\{}_\\-=\\+`~;:'\"<>\\?\\|\\\\n\\t]+)"; const CHAR_TO_ESCAPE = ['\\','.','$','*','+','?','(',')','[','{,','|', ']', '-'] function addEscape(str:string){ diff --git a/tests/Parser.test.ts b/tests/Parser.test.ts index e4889d2..5c48736 100644 --- a/tests/Parser.test.ts +++ b/tests/Parser.test.ts @@ -97,7 +97,7 @@ describe('Tokenize', () => { }); }); -const mdString = '$$math$$ [[link]] ```mermaid m ``` $inline$ $$double math$$ ```py code ``` ![[image]]'; +const mdString = '$$math$$ [[link]] ```mermaid m ``` $\\phi$ $$double math$$ ```py code ``` ![[image]]'; describe('BuildElements', () => { test('find elements', () =>{ @@ -116,7 +116,7 @@ describe('BuildElements', () => { expect(elements[3].Value).toEqual("double math"); expect(elements[3].Type).toEqual(Token.$$); - expect(elements[4].Value).toEqual("inline"); + expect(elements[4].Value).toEqual("\\phi"); expect(elements[4].Type).toEqual(Token.$); expect(elements[5].Value).toEqual(" m ");