Skip to content

Commit

Permalink
🐛 Remove double header (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanc1 committed Mar 23, 2023
1 parent 67b4120 commit 3927ed5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/tricky-bulldogs-lay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'myst-demo': patch
---

Remove double header when there is a frontmatter title block.
8 changes: 4 additions & 4 deletions packages/myst-demo/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async function saveDocxFile(filename: string, mdast: any, footnotes?: any) {
async function parse(
text: string,
defaultFrontmatter?: PageFrontmatter,
renderers?: Record<string, NodeRenderer>,
options?: { renderers?: Record<string, NodeRenderer>; removeHeading?: boolean },
) {
// Ensure that any imports from myst are async and scoped to this function
const { visit } = await import('unist-util-visit');
Expand Down Expand Up @@ -97,7 +97,7 @@ async function parse(
};
const { frontmatter: frontmatterRaw } = getFrontmatter(mdast, {
removeYaml: true,
removeHeading: false,
removeHeading: options?.removeHeading ?? false,
});
const frontmatter = validatePageFrontmatter(frontmatterRaw, {
property: 'frontmatter',
Expand All @@ -124,7 +124,7 @@ async function parse(
const jats = unified()
.use(mystToJats, { spaces: 2 })
.stringify(mdast as any, jatsFile).result as JatsResult;
const content = useParse(mdast as any, renderers);
const content = useParse(mdast as any, options?.renderers);
return {
frontmatter,
yaml: mdastString,
Expand Down Expand Up @@ -173,7 +173,7 @@ export function MySTRenderer({

useEffect(() => {
const ref = { current: true };
parse(text, { numbering }, renderers).then((result) => {
parse(text, { numbering }, { renderers, removeHeading: !!TitleBlock }).then((result) => {
if (!ref.current) return;
setFrontmatter(result.frontmatter);
setYaml(result.yaml);
Expand Down

0 comments on commit 3927ed5

Please sign in to comment.