cleanup
This commit is contained in:
parent
a26588835b
commit
cee1d41d6f
0
bin/strip-frontmatter
Normal file → Executable file
0
bin/strip-frontmatter
Normal file → Executable file
0
bin/strip-frontmatter.js
Normal file → Executable file
0
bin/strip-frontmatter.js
Normal file → Executable file
@ -107,8 +107,8 @@ const options: MarkdownOptions = {
|
||||
|
||||
```bash
|
||||
./bin/markdown2html \
|
||||
--katex-macro '\foobar' '\text{foo}' '\text{bar}' \
|
||||
--katex-macro '\bazqux' '\text{baz}' '\text{qux}'
|
||||
--katex-macro '\foobar' '\text{foo} + \text{bar}' \
|
||||
--katex-macro '\bazqux' '\text{baz} + \text{qux}'
|
||||
```
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
import * as yaml from 'yaml';
|
||||
|
||||
export function process_frontmatter(document: string) {
|
||||
export function process_frontmatter(document: string, parse = true) {
|
||||
if (! document.startsWith('---\n')) {
|
||||
return {
|
||||
frontmatter: null,
|
||||
@ -12,7 +12,7 @@ export function process_frontmatter(document: string) {
|
||||
const endIndex = document.slice(3).indexOf('\n---\n') + 3;
|
||||
const frontmatterYaml = document.slice(3, endIndex);
|
||||
const markdown = document.slice(endIndex + 4);
|
||||
const frontmatter = yaml.parse(frontmatterYaml);
|
||||
const frontmatter = parse ? frontmatterYaml : yaml.parse(frontmatterYaml);
|
||||
|
||||
return { frontmatter, markdown };
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user