1
0
Fork 0
mirror of https://gitlab.com/SIGBUS/nyaa.git synced 2024-12-22 20:50:00 +00:00

Handle softbreaks properly with commonmark, fixes #100

This commit is contained in:
Nazo 2017-05-17 18:54:17 +03:00
parent 88311e0551
commit 40d7540058
2 changed files with 2 additions and 4 deletions

View file

@ -106,8 +106,7 @@ document.addEventListener("DOMContentLoaded", function() {
var targetEl = markdownEditor.querySelector(targetSelector); var targetEl = markdownEditor.querySelector(targetSelector);
var reader = new commonmark.Parser({safe: true}); var reader = new commonmark.Parser({safe: true});
var writer = new commonmark.HtmlRenderer({safe: true}); var writer = new commonmark.HtmlRenderer({safe: true, softbreak: '<br />'});
writer.softbreak = '<br />';
previewTabEl.addEventListener('click', function () { previewTabEl.addEventListener('click', function () {
var parsed = reader.parse(sourceSelector.value.trim()); var parsed = reader.parse(sourceSelector.value.trim());

View file

@ -123,8 +123,7 @@
var target = document.getElementById('torrent-description'); var target = document.getElementById('torrent-description');
var text = target.innerHTML; var text = target.innerHTML;
var reader = new commonmark.Parser({safe: true}); var reader = new commonmark.Parser({safe: true});
var writer = new commonmark.HtmlRenderer({safe: true}); var writer = new commonmark.HtmlRenderer({safe: true, softbreak: '<br />'});
writer.softbreak = '<br />';
var parsed = reader.parse(text.trim()); var parsed = reader.parse(text.trim());
target.innerHTML = writer.render(parsed); target.innerHTML = writer.render(parsed);
</script> </script>