Skip to content
This repository was archived by the owner on Feb 26, 2021. It is now read-only.

Commit 253760d

Browse files
committed
Merge branch 'dev'
2 parents 9ae8571 + f39c802 commit 253760d

File tree

5 files changed

+52
-42
lines changed

5 files changed

+52
-42
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.6.4
2+
* Fix judgement parsing (#23)
3+
* Fix plain text message won't display
4+
15
## 0.6.3
26
* Fix judgement parsing (#23)
37
* Introduce dev-mode-only monitor (for debugging)

lib/parser/view.js

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

lib/view.js

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

src/parser/view.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function divideContent(lines: string[]): {
4646
function concatItems(lines: string[]): string[] {
4747

4848

49-
function isNewLine(line: string): boolean {
49+
function isNewLine({ line, nextLine, index }): boolean {
5050
// Goal: Banana
5151
const goal = /^Goal\: \S*/;
5252

@@ -64,20 +64,24 @@ function concatItems(lines: string[]): string[] {
6464
// banananananananananananananananana
6565
// : Banana
6666
const reallyLongTermIdentifier = /^\S+$/;
67+
const restOfTheJudgement = /^\s*\:\s* \S*$/;
6768

6869
return goal.test(line)
6970
|| have.test(line)
7071
|| sort.test(line)
71-
|| reallyLongTermIdentifier.test(line)
72+
|| reallyLongTermIdentifier.test(line) && (nextLine && restOfTheJudgement.test(nextLine))
7273
|| completeJudgement.test(line)
7374
}
7475

7576

7677
const newLineIndices = lines.map((line, index) => {
77-
// console.log(isNewLine(line), line)
78-
return { line, index }
78+
return {
79+
line: line,
80+
nextLine: lines[index + 1],
81+
index: index
82+
}
7983
})
80-
.filter(pair => isNewLine(pair.line))
84+
.filter(obj => isNewLine(obj))
8185
.map(pair => pair.index)
8286

8387
const aggregatedLines = newLineIndices.map((index, i) => {

src/view.tsx

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -247,15 +247,20 @@ export default class View {
247247

248248
if (type === V.Style.Info || type === V.Style.Success) {
249249
const { banner, body } = parseContent(payload);
250-
const grouped = _.groupBy(body, 'judgementForm');
251-
this.store.dispatch(updateBanner(banner));
252-
this.store.dispatch(updateBody({
253-
goal: (grouped['goal'] || []) as V.Goal[],
254-
judgement: (grouped['type judgement'] || []) as V.Judgement[],
255-
term: (grouped['term'] || []) as V.Term[],
256-
meta: (grouped['meta'] || []) as V.Meta[],
257-
sort: (grouped['sort'] || []) as V.Sort[]
258-
}));
250+
// if parseContent failed, fallback to displaying plain text
251+
if (_.isEmpty(banner) && _.isEmpty(body)) {
252+
this.store.dispatch(updatePlainText(payload.join('\n')));
253+
} else {
254+
const grouped = _.groupBy(body, 'judgementForm');
255+
this.store.dispatch(updateBanner(banner));
256+
this.store.dispatch(updateBody({
257+
goal: (grouped['goal'] || []) as V.Goal[],
258+
judgement: (grouped['type judgement'] || []) as V.Judgement[],
259+
term: (grouped['term'] || []) as V.Term[],
260+
meta: (grouped['meta'] || []) as V.Meta[],
261+
sort: (grouped['sort'] || []) as V.Sort[]
262+
}));
263+
}
259264
} else if (type === V.Style.Error) {
260265
const error = parseError(payload.join('\n'));
261266
this.store.dispatch(updateError(error));

0 commit comments

Comments
 (0)