Skip to content

Commit c8fb883

Browse files
committed
Enabling Markdown for GristDocTour
1 parent fb65d72 commit c8fb883

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

app/client/ui/DocTour.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ import {IconList, IconName} from 'app/client/ui2018/IconList';
1010
import {DocData} from 'app/common/DocData';
1111
import {dom} from 'grainjs';
1212
import sortBy = require('lodash/sortBy');
13+
import {marked} from "marked";
14+
import {renderer} from 'app/client/ui/DocTutorialRenderer';
15+
import {sanitizeTutorialHTML} from "./sanitizeHTML";
16+
1317

1418
const t = makeT('DocTour');
1519

@@ -44,7 +48,17 @@ async function makeDocTour(docData: DocData, docComm: DocComm): Promise<IOnBoard
4448
return String(tableData.getValue(rowId, colId) || "");
4549
}
4650
const title = getValue("Title");
47-
let body: HTMLElement | string = getValue("Body");
51+
52+
const bodyHtmlContent = sanitizeTutorialHTML(marked.parse(getValue("Body"), {
53+
async: false, renderer
54+
}));
55+
const element = document.createElement('div');
56+
element.innerHTML = bodyHtmlContent;
57+
58+
59+
let body: HTMLElement = element;
60+
61+
4862
const linkText = getValue("Link_Text");
4963
const linkUrl = getValue("Link_URL");
5064
const linkIcon = getValue("Link_Icon") as IconName;

app/client/ui/DocTourRenderer.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import {constructUrl} from 'app/client/models/gristUrlState';
2+
import {gristIconLink} from 'app/client/ui2018/links';
3+
import {marked} from 'marked';
4+
5+
export const renderer = new marked.Renderer();
6+
7+
renderer.link = ({href, text}) =>
8+
gristIconLink(constructUrl(href), text).outerHTML;

0 commit comments

Comments
 (0)