ForgeTotal.js 5
de

Total.js 5

Markdown in HTML umwandeln

Total.js 5 · total5@0.0.19 contentmarkdown Mit Total.js 5 ausgeführt

Total.js fügt Strings markdown() hinzu. Es wandelt Überschriften, Hervorhebungen, Listen, Links, Code und Tabellen in HTML um und maskiert rohe HTML-Tags im Text. Übergib ein Optionsobjekt, um zu wählen, was umgewandelt wird; nützlich sind ul, links, formatting, headlines, code, tables und linetag (das Tag für Absätze).

controllers/content.js
exports.install = function() {
	ROUTE('POST /markdown/', render);
};

function render($) {
	var html = ($.body.text || '').markdown({ linetag: 'p', ul: true, links: true, formatting: true, headlines: true, code: true });
	$.html(html);
}