From 40d754005877b53bce0d0134e72dee7d91ce5d38 Mon Sep 17 00:00:00 2001 From: Nazo Date: Wed, 17 May 2017 18:54:17 +0300 Subject: [PATCH] Handle softbreaks properly with commonmark, fixes #100 --- nyaa/static/js/main.js | 3 +-- nyaa/templates/view.html | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/nyaa/static/js/main.js b/nyaa/static/js/main.js index 63f32c5..d6c0314 100644 --- a/nyaa/static/js/main.js +++ b/nyaa/static/js/main.js @@ -106,8 +106,7 @@ document.addEventListener("DOMContentLoaded", function() { var targetEl = markdownEditor.querySelector(targetSelector); var reader = new commonmark.Parser({safe: true}); - var writer = new commonmark.HtmlRenderer({safe: true}); - writer.softbreak = '
'; + var writer = new commonmark.HtmlRenderer({safe: true, softbreak: '
'}); previewTabEl.addEventListener('click', function () { var parsed = reader.parse(sourceSelector.value.trim()); diff --git a/nyaa/templates/view.html b/nyaa/templates/view.html index 6542c30..6c835b8 100644 --- a/nyaa/templates/view.html +++ b/nyaa/templates/view.html @@ -123,8 +123,7 @@ var target = document.getElementById('torrent-description'); var text = target.innerHTML; var reader = new commonmark.Parser({safe: true}); - var writer = new commonmark.HtmlRenderer({safe: true}); - writer.softbreak = '
'; + var writer = new commonmark.HtmlRenderer({safe: true, softbreak: '
'}); var parsed = reader.parse(text.trim()); target.innerHTML = writer.render(parsed);