-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Now supports not parsing the internals of a directive, which is helpful for things like math directives. Supported by the skipParsing option on the directive. See #11 for the math directive changes!
- Loading branch information
Showing
13 changed files
with
181 additions
and
31 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Math directive: | ||
. | ||
```{math} | ||
:label: my_label | ||
w_{t+1} = (1 + r_{t+1}) s(w_t) + y_{t+1} | ||
``` | ||
. | ||
<div class="math numbered" id="eq-my_label" number="1"> | ||
w_{t+1} = (1 + r_{t+1}) s(w_t) + y_{t+1} | ||
</div> | ||
. | ||
|
||
Math directive: | ||
. | ||
```{math} | ||
w_{t+1} = (1 + r_{t+1}) s(w_t) + y_{t+1} | ||
``` | ||
. | ||
<div class="math"> | ||
w_{t+1} = (1 + r_{t+1}) s(w_t) + y_{t+1} | ||
</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
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 |
---|---|---|
@@ -1,10 +1,12 @@ | ||
import admonitions from './admonition'; | ||
import figure from './figure'; | ||
import math from './math'; | ||
import { Directives } from './types'; | ||
|
||
const directives: Directives = { | ||
...admonitions, | ||
...figure, | ||
...math, | ||
}; | ||
|
||
export default directives; |
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,34 @@ | ||
import { TargetKind } from '../state'; | ||
import { Directive } from './types'; | ||
import { unusedOptionsWarning } from './utils'; | ||
|
||
export type Args = { | ||
}; | ||
|
||
export type Opts = { | ||
label: string; | ||
}; | ||
|
||
const math = { | ||
math: { | ||
token: 'math', | ||
numbered: TargetKind.equation, | ||
skipParsing: true, | ||
getArguments: () => ({ args: {}, content: '' }), | ||
getOptions: (data) => { | ||
const { label, ...rest } = data; | ||
unusedOptionsWarning('math', rest); | ||
return { label }; | ||
}, | ||
renderer: (args, opts, target) => { | ||
const { id, number } = target ?? {}; | ||
return ['div', { | ||
class: target ? ['math', 'numbered'] : 'math', | ||
id, | ||
number, | ||
}, 0]; | ||
}, | ||
} as Directive<Args, Opts>, | ||
}; | ||
|
||
export default math; |
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,6 @@ | ||
|
||
export const unusedOptionsWarning = (kind: string, opts: Record<string, any>) => { | ||
if (Object.keys(opts).length > 0) { | ||
console.warn(`Unknown ${kind} options`, opts); | ||
} | ||
}; |
Oops, something went wrong.