Skip to content

Commit

Permalink
make the snippets markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Schwab committed Jan 11, 2019
1 parent 9f67cf7 commit af8b2d7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
7 changes: 4 additions & 3 deletions client/AddForm.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const Vue = require('vue/dist/vue.js')
const marked = require('marked')

Vue.component('add-form', {
props: ['problemProp', 'solutionProp', 'keywordStringProp'],
Expand Down Expand Up @@ -30,9 +31,9 @@ Vue.component('add-form', {
},
markdownPreview: function() {
if (this.solution) {
return this.solution
return marked(this.solution)
} else {
return "Preview of markdown solution rendering"
return "<p>Preview of markdown rendering of the solution</p>"
}
}
},
Expand All @@ -46,7 +47,7 @@ Vue.component('add-form', {
<br />
<input type="button" value="Submit" v-on:click="submit">
<hr />
<div class="md">{{ markdownPreview }}</div>
<div class="md" v-html="markdownPreview"></div>
</div>
`,
methods: {
Expand Down
8 changes: 7 additions & 1 deletion client/ViewPage.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const {ipcRenderer} = require('electron')
const Vue = require('vue/dist/vue.js')
const marked = require('marked')

let vm

Expand All @@ -17,6 +18,11 @@ Vue.component('view-page', {
}
}
},
computed: {
markedSolution: function() {
return marked(this.snippet.solution)
}
},
watch: {
snippetKey: function(key) {
if (key) {
Expand All @@ -33,7 +39,7 @@ Vue.component('view-page', {
</div>
<div id="view-results">
<p class="problem">{{ snippet.problem }}</p>
<p class="solution">{{ snippet.solution }}</p>
<div class="solution" v-html="markedSolution"></div>
<p class="keywords">{{ snippet.keywords }}</p>
</div>
</div>
Expand Down
4 changes: 0 additions & 4 deletions client/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,5 @@
width: 50%;
}

#view-results .solution {
font-family: monospace;
white-space: pre-wrap;
}


0 comments on commit af8b2d7

Please sign in to comment.