Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit149589f

Browse files
committed
feat: 🎸 add support for single dollar $ inline math
1 parent1aedc8b commit149589f

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

‎src/__tests__/inline.spec.ts‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,18 @@ describe('Inline Markdown', () => {
459459
]);
460460
});
461461

462+
test('single dollar inline math works',()=>{
463+
constparser=create();
464+
constast=parser.tokenizeInline('$1+1$');
465+
466+
expect(ast).toMatchObject([
467+
{
468+
type:'inlineMath',
469+
value:'1+1',
470+
},
471+
]);
472+
});
473+
462474
test('in text',()=>{
463475
constparser=create();
464476
constast=parser.tokenizeInline('Hey, look $$f(x) = Y ^ 2$$ is a real function.');
@@ -470,6 +482,17 @@ describe('Inline Markdown', () => {
470482
]);
471483
});
472484

485+
test('single dollar inline math, in text',()=>{
486+
constparser=create();
487+
constast=parser.tokenizeInline('Hey, look $f(x) = Y ^ 2$ is a real function.');
488+
489+
expect(ast).toMatchObject([
490+
{type:'text',len:10,value:'Hey, look '},
491+
{type:'inlineMath',len:14,value:'f(x) = Y ^ 2'},
492+
{type:'text',len:20,value:' is a real function.'},
493+
]);
494+
});
495+
473496
test('emphasized',()=>{
474497
constparser=create();
475498
constast=parser.tokenizeInline('*$$123$$*');

‎src/tokenizer/inlineMath.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* tslint:disable only-arrow-functions */
22
import{TTokenizer,IInlineMath}from'../types';
33

4-
constREG=/^\$\$(?=\S)([\s\S]*?\S)\$\$/;
4+
constREG=/^\${1,2}(?=\S)([\s\S]*?\S)\${1,2}/;
55

66
constinlineMath=()=>{
77
consttokenizer:TTokenizer<IInlineMath>=function(eat,value){

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp