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

Switch marked to commonmark

This commit is contained in:
Nazo 2017-05-16 21:29:22 +03:00
parent 6cda661554
commit 6f61970559
3 changed files with 12 additions and 4 deletions

View file

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

View file

@ -34,7 +34,7 @@
<!-- Modified to not apply border-radius to selectpickers and stuff so our navbar looks cool -->
<script src="/static/js/bootstrap-select.js"></script>
<script src="/static/js/main.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/marked/0.3.6/marked.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/commonmark/0.27.0/commonmark.min.js"></script>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>

View file

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