-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix some bugs (Mainly string parsing) (#79)
* fix: latex punctuation convert error * test: add latex convert test * fix: send to dirname deck can not work normally at opensuse
- Loading branch information
1 parent
c0114a2
commit 876cac3
Showing
8 changed files
with
82 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { CardParser } from "../parsers/cardParser"; | ||
|
||
describe("Latex", () => { | ||
it("Should keep the content of 'Latex inline' unchanged.", async () => { | ||
// linesToHtml always return a newline at the end of string | ||
const latexs = ["a=\\%1", "b=\\#1"]; | ||
const input = [ | ||
`extra stuff before the latex`, | ||
`extra stuff before the latex $${latexs[0]}$ extra stuff after the latex`, | ||
`$${latexs[1]}$`, | ||
`extra stuff after the latex` | ||
]; | ||
const cardParser = new CardParser(); | ||
// Act | ||
const result = await cardParser.linesToHtml(input); | ||
// Assert | ||
for (let latex of latexs) { | ||
expect(result).toMatch(latex); | ||
} | ||
}); | ||
it("Should keep the content of 'Latex block' unchanged.", async () => { | ||
// linesToHtml always return a newline at the end of string | ||
const latexs = ["a=\\%1", "b=\\#1", | ||
"\\before{align}", "c=\\{1,2\\} \\\\", "d=\\$2", "\\end{align}"]; | ||
const input = [ | ||
`extra stuff before the latex`, | ||
`$$${latexs[0]} ${latexs[1]}$$`, // one line latex block | ||
`extra stuff`, | ||
`$$`, // multiline latex block | ||
`${latexs[2]}`, | ||
`${latexs[3]}`, | ||
`${latexs[4]}`, | ||
`${latexs[5]}`, | ||
`$$` | ||
]; | ||
const cardParser = new CardParser(); | ||
// Act | ||
const result = await cardParser.linesToHtml(input); | ||
// Assert | ||
for (let latex of latexs) { | ||
expect(result).toMatch(latex); | ||
} | ||
}); | ||
it("Should not affect the conversion outside of latex", async () => { | ||
const htmlStr = "<p>%</p>\n"; | ||
const input = [ | ||
"\\%" | ||
]; | ||
const cardParser = new CardParser(); | ||
// Act | ||
const result = (await cardParser.linesToHtml(input)); | ||
// Assert | ||
expect(result).toEqual(htmlStr); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters