File tree Expand file tree Collapse file tree 6 files changed +597
-17
lines changed Expand file tree Collapse file tree 6 files changed +597
-17
lines changed Original file line number Diff line number Diff line change 6363 "run" : " Run" ,
6464 "mostImportantParts" : " These were the most important fish parts:" ,
6565 "clickIndividualFish" : " Click individual fish to see their information." ,
66- "mostImportantPartsInDetermining" : " These were the most important fish parts in determining whether this fish was" ,
67- "or" : " or" ,
66+ "mostImportantPartsDescription" : " These were the most important fish parts in determining whether this fish was “*{word}*” or “**{notWord}**”." ,
6867 "newWord" : " New Word" ,
6968 "finish" : " Finish" ,
7069 "trainMore" : " Train More" ,
Original file line number Diff line number Diff line change 3939 "react-dom" : " ~15.4.0"
4040 },
4141 "devDependencies" : {
42+ "@code-dot-org/redactable-markdown" : " ^0.4.0" ,
4243 "@tensorflow-models/knn-classifier" : " ~1.1.0" ,
4344 "@tensorflow-models/mobilenet" : " ^2.0.4" ,
4445 "@tensorflow/tfjs" : " ^1.3.1" ,
7980 "react-addons-test-utils" : " ~15.4.0" ,
8081 "react-dom" : " ~15.4.0" ,
8182 "react-test-renderer" : " ~15.4.0" ,
83+ "rehype-react" : " ^4.0.1" ,
84+ "remark-parse" : " ^7.0.2" ,
85+ "remark-rehype" : " ^5.0.0" ,
8286 "sinon" : " ^7.5.0" ,
8387 "style-loader" : " ^1.0.0" ,
8488 "svm" : " uponthesun/svmjs" ,
Original file line number Diff line number Diff line change 4848 button {
4949 padding : 1.5% 3% ;
5050 }
51+
52+ # pondTextMarkdown p {
53+ margin : 0
54+ }
55+ # pondTextMarkdown strong {
56+ color : # eb5757 ;
57+ font-weight : normal;
58+ }
59+ # pondTextMarkdown em {
60+ color : # 56c568 ;
61+ font-style : normal;
62+ }
63+
5164
5265 /*
5366 * Primary aim is to fit the width up to 0.9 of the screen width.
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ import {
3232 faTrash
3333} from '@fortawesome/free-solid-svg-icons' ;
3434import I18n from './i18n' ;
35+ import Markdown from '@ml/utils/Markdown' ;
3536
3637const styles = {
3738 body : {
@@ -1180,18 +1181,18 @@ class PondPanel extends React.Component {
11801181 >
11811182 { state . pondExplainFishSummary && (
11821183 < div >
1183- < div style = { styles . pondPanelPreText } >
1184- { I18n . t ( 'mostImportantPartsInDetermining' ) }
1185- { ' “' }
1186- < span style = { { color : colors . green } } >
1187- { state . word . toLowerCase ( ) }
1188- </ span >
1189- { '”' } { I18n . t ( 'or' ) }
1190- { ' “' }
1191- < span style = { { color : colors . red } } >
1192- { I18n . t ( 'notWord' , { word : state . word } ) . toLowerCase ( ) }
1193- </ span >
1194- { '”' } .
1184+ < div style = { styles . pondPanelPreText } id = "pondTextMarkdown" >
1185+ < Markdown
1186+ markdown = { I18n . t (
1187+ 'mostImportantPartsDescription' ,
1188+ {
1189+ word : state . word . toLowerCase ( ) ,
1190+ notWord : I18n . t ( 'notWord' , {
1191+ word : state . word
1192+ } ) . toLowerCase ( )
1193+ }
1194+ ) }
1195+ />
11951196 </ div >
11961197 { state . pondExplainFishSummary . slice ( 0 , 4 ) . map ( ( f , i ) => (
11971198 < div key = { i } >
Original file line number Diff line number Diff line change 1+ /**
2+ * Implementation of this Markdown component is based off of the implementation
3+ * of SafeMarkdown in the main code-dot-org repo.
4+ *
5+ */
6+ import PropTypes from 'prop-types' ;
7+ import React from 'react' ;
8+
9+ import remarkRehype from 'remark-rehype' ;
10+ import rehypeReact from 'rehype-react' ;
11+ import Parser from '@code-dot-org/redactable-markdown' ;
12+
13+ const markdownProcessor = Parser . create ( )
14+ . getParser ( )
15+ . use ( remarkRehype )
16+ . use ( rehypeReact , { createElement : React . createElement } ) ;
17+
18+ export default class Markdown extends React . Component {
19+ static propTypes = {
20+ markdown : PropTypes . string . isRequired
21+ } ;
22+
23+ render ( ) {
24+ return markdownProcessor . processSync ( this . props . markdown ) . contents ;
25+ }
26+ }
You can’t perform that action at this time.
0 commit comments