diff --git a/public/api/articles.json b/public/api/articles.json index cb67fc9..5ef4bbf 100644 --- a/public/api/articles.json +++ b/public/api/articles.json @@ -4,7 +4,7 @@ "id": 0, "title": "Test Article", "desc":"This is a description", - "contents": "Hello World" + "contents": "Hello World `SomeCode``MoreCode`Apple" } ] } \ No newline at end of file diff --git a/src/components/Article.js b/src/components/Article.js index 13d9dc3..5aa11c5 100644 --- a/src/components/Article.js +++ b/src/components/Article.js @@ -2,11 +2,50 @@ import React from 'react'; import './css/Articles.css'; const Article = ({article}) => { + let articleFormatter = (text) => { + let output = [""]; + let type = []; + let ind = 0; + let tick=false; + + for (let i = 0; i < text.length; i++) { + if (text[i] === '`') { + if (tick) { + //output[ind++] += text[i] + output[++ind] = "" + tick = false; + } else { + //output[++ind] = text[i] + type.push(1); + output[++ind] = "" + tick = true; + } + + } else { + if (output.length > type.length) { + type.push(0); + output[ind] = "" + } + output[ind] += text[i] + } + } + let code = [...output.keys()].map((i)=>{ + console.log(output[i], type[i]); + if (type[i] == 0){ + return