Skip to content

Commit fe475aa

Browse files
committed
Parse description better
1 parent 71aea53 commit fe475aa

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

package-lock.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
"redbox-react": "^1.5.0",
9090
"redux": "^4.0.0",
9191
"redux-actions": "^2.2.1",
92+
"remove-markdown": "^0.3.0",
9293
"sass-loader": "^7.0.3",
9394
"screenfull": "^3.3.2",
9495
"style-loader": "^0.21.0",

src/frontend/components/App/index.jsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { connect } from 'react-redux';
44
import Promise from 'bluebird';
55
import { Helmet } from 'react-helmet';
66
import AutosizeInput from 'react-input-autosize';
7+
import removeMarkdown from 'remove-markdown';
78
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
89
import faPlus from '@fortawesome/fontawesome-free-solid/faPlus';
910
import {
@@ -228,8 +229,12 @@ class App extends BaseComponent {
228229
const { files } = this.props.current;
229230
const readmeFile = files.find(file => file.name === 'README.md');
230231
if (!readmeFile) return '';
231-
const groups = /^\s*# .*\n+([^\n]+)/.exec(readmeFile.content);
232-
return groups && groups[1] || '';
232+
const lines = readmeFile.content.split('\n');
233+
lines.shift();
234+
while (lines.length && !lines[0].trim()) lines.shift();
235+
let descriptionLines = [];
236+
while (lines.length && lines[0].trim()) descriptionLines.push(lines.shift());
237+
return removeMarkdown(descriptionLines.join(' '));
233238
}
234239

235240
render() {

0 commit comments

Comments
 (0)