Skip to content

Commit 4172e19

Browse files
committed
Fixed #148
1 parent cb170c3 commit 4172e19

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

src/components/code.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,24 @@ import React, { Component, PropTypes } from "react";
22
import { getStyles } from "../utils/base";
33
import Radium from "radium";
44

5+
const format = (str) => {
6+
return str.replace(/</g, "&lt;").replace(/>/g, "&gt;");
7+
};
8+
59
@Radium
610
export default class Code extends Component {
11+
createMarkup() {
12+
return {
13+
__html: format(this.props.children)
14+
};
15+
}
716
render() {
817
return (
9-
<code className={this.props.className} style={[this.context.styles.components.code, getStyles.call(this), this.props.style]}>
10-
{this.props.children}
11-
</code>
18+
<code
19+
className={this.props.className}
20+
style={[this.context.styles.components.code, getStyles.call(this), this.props.style]}
21+
dangerouslySetInnerHTML={this.createMarkup()}
22+
/>
1223
);
1324
}
1425
}

src/components/markdown.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { isUndefined } from "lodash";
55

66
import BlockQuote from "./block-quote";
77
import CodePane from "./code-pane";
8+
import Code from "./code";
89
import Heading from "./heading";
910
import Image from "./image";
1011
import Link from "./link";
@@ -58,8 +59,7 @@ export const mdastConfigDefault = {
5859
h5: spectacleComponent(Heading, {size: 5}),
5960
h6: spectacleComponent(Heading, {size: 6}),
6061
img: Image,
61-
// https://github.com/FormidableLabs/spectacle/issues/88
62-
// inlineCode: Code,
62+
inlineCode: Code,
6363
li: ListItem,
6464
p: Text,
6565
strong: spectacleComponent(S, {type: "bold"}),

0 commit comments

Comments
 (0)