Skip to content

Commit 0f73f85

Browse files
committed
highlighting
1 parent 0582d1d commit 0f73f85

File tree

6 files changed

+21
-12
lines changed

6 files changed

+21
-12
lines changed

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"/>
99
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css"/>
1010
<link rel="stylesheet" href="http://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css"/>
11+
<script src="/node_modules/prismjs-package/themes/prism.css"></script>
1112
<link rel="stylesheet" href="/build/styles.css"/>
1213
</head>
1314
<body>

lib/change.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,23 @@ var _style = require('./style');
1313

1414
var _style2 = _interopRequireDefault(_style);
1515

16+
var _prismjsPackage = require('prismjs-package');
17+
18+
var _prismjsPackage2 = _interopRequireDefault(_prismjsPackage);
19+
1620
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1721

1822
function Change(props) {
1923
var ln1 = props.normal ? props.ln1 : props.ln;
2024
var ln2 = props.normal ? props.ln2 : props.ln;
2125

22-
// TODO highlight with prism.js
2326
var html = props.content;
2427

25-
// try {
26-
// html = highlight(props.lang, props.content).value;
27-
// } catch (e) {}
28+
try {
29+
html = (0, _prismjsPackage2.default)(props.content, props.lang);
30+
} catch (e) {
31+
console.log('highlight error:', e);
32+
}
2833

2934
return _react2.default.createElement(
3035
'tr',

lib/diffview.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function Part(props) {
4747

4848
return _react2.default.createElement(
4949
'article',
50-
null,
50+
{ className: _style2.default.diff },
5151
_react2.default.createElement(
5252
'header',
5353
null,

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
"classnames": "^2.2.3",
2929
"lang-map": "^0.4.0",
3030
"lodash": "^4.0.0",
31-
"parse-diff": "^0.3.1",
31+
"parse-diff": "^0.3.2",
32+
"prismjs-package": "^0.6.1",
3233
"react": "^0.14.6",
3334
"react-dom": "^0.14.6"
3435
},

src/change.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
import React from 'react';
22
import style from './style';
3+
import highlight from 'prismjs-package';
34

45
export default function Change(props) {
56
const ln1 = props.normal ? props.ln1 : props.ln;
67
const ln2 = props.normal ? props.ln2 : props.ln;
78

8-
// TODO highlight with prism.js
9-
const html = props.content;
9+
let html = props.content;
1010

11-
// try {
12-
// html = highlight(props.lang, props.content).value;
13-
// } catch (e) {}
11+
try {
12+
html = highlight(props.content, props.lang);
13+
} catch (e) {
14+
console.log('highlight error:', e);
15+
}
1416

1517
return (
1618
<tr className={props.type}>

src/diffview.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function Part(props) {
1717
});
1818

1919
return (
20-
<article>
20+
<article className={style.diff}>
2121
<header>
2222
<span className={style.adds}>+++ {additions}</span>
2323
<span className={style.dels}>--- {deletions}</span>

0 commit comments

Comments
 (0)