Skip to content

Commit 0fe6659

Browse files
committed
Merge branch 'issue-68/latex-rendering-problem' into main
(Hatton corrected some linting problems during merge)
2 parents 5baebe8 + 6aa7029 commit 0fe6659

File tree

1 file changed

+106
-0
lines changed

1 file changed

+106
-0
lines changed

src/latex.spec.ts

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
import { NotionToMarkdown } from "notion-to-md";
2+
import { HierarchicalNamedLayoutStrategy } from "./HierarchicalNamedLayoutStrategy";
3+
import { LayoutStrategy } from "./LayoutStrategy";
4+
import { NotionPage } from "./NotionPage";
5+
6+
import { getMarkdownFromNotionBlocks } from "./transform";
7+
8+
import { IDocuNotionContext } from "./plugins/pluginTypes";
9+
import { convertInternalUrl } from "./plugins/internalLinks";
10+
11+
import { initNotionClient } from "./pull";
12+
import { NotionBlock } from "./types";
13+
14+
import { IDocuNotionConfig } from "./config/configuration";
15+
16+
import defaultConfig from "./config/default.docunotion.config";
17+
18+
test("Latex Rendering", async () => {
19+
const pages = new Array<NotionPage>();
20+
const counts = {
21+
output_normally: 0,
22+
skipped_because_empty: 0,
23+
skipped_because_status: 0,
24+
skipped_because_level_cannot_have_content: 0,
25+
};
26+
27+
const notionClient = initNotionClient("");
28+
29+
const layoutStrategy = new HierarchicalNamedLayoutStrategy();
30+
31+
const config: IDocuNotionConfig = defaultConfig;
32+
33+
const context: IDocuNotionContext = {
34+
getBlockChildren: (id: string) => {
35+
return new Promise<NotionBlock[]>(resolve =>
36+
resolve(new Array<NotionBlock>())
37+
);
38+
},
39+
directoryContainingMarkdown: "", // this changes with each page
40+
relativeFilePathToFolderContainingPage: "", // this changes with each page
41+
layoutStrategy: layoutStrategy,
42+
notionToMarkdown: new NotionToMarkdown({ notionClient }),
43+
options: {
44+
notionToken: "",
45+
rootPage: "",
46+
locales: [""],
47+
markdownOutputPath: "",
48+
imgOutputPath: "",
49+
imgPrefixInMarkdown: "",
50+
statusTag: "",
51+
},
52+
53+
pages: pages,
54+
counts: counts, // review will this get copied or pointed to?
55+
imports: [],
56+
convertNotionLinkToLocalDocusaurusLink: (url: string) =>
57+
convertInternalUrl(context, url),
58+
};
59+
60+
const blocks: Array<NotionBlock> = [
61+
{
62+
object: "block",
63+
id: "169e1c47-6706-4518-adca-73086b2738ac",
64+
parent: {
65+
type: "page_id",
66+
page_id: "2acc11a4-82a9-4759-b429-fa011c164888",
67+
},
68+
created_time: "2023-08-18T15:51:00.000Z",
69+
last_edited_time: "2023-08-18T15:51:00.000Z",
70+
created_by: {
71+
object: "user",
72+
id: "af5c163e-82b1-49d1-9f1c-539907bb9fb9",
73+
},
74+
last_edited_by: {
75+
object: "user",
76+
id: "af5c163e-82b1-49d1-9f1c-539907bb9fb9",
77+
},
78+
has_children: false,
79+
archived: false,
80+
type: "paragraph",
81+
paragraph: {
82+
rich_text: [
83+
{
84+
type: "equation",
85+
equation: { expression: "x" },
86+
annotations: {
87+
bold: false,
88+
italic: false,
89+
strikethrough: false,
90+
underline: false,
91+
code: false,
92+
color: "default",
93+
},
94+
plain_text: "x",
95+
href: null,
96+
},
97+
],
98+
color: "default",
99+
},
100+
},
101+
];
102+
103+
expect(await getMarkdownFromNotionBlocks(context, config, blocks)).toContain(
104+
"$x$"
105+
);
106+
});

0 commit comments

Comments
 (0)