Created
January 29, 2019 06:20
-
-
Save OlivierJM/38b01eedfa759824ff65f419626b094e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function parseText(text) { | |
| let filterSpace = item => item.length > 1; | |
| let spacedWords = text | |
| .split(" ") | |
| .filter(filterSpace) | |
| .map(word => `${word} `); | |
| spacedWords.map((word, i) => { | |
| if (!word.indexOf("_")) { | |
| let newWord = <span style={{ color: "blue" }}>{word.substring(1)}</span>; | |
| spacedWords[i] = newWord; | |
| } | |
| if (!word.indexOf("*")) { | |
| let starredWord = ( | |
| <span style={{ color: "red" }}>{word.substring(1)}</span> | |
| ); | |
| spacedWords[i] = starredWord; | |
| } | |
| }); | |
| return spacedWords; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment