From e58200e882a16fe81e12b03ec13c47d2bb88f669 Mon Sep 17 00:00:00 2001
From: Gunjan Karamchandani
Date: Thu, 28 Sep 2017 19:04:42 +0530
Subject: [PATCH] Markdown support for question body added (#9)
---
package.json | 5 +-
src/QuestionViewer/index.js | 14 +++-
yarn.lock | 125 ++++++++++++++++++++++++++++++++++--
3 files changed, 136 insertions(+), 8 deletions(-)
diff --git a/package.json b/package.json
index 08ca373..d2c9346 100644
--- a/package.json
+++ b/package.json
@@ -8,7 +8,10 @@
"inferno-router": "^3.9.0",
"inferno-scripts": "4.2.0",
"linkstate": "^1.1.0",
- "milligram": "^1.3.0"
+ "milligram": "^1.3.0",
+ "react": "^16.0.0",
+ "remarkable": "^1.7.1",
+ "remarkable-react": "^1.0.1"
},
"proxy": "http://localhost:3000",
"scripts": {
diff --git a/src/QuestionViewer/index.js b/src/QuestionViewer/index.js
index a72172e..c856858 100644
--- a/src/QuestionViewer/index.js
+++ b/src/QuestionViewer/index.js
@@ -1,6 +1,17 @@
import { Link } from 'inferno-router';
import linkState from 'linkstate';
import Component from 'inferno-component';
+var Remarkable = require('remarkable');
+var md = new Remarkable({
+ html: true,
+ xhtmlOut: false,
+ breaks: false,
+ langPrefix: 'language-',
+ linkify: false,
+ typographer: false,
+ quotes: '“”‘’',
+ highlight: function (/*str, lang*/) { return ''; }
+});
class QuestionViewer extends Component {
state = {
@@ -25,6 +36,7 @@ class QuestionViewer extends Component {
// Read fetch documentation on how to send post request and
// display output in window.alert
}
+
render() {
const { loading, question, error, answer } = this.state
const qno = parseInt(this.props.params.qno,10)
@@ -34,7 +46,7 @@ class QuestionViewer extends Component {
Q{question.qno}: {question.title}
{error && ERROR: {error}
}
- {question.body}
+