-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 skip code blocks when running latex processing
correct math syntax Co-authored-by: Erin Schnabel <ebullientworks@gmail.com>
- Loading branch information
Showing
3 changed files
with
291 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Basic Markdown Syntax > Code Blocks 1`] = ` | ||
"<!-- .slide: class="drop" --> | ||
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true"> | ||
\`\`\`dockerfile | ||
FROM ubuntu | ||
\`\`\` | ||
</div>" | ||
`; | ||
|
||
exports[`Basic Markdown Syntax > Code Blocks with multiple $ characters 1`] = ` | ||
"<!-- .slide: class="drop" --> | ||
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true"> | ||
\`\`\`dockerfile | ||
USER $USER_NAME:$USER_NAME | ||
\`\`\` | ||
</div>" | ||
`; | ||
|
||
exports[`Basic Markdown Syntax > Math with Code Blocks 1`] = ` | ||
"<!-- .slide: class="drop" --> | ||
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true"> | ||
$egin{vmatrix}a & b\\ | ||
c & d | ||
end{vmatrix}=ad-bc$ | ||
\`\`\`dockerfile | ||
USER $USER_NAME:$USER_NAME | ||
\`\`\` | ||
You can also do inline math like \`$s^{-2}_{n}sum_{i=1}^{n}$\` | ||
</div>" | ||
`; | ||
|
||
exports[`Basic Markdown Syntax > Math with Multiple Code Blocks 1`] = ` | ||
"<!-- .slide: class="drop" --> | ||
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true"> | ||
$egin{vmatrix}a & b\\ | ||
c & d | ||
end{vmatrix}=ad-bc$ | ||
\`\`\`dockerfile | ||
USER $USER_NAME:$USER_NAME | ||
\`\`\` | ||
You can also do inline math like \`$s^{-2}_{n}sum_{i=1}^{n}$\` | ||
\`\`\`bash | ||
eval "$(/home/$USER_NAME/.rbenv/bin/rbenv init -)" | ||
\`\`\` | ||
That was ruby, now we have javascript: | ||
\`\`\` | ||
console.log("Hello world!") | ||
\`\`\` | ||
</div>" | ||
`; | ||
|
||
exports[`Code Block Syntax > Headers 1`] = ` | ||
"<!-- .slide: class="drop" --> | ||
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true"> | ||
\`\`\` | ||
USER $USER_NAME:$USER_NAME | ||
\`\`\` | ||
The above does not show backticks | ||
</div>" | ||
`; | ||
|
||
exports[`Code Block Syntax > Headers 2`] = ` | ||
"<!-- .slide: class="drop" --> | ||
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true"> | ||
\`\`\` | ||
USER \`$USER_NAME:$\`USER_NAME | ||
\`\`\` | ||
The above does show backticks | ||
</div>" | ||
`; | ||
|
||
exports[`Code Block Syntax > Headers 3`] = ` | ||
"<!-- .slide: class="drop" --> | ||
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true"> | ||
\`\`\` | ||
USER $USER_NAME:$USER_NAME | ||
\`\`\` | ||
The above does not show backticks | ||
</div>" | ||
`; | ||
|
||
exports[`Embedded code has extra characters near dollar signs 1`] = ` | ||
"<!-- .slide: class="drop" --> | ||
<div class="" style="position: absolute; left: 0px; top: 0px; height: 700px; width: 960px; min-height: 700px; display: flex; flex-direction: column; align-items: center; justify-content: center" absolute="true"> | ||
\`\`\`javascript | ||
export class CounterService { | ||
count$ = new BehaviorSubject(1000); | ||
double$ = this.count$.pipe(map((count) => count * 2)); | ||
triple$ = this.count$.pipe(map((count) => count * 3)); | ||
combined$ = combineLatest([this.double$, this.triple$]).pipe( | ||
map(([double, triple]) => double + triple) | ||
); | ||
over9000$ = this.combined$.pipe(map((combined) => combined > 9000)); | ||
message$ = this.over9000$.pipe( | ||
map((over9000) => (over9000 ? "It's over 9000!" : "It's under 9000.")) | ||
); | ||
} | ||
\`\`\` | ||
</div>" | ||
`; |
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,145 @@ | ||
import { MarkdownProcessor } from 'src/obsidian/markdownProcessor'; | ||
import { obsidianUtils as utilsInstance } from './__mocks__/mockObsidianUtils'; | ||
import { prepare } from './testUtils'; | ||
|
||
test('Basic Markdown Syntax > Code Blocks', () => { | ||
const input = ` | ||
\`\`\`dockerfile | ||
FROM ubuntu | ||
\`\`\` | ||
`; | ||
|
||
const { options, markdown } = prepare(input); | ||
const sut = new MarkdownProcessor(utilsInstance); | ||
|
||
return expect(sut.process(markdown, options)).toMatchSnapshot(); | ||
}); | ||
|
||
test('Basic Markdown Syntax > Code Blocks with multiple $ characters', () => { | ||
const input = ` | ||
\`\`\`dockerfile | ||
USER $USER_NAME:$USER_NAME | ||
\`\`\` | ||
`; | ||
|
||
const { options, markdown } = prepare(input); | ||
const sut = new MarkdownProcessor(utilsInstance); | ||
|
||
return expect(sut.process(markdown, options)).toMatchSnapshot(); | ||
}); | ||
|
||
test('Code Block Syntax > Headers', () => { | ||
const input = ` | ||
\`\`\` | ||
USER $USER_NAME:$USER_NAME | ||
\`\`\` | ||
The above does not show backticks | ||
`; | ||
|
||
const { options, markdown } = prepare(input); | ||
const sut = new MarkdownProcessor(utilsInstance); | ||
|
||
return expect(sut.process(markdown, options)).toMatchSnapshot(); | ||
}); | ||
|
||
test('Code Block Syntax > Headers', () => { | ||
const input = ` \`\`\` | ||
USER $USER_NAME:$USER_NAME | ||
\`\`\` | ||
The above does show backticks | ||
`; | ||
|
||
const { options, markdown } = prepare(input); | ||
const sut = new MarkdownProcessor(utilsInstance); | ||
|
||
return expect(sut.process(markdown, options)).toMatchSnapshot(); | ||
}); | ||
|
||
test('Code Block Syntax > Headers', () => { | ||
const input = `\`\`\` | ||
USER $USER_NAME:$USER_NAME | ||
\`\`\` | ||
The above does not show backticks | ||
`; | ||
|
||
const { options, markdown } = prepare(input); | ||
const sut = new MarkdownProcessor(utilsInstance); | ||
|
||
return expect(sut.process(markdown, options)).toMatchSnapshot(); | ||
}); | ||
|
||
test('Basic Markdown Syntax > Math with Code Blocks', () => { | ||
const input = `$$\begin{vmatrix}a & b\\ | ||
c & d | ||
\end{vmatrix}=ad-bc$$ | ||
\`\`\`dockerfile | ||
USER $USER_NAME:$USER_NAME | ||
\`\`\` | ||
You can also do inline math like $s^{-2}_{n}sum_{i=1}^{n}$`; | ||
|
||
const { options, markdown } = prepare(input); | ||
const sut = new MarkdownProcessor(utilsInstance); | ||
|
||
return expect(sut.process(markdown, options)).toMatchSnapshot(); | ||
}); | ||
|
||
test('Basic Markdown Syntax > Math with Multiple Code Blocks', () => { | ||
const input = `$$\begin{vmatrix}a & b\\ | ||
c & d | ||
\end{vmatrix}=ad-bc$$ | ||
\`\`\`dockerfile | ||
USER $USER_NAME:$USER_NAME | ||
\`\`\` | ||
You can also do inline math like $s^{-2}_{n}sum_{i=1}^{n}$ | ||
\`\`\`bash | ||
eval "$(/home/$USER_NAME/.rbenv/bin/rbenv init -)" | ||
\`\`\` | ||
That was ruby, now we have javascript: | ||
\`\`\` | ||
console.log("Hello world!") | ||
\`\`\` | ||
`; | ||
|
||
const { options, markdown } = prepare(input); | ||
const sut = new MarkdownProcessor(utilsInstance); | ||
|
||
return expect(sut.process(markdown, options)).toMatchSnapshot(); | ||
}); | ||
|
||
test('Embedded code has extra characters near dollar signs', () => { | ||
const input = ` | ||
\`\`\`javascript | ||
export class CounterService { | ||
count$ = new BehaviorSubject(1000); | ||
double$ = this.count$.pipe(map((count) => count * 2)); | ||
triple$ = this.count$.pipe(map((count) => count * 3)); | ||
combined$ = combineLatest([this.double$, this.triple$]).pipe( | ||
map(([double, triple]) => double + triple) | ||
); | ||
over9000$ = this.combined$.pipe(map((combined) => combined > 9000)); | ||
message$ = this.over9000$.pipe( | ||
map((over9000) => (over9000 ? "It's over 9000!" : "It's under 9000.")) | ||
); | ||
} | ||
\`\`\``; | ||
|
||
const { options, markdown } = prepare(input); | ||
const sut = new MarkdownProcessor(utilsInstance); | ||
|
||
return expect(sut.process(markdown, options)).toMatchSnapshot(); | ||
}); | ||
|