Skip to content

Commit

Permalink
fixed bug
Browse files Browse the repository at this point in the history
  • Loading branch information
SeppiaBrilla committed Jan 4, 2024
1 parent dacdea5 commit 418fd00
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
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.4",
"version": "0.1.5",
"description": "A typescript library to transform Obsidian notes into html",
"main": "lib/cjs/index.js",
"module": "lib/esm/index.js",
Expand Down
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 \\^\\/,\\.\\*\\!\\@\\#\\%\\^\\&()\\{}_\\-=\\+`~;:'\"<>\\?\\|\\\\n\\t]+)";
const CHAR_TO_ESCAPE = ['\\','.','$','*','+','?','(',')','[','{,','|', ']', '-']

function addEscape(str:string){
Expand Down
14 changes: 12 additions & 2 deletions tests/Parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const mdString = '$$math$$ [[link]] ```mermaid m ``` $\\phi$ $$double math$$ ```

describe('BuildElements', () => {
test('find elements', () =>{
const elements = BuildElements(mdString);
let elements = BuildElements(mdString);

expect(elements.length).toEqual(7);
expect(elements[0].Value).toEqual("image");
Expand All @@ -124,6 +124,16 @@ describe('BuildElements', () => {

expect(elements[6].Value).toEqual("py code ");
expect(elements[6].Type).toEqual(Token['```']);
});

elements = BuildElements(`$$
\\begin{align}
\\frac{\\partial L}{\\partial \\Theta_{k -1}} &= \\frac{\\partial L}{\\partial f_k} \\frac{\\partial f_k}{\\partial \\Theta_{k - 1}}\\
\\frac{\\partial L}{\\partial \\Theta_{k -2}} &= \\frac{\\partial L}{\\partial f_k} \\frac{\\partial f_k}{\\partial f_{k-1}} \\frac{\\partial f_{k-1}}{\\partial \\Theta_{k-2}}\\
\\frac{\\partial L}{\\partial \\Theta_{k -3}} &= \\frac{\\partial L}{\\partial f_k} \\frac{\\partial f_k}{\\partial f_{k-1}} \\frac{\\partial f_{k-1}}{\\partial f_{k-2}}\\frac{\\partial f_{k-2}}{\\partial \\Theta_{k-3}}\\
&\\dots
\\end{align}
$$`);
expect(elements.length).toEqual(1);
expect(elements[0].Type).toEqual(Token.$$);
});
});

0 comments on commit 418fd00

Please sign in to comment.