Skip to content

Commit 09c3170

Browse files
committed
Switching to Prism
1 parent 8b8cdd2 commit 09c3170

File tree

7 files changed

+21
-17
lines changed

7 files changed

+21
-17
lines changed

index.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44
<meta charset="UTF-8">
55
<meta name="viewport" content="width=device-width initial-scale=1 user-scalable=no" />
66
<title>Spectacle</title>
7-
<link href="http://fonts.googleapis.com/css?family=Lobster+Two:400,700" rel="stylesheet" type="text/css">
8-
<link href="http://fonts.googleapis.com/css?family=Open+Sans+Condensed:300,700" rel="stylesheet" type="text/css">
7+
<link href="https://fonts.googleapis.com/css?family=Lobster+Two:400,700" rel="stylesheet" type="text/css">
8+
<link href="https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300,700" rel="stylesheet" type="text/css">
9+
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/prism/1.3.0/themes/prism-tomorrow.css">
910
</head>
1011
<body>
1112
<div id="root"></div>
13+
<script src="https://cdn.jsdelivr.net/prism/1.3.0/prism.js" type="text/javascript"></script>
14+
<script src="https://cdn.jsdelivr.net/prism/1.3.0/components/prism-jsx.min.js" type="text/javascript"></script>
1215
<script src="./dist/bundle.js"></script>
1316
</body>
1417
</html>

index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import preloader from "./src/utils/preloader";
1111
import Interactive from "./assets/interactive";
1212

1313
require("normalize.css");
14-
require("./themes/default/index.css");
14+
require("./src/themes/default/index.css");
1515
require("highlight.js/styles/monokai_sublime.css");
1616

1717
const images = {
@@ -25,8 +25,8 @@ preloader([images.city, images.kat, images.markdown]);
2525

2626
render(
2727
<Spectacle
28-
theme={require("./themes/default/index")}
29-
print={require("./themes/default/print")}
28+
theme={require("./src/themes/default/index")}
29+
print={require("./src/themes/default/print")}
3030
>
3131
<Deck transition={["zoom", "slide"]} transitionDuration={500}>
3232
<Slide transition={["zoom"]} bgColor="primary">
@@ -52,7 +52,7 @@ render(
5252
</Slide>
5353
<Slide transition={["zoom", "fade"]} bgColor="primary" notes="<ul><li>talk about that</li><li>and that</li></ul>">
5454
<CodePane
55-
lang="javascript"
55+
lang="jsx"
5656
source={require("raw!./assets/deck.example")}
5757
margin="20px auto"
5858
/>

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"author": "",
1313
"license": "MIT",
1414
"dependencies": {
15-
"highlight.js": "8.9.1",
1615
"history": "1.13.1",
1716
"lodash": "3.10.1",
1817
"mdast": "^2.1.0",

src/components/code-pane.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,29 @@
11
import React, { Component, PropTypes } from "react";
2-
import highlight from "highlight.js";
32
import { getStyles } from "../utils/base";
43
import Radium from "radium";
54
import isUndefined from "lodash/lang/isundefined";
65

6+
const format = (str) => {
7+
return str.replace(/</g,'&lt;').replace(/>/g,'&gt;') ;
8+
};
9+
710
@Radium
811
export default class CodePane extends Component {
912
createMarkup() {
1013
const { source, children, lang } = this.props;
11-
// Allow code to come from source or from children, for markdown support
12-
const language = highlight.getLanguage(lang);
1314
const code = (isUndefined(source) || source === "") ? children : source;
14-
const markup = highlight.highlightAuto(code, language ? language.aliases : undefined);
1515
return {
16-
__html: markup.value
16+
__html: format(code)
1717
};
1818
}
19+
componentDidMount() {
20+
return window.Prism && window.Prism.highlightAll();
21+
}
1922
render() {
2023
return (
2124
<pre style={[this.context.styles.components.codePane.pre, getStyles.call(this), this.props.style]}>
2225
<code
23-
className="hljs"
26+
className={`language-${this.props.lang}`}
2427
style={this.context.styles.components.codePane.code}
2528
dangerouslySetInnerHTML={this.createMarkup()}
2629
/>
@@ -41,6 +44,6 @@ CodePane.propTypes = {
4144
};
4245

4346
CodePane.defaultProps = {
44-
lang: "",
47+
lang: "markup",
4548
source: ""
4649
};
File renamed without changes.

themes/default/index.js renamed to src/themes/default/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,14 @@ export default {
133133
codePane: {
134134
pre: {
135135
margin: "auto",
136-
fontSize: "1rem",
136+
fontSize: "0.8rem",
137137
fontWeight: "normal",
138138
fontFamily: fonts.tertiary,
139139
minWidth: "100%",
140140
maxWidth: 800
141141
},
142142
code: {
143143
textAlign: "left",
144-
padding: 20,
145144
fontWeight: "normal"
146145
}
147146
},

themes/default/print.js renamed to src/themes/default/print.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export default {
6161
pre: {
6262
maxWidth: 800,
6363
margin: "auto",
64-
fontSize: "1rem",
64+
fontSize: "0.8rem",
6565
fontWeight: "normal",
6666
fontFamily: fonts.tertiary
6767
},

0 commit comments

Comments
 (0)