Skip to content

Commit

Permalink
fixed backslash in regex
Browse files Browse the repository at this point in the history
  • Loading branch information
SeppiaBrilla committed Jan 4, 2024
1 parent c13a373 commit 815ff3d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Parser.ts
Original file line number Diff line number Diff line change
@@ -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){
Expand Down
4 changes: 2 additions & 2 deletions tests/Parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () =>{
Expand All @@ -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 ");
Expand Down

0 comments on commit 815ff3d

Please sign in to comment.