Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add github-markdown-css #204

Merged
merged 1 commit into from
Sep 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
"nino-cli": "^1.1.4",
"puppeteer-core": "^1.19.0",
"react-lazyload": "^2.6.2",
"react-markdown": "^4.2.0",
"typescript": "^3.5.3"
},
"devDependencies": {
Expand All @@ -61,6 +60,7 @@
"@types/koa-bodyparser": "^4.3.0",
"@types/koa-router": "^7.0.42",
"@types/koa-static": "^4.0.1",
"@types/marked": "^0.6.5",
"@types/prettier": "^1.18.2",
"@types/puppeteer-core": "^1.9.0",
"@types/react": "^16.9.2",
Expand All @@ -77,10 +77,12 @@
"date-fns": "^2.0.0-beta.2",
"fs-extra": "^8.1.0",
"gh-pages": "^2.1.1",
"github-markdown-css": "^3.0.1",
"koa-bodyparser": "^4.2.1",
"koa-router": "^7.4.0",
"koa-static": "^5.0.0",
"lint-staged": "^9.2.3",
"marked": "^0.7.0",
"mockdate": "^2.0.5",
"npm-run-all": "^4.1.5",
"post-compile-webpack-plugin": "^0.1.2",
Expand Down
12 changes: 7 additions & 5 deletions src/pages/MarkdownDetail.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import React from 'react';
import Markdown from 'react-markdown/with-html';
import marked from 'marked';
import './css/MarkdownDetail.css';
import 'github-markdown-css/github-markdown.css';

export interface MarkdownDetailProps {
dataSource: string;
}

export default (props: MarkdownDetailProps) => (
<div className="MarkdownDetail">
<div className="MarkdownDetail markdown-body">
<div className="wrapper">
<div className="content">
<Markdown source={props.dataSource} escapeHtml={false} />
</div>
<div
className="content"
dangerouslySetInnerHTML={{ __html: marked(props.dataSource || '') }}
></div>
</div>
</div>
);
57 changes: 10 additions & 47 deletions src/pages/__tests__/__snapshots__/MarkdownDetail.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5,59 +5,22 @@ exports[`MarkdownDetail render correctly 1`] = `
dataSource="- test"
>
<div
className="MarkdownDetail"
className="MarkdownDetail markdown-body"
>
<div
className="wrapper"
>
<div
className="content"
>
<ReactMarkdownWithHtml
astPlugins={Array []}
escapeHtml={false}
parserOptions={Object {}}
plugins={Array []}
rawSourcePos={false}
renderers={Object {}}
skipHtml={false}
source="- test"
sourcePos={false}
transformLinkUri={[Function]}
>
<Root
key="root-1-1-0"
>
<List
depth={0}
key="list-1-1-0"
ordered={false}
start={null}
tight={true}
>
<ul>
<ListItem
checked={null}
index={0}
key="listItem-1-1-0"
ordered={false}
tight={true}
>
<li>
<TextRenderer
key="text-1-3-0"
nodeKey="text-1-3-0"
value="test"
>
test
</TextRenderer>
</li>
</ListItem>
</ul>
</List>
</Root>
</ReactMarkdownWithHtml>
</div>
dangerouslySetInnerHTML={
Object {
"__html": "<ul>
<li>test</li>
</ul>
",
}
}
/>
</div>
</div>
</Component>
Expand Down
25 changes: 7 additions & 18 deletions src/pages/__tests__/__snapshots__/MarkdownEditor.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -92,30 +92,19 @@ exports[`MarkdownEditor render correctly 1`] = `
>
<Component>
<div
className="MarkdownDetail"
className="MarkdownDetail markdown-body"
>
<div
className="wrapper"
>
<div
className="content"
>
<ReactMarkdownWithHtml
astPlugins={Array []}
escapeHtml={false}
parserOptions={Object {}}
plugins={Array []}
rawSourcePos={false}
renderers={Object {}}
skipHtml={false}
sourcePos={false}
transformLinkUri={[Function]}
>
<Root
key="root-1-1-0"
/>
</ReactMarkdownWithHtml>
</div>
dangerouslySetInnerHTML={
Object {
"__html": "",
}
}
/>
</div>
</div>
</Component>
Expand Down