Skip to content

Commit

Permalink
added \ support
Browse files Browse the repository at this point in the history
  • Loading branch information
SeppiaBrilla committed Oct 21, 2023
1 parent 58f3361 commit 4204b85
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "web-obsidian-builder",
"version": "0.1.0",
"version": "0.1.2",
"description": "A typescript library to transform Obsidian notes into html",
"main": "lib/cjs/index.js",
"module": "lib/esm/index.js",
Expand Down
2 changes: 2 additions & 0 deletions src/Parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ function Tokenize(mdString: string): Array<MarkdownToken>{
const match: Array<MarkdownToken> = [];
let i = 0;
while(i <= mdString.length){
if(mdString[i] === '\\')
i += 2;
const str: string = mdString.substring(i, Math.min(i+maxStep, mdString.length));
const token: Token = ToToken(str);
if(token != Token.u){
Expand Down
11 changes: 11 additions & 0 deletions tests/Parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,17 @@ describe('Tokenize', () => {
expect(tokens[7].Value).toEqual(Token['```']);
expect(tokens[7].Position).toEqual(39);
});

test('escape sequence', () => {
const mdStr = '$123 \\$ \\$ 123$';
const tokens = Tokenize(mdStr);

expect(tokens.length).toEqual(2);
expect(tokens[0].Value).toEqual(Token['$']);
expect(tokens[0].Position).toEqual(0);
expect(tokens[1].Value).toEqual(Token['$']);
expect(tokens[1].Position).toEqual(14);
});
});

const mdString = '$$math$$ [[link]] ```mermaid m ``` $inline$ $$double math$$ ```py code ``` ![[image]]';
Expand Down

0 comments on commit 4204b85

Please sign in to comment.