forked from mapbox/mapbox-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsection.js
More file actions
45 lines (42 loc) · 1.27 KB
/
Copy pathsection.js
File metadata and controls
45 lines (42 loc) · 1.27 KB
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
import React from 'react';
import remark from 'remark';
import remarkHTML from 'remark-html';
import remarkHighlight from '../highlight';
import PureRenderMixin from 'react-pure-render/mixin';
import { postHighlight, remarkPlugins } from '../custom';
function renderHighlighted(nodes) {
return {
__html: postHighlight(remark()
.use(remarkHTML)
.stringify(remark()
.use(remarkHighlight)
.use(remarkPlugins)
.run({
type: 'root',
children: nodes
})))
};
}
var Section = React.createClass({
mixins: [PureRenderMixin],
propTypes: {
chunk: React.PropTypes.object.isRequired,
leftClassname: React.PropTypes.string.isRequired,
rightClassname: React.PropTypes.string.isRequired
},
render() {
let { chunk, leftClassname, rightClassname } = this.props;
let { left, right, preview } = chunk;
return (<div
data-title={chunk.title}
className={`keyline-top section contain clearfix ${preview ? 'preview' : ''}`}>
<div
className={leftClassname}
dangerouslySetInnerHTML={renderHighlighted(left)} />
{right.length > 0 && <div
className={rightClassname}
dangerouslySetInnerHTML={renderHighlighted(right)} />}
</div>);
}
});
module.exports = Section;