This repository has been archived by the owner on Sep 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9114fbe
commit 0913ba1
Showing
5 changed files
with
148 additions
and
54 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import * as React from 'react' | ||
import { Converter } from 'showdown' | ||
import { convert, WithTwemoji } from './Emojify' | ||
import styled from 'styled-components' | ||
|
||
// See https://github.com/showdownjs/showdown#valid-options | ||
const converter = new Converter({ | ||
simplifiedAutoLink: true, | ||
excludeTrailingPunctuationFromURLs: true, | ||
strikethrough: true, | ||
ghCodeBlocks: false, | ||
simpleLineBreaks: true, | ||
openLinksInNewWindow: true, | ||
}) | ||
|
||
const FromMarkdown = styled(WithTwemoji)` | ||
p { | ||
padding: 0.5rem; | ||
margin: 0; | ||
} | ||
code { | ||
color: inherit; | ||
padding: 0.15rem; | ||
border-radius: 4px; | ||
font-weight: bold; | ||
text-shadow: 1px 1px 2px #000000dd; | ||
} | ||
img { | ||
max-width: 100%; | ||
} | ||
` | ||
|
||
export const markdownify = (text: string) => ( | ||
<FromMarkdown | ||
dangerouslySetInnerHTML={{ | ||
__html: converter.makeHtml(convert(text)), | ||
}} | ||
/> | ||
) |
Oops, something went wrong.