aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/components/renderers/Markdown.js
blob: f69d176c2cef49824cf298eb38032c9fb4774970 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import React from 'react';
import ReactMarkdown from 'react-markdown';
import styled from 'styled-components'
import MarkdownCodeRenderer from './InlineCode'

const Content = styled.div`
    max-width: 100%;
    overflow-wrap: anywhere;
    img {
        max-width: 100%;
    }
    
    h3 {
        font-weight: bold;
    }

    hr {
        border-top: 1px solid ${p => p.theme.colors.text};
        border-style: solid;
    }

    code {
        background: ${p => p.theme.colors.codeHighlight};
        font-size: 0.8em;
    }
    
    pre {
        padding: 0.7em;
        background: ${p => p.theme.colors.codeHighlight};
    }
    
    pre > code {
        background: none;
    }
    
    table {
        width: 100%;
    }
    
    code, pre {
        background: none;
        font-family: 'JetBrains Mono', monospace;
        padding: initial;
        border-radius: 3px;
        outline: none;
    }
`
const Markdown = ({content}) => {
    return <Content>
        <ReactMarkdown
            source={content}
            linkTarget='_blank'
            renderers={{
                code: MarkdownCodeRenderer,
            }}
        />
    </Content>;
}

export default Markdown