Răsfoiți Sursa

use the triple brace to prevent HTML escaping

Yuki Takei 2 ani în urmă
părinte
comite
f5e6107b15

+ 43 - 0
apps/app/src/components/TemplateModal/use-formatter.spec.tsx

@@ -55,4 +55,47 @@ describe('useFormatter', () => {
     expect(markdown).toBe('markdown body');
   });
 
+  it('returns markdown formatted when currentPagePath is undefined', () => {
+    // when
+    const { format } = useFormatter();
+    const template = mock<ITemplate>();
+    template.markdown = `
+title: {{{title}}}{{^title}}(empty){{/title}}
+path: {{{path}}}
+`;
+    const markdown = format(template);
+
+    // then
+    expect(markdown).toBe(`
+title: (empty)
+path: /
+`);
+  });
+
+  it('returns markdown formatted', () => {
+    // setup
+    mocks.useCurrentPagePathMock.mockImplementation(() => {
+      return { data: '/Sandbox' };
+    });
+    // 2023/5/31 15:01:xx
+    vi.setSystemTime(new Date(2023, 4, 31, 15, 1));
+
+    // when
+    const { format } = useFormatter();
+    const template = mock<ITemplate>();
+    template.markdown = `
+title: {{{title}}}
+path: {{{path}}}
+date: {{yyyy}}/{{MM}}/{{dd}} {{HH}}:{{mm}}
+`;
+    const markdown = format(template);
+
+    // then
+    expect(markdown).toBe(`
+title: Sandbox
+path: /Sandbox
+date: 2023/05/31 15:01
+`);
+  });
+
 });

+ 2 - 2
apps/app/src/stores/template.tsx

@@ -45,7 +45,7 @@ const presetTemplates: ITemplate[] = [
   {
     id: '__preset2__',
     name: '議事録',
-    markdown: `# {{title}}{{^title}}<会議名>{{/title}}
+    markdown: `# {{{title}}}{{^title}}<会議名>{{/title}}
 
 ## 日時
 {{yyyy}}/{{MM}}/{{dd}} {{HH}}:{{mm}}〜hh:mm
@@ -90,7 +90,7 @@ const presetTemplates: ITemplate[] = [
   {
     id: '__preset3__',
     name: '企画書',
-    markdown: `# {{title}}{{^title}}<企画タイトル>{{/title}}
+    markdown: `# {{{title}}}{{^title}}<企画タイトル>{{/title}}
 
 ## 目的