Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit659d5ce

Browse files
committed
flag markdown that fails to parse
1 parente0395ae commit659d5ce

File tree

3 files changed

+80
-15
lines changed

3 files changed

+80
-15
lines changed

‎web-app/src/components/Markdown/index.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import * as React from 'react'
88
import'./prism.css'
99

1010
// markdown highlighter instance
11-
constmd=newMarkdownIt({
11+
constmd:MarkdownIt=newMarkdownIt({
1212
breaks:true,
1313
// highlight: syntaxHighlight,
1414
html:true,
@@ -25,8 +25,17 @@ interface Props {
2525
}
2626

2727
constMarkdown=(props:Props)=>{
28-
consthtml=md.render(props.children)
29-
// TODO: sanitize HTML
28+
lethtml:string
29+
try{
30+
html=md.render(props.children)
31+
}catch(error){
32+
console.log(`failed to parse markdown for${props.children}`)
33+
html=`<div style='background-color: #FFB81A; padding: 0.5rem;'>
34+
<strong style='padding-bottom: 0.5rem;'>ERROR: Failed to parse markdown</strong>
35+
<p>${props.children}</p>
36+
</div>`
37+
}
38+
// TODO: sanitize markdown or HTML
3039
return<divdangerouslySetInnerHTML={{__html:html}}/>
3140
}
3241

‎web-app/src/containers/Tutorial/LevelPage/Level/index.tsx

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,20 @@ const Level = ({ level, onContinue, onLoadSolution }: Props) => {
7171
<div>
7272
<divstyle={styles.header}>Tasks</div>
7373
<divstyle={styles.steps}>
74-
{level.steps.map((step:G.Step&{status:T.ProgressStatus}|null,index:number)=>{
75-
if(!step){
76-
returnnull
77-
}
78-
return<Step
79-
order={index+1}
80-
status={step.status}
81-
content={step.content}
82-
onLoadSolution={onLoadSolution}
83-
/>
84-
})}
74+
{level.steps.map((step:G.Step&{status:T.ProgressStatus}|null,index:number)=>{
75+
if(!step){
76+
returnnull
77+
}
78+
return(
79+
<Step
80+
key={step.id}
81+
order={index+1}
82+
status={step.status}
83+
content={step.content}
84+
onLoadSolution={onLoadSolution}
85+
/>
86+
)
87+
})}
8588
</div>
8689
</div>
8790

‎web-app/stories/Level.stories.tsx

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
importReactfrom'react'
22
import*asGfrom'../../typings/graphql'
3+
import*asTfrom'../../typings'
34

45
import{action}from'@storybook/addon-actions'
56
import{withKnobs}from'@storybook/addon-knobs'
@@ -8,11 +9,17 @@ import { storiesOf } from '@storybook/react'
89
importSideBarDecoratorfrom'./utils/SideBarDecorator'
910
importLevelfrom'../src/containers/Tutorial/LevelPage/Level/index'
1011

12+
typeModifiedLevel=G.Level&{
13+
status:T.ProgressStatus
14+
index:number
15+
steps:Array<G.Step&{status:T.ProgressStatus}>
16+
}
17+
1118
storiesOf('Level',module)
1219
.addDecorator(SideBarDecorator)
1320
.addDecorator(withKnobs)
1421
.add('Level',()=>{
15-
constlevel:G.Level&{index:number}={
22+
constlevel={
1623
id:'L1',
1724
index:2,
1825
title:'A Title',
@@ -67,3 +74,49 @@ storiesOf('Level', module)
6774
}
6875
return<Levellevel={level}onContinue={action('onContinue')}onLoadSolution={action('onLoadSolution')}/>
6976
})
77+
.add('Level 2',()=>{
78+
constlevel={
79+
id:'L1',
80+
title:'A Title',
81+
description:'A description',
82+
content:'Should support markdown test\n ```js\nvar a = 1\n```\nwhew it works!',
83+
setup:{commits:['77e57cd'],commands:['npm install'],files:[]},
84+
steps:[
85+
{
86+
id:'L1:S1',
87+
content:'Should support markdown test\n ```js\nvar a = 1\n```\nwhew it works!',
88+
setup:{commits:['a4679b1'],commands:[],files:['package.json']},
89+
solution:{
90+
commits:['7c64508'],
91+
commands:['npm install'],
92+
files:['package.json'],
93+
},
94+
status:'ACTIVE',
95+
},
96+
{
97+
id:'L1:S2',
98+
content:'Should support markdown test\n ```ts\nvar a = 1\n```\nwhew it works!',
99+
setup:{commits:['8a8a5cb'],commands:[],files:['src/main.ts']},
100+
solution:{commits:['c2f7973'],commands:[],files:['src/main.ts']},
101+
status:'INCOMPLETE',
102+
},
103+
{
104+
id:'L1:S3',
105+
content:'Should support markdown test\n ```js\nvar a = 1\n```\nwhew it works!',
106+
setup:{commits:['992bcb1'],commands:[],files:['src/main.ts']},
107+
solution:{commits:['1b92779'],commands:[],files:['src/main.ts']},
108+
status:'INCOMPLETE',
109+
},
110+
{
111+
id:'L1:S4',
112+
content:'Should support markdown test\n ```js\nvar a = 1\n```\nwhew it works!',
113+
setup:{commits:['be32adb'],commands:[],files:['src/main.ts']},
114+
solution:{commits:['7fe26cb'],commands:[],files:['src/main.ts']},
115+
status:'INCOMPLETE',
116+
},
117+
],
118+
index:0,
119+
status:'ACTIVE',
120+
}
121+
return<Levellevel={level}onContinue={action('onContinue')}onLoadSolution={action('onLoadSolution')}/>
122+
})

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp