ForgeTotal.js 5
it

Total.js 5

Convertire Markdown in HTML

Total.js 5 · total5@0.0.19 contentmarkdown Eseguita con Total.js 5

Total.js aggiunge markdown() alle stringhe. Trasforma titoli, enfasi, elenchi, link, codice e tabelle in HTML ed esegue l'escape dei tag HTML grezzi nel testo. Passa un oggetto di opzioni per scegliere cosa convertire; le più utili sono ul, links, formatting, headlines, code, tables e linetag (il tag usato per i paragrafi).

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);
}