Skip to content

Commit 1799b82

Browse files
authored
Merge pull request redpwn#366 from redpwn/feat/improve-chall-rendering
feat(client): improve chall rendering
2 parents 559f132 + a104115 commit 1799b82

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

client/src/components/markdown.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,24 @@ import Timer from './timer'
44
import Sponsors from './sponsors'
55
import ActionButton from './action-button'
66

7+
// From https://github.com/developit/snarkdown/issues/75?
8+
const snarkdownEnhanced = (md) => {
9+
const htmls = md
10+
.split(/(?:\r?\n){2,}/)
11+
.map(l =>
12+
[' ', '\t', '#', '-', '*'].some(ch => l.startsWith(ch))
13+
? snarkdown(l)
14+
: `<p>${snarkdown(l)}</p>`
15+
)
16+
17+
return htmls.join('\n\n')
18+
}
19+
720
const Markdown = ({ content }) => (
821
<Markup
922
type='html'
1023
trim={false}
11-
markup={snarkdown(content)}
24+
markup={snarkdownEnhanced(content)}
1225
components={{ Timer, Sponsors, ActionButton }}
1326
/>
1427
)

client/src/components/problem.js

+5
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ export default withStyles({
9999
'& a': {
100100
display: 'inline',
101101
padding: 0
102+
},
103+
'& p': {
104+
lineHeight: '1.4em',
105+
fontSize: '1em',
106+
marginTop: 0
102107
}
103108
},
104109
divider: {

0 commit comments

Comments
 (0)