1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
function previsualisation() {
t=document.newpost.textvalue.value
t=code_to_html(t)
if (document.getElementById) document.getElementById("prev_news").innerHTML=t
}
function deblaie(reg,t) {
textvalue=new String(t);
return textvalue.replace(reg,'$1\n');
}
function remplace_tag(reg,rep,t) {
textvalue=new String(t);
return textvalue.replace(reg,rep);
}
function remblaie(t) {
textvalue=new String(t);
return textvalue.replace(/\n/g,'');
}
function nl2br(t) {
textvalue=new String(t);
return textvalue.replace(/\n/g,'<br/>');
}
function nl2khol(t) {
textvalue=new String(t);
return textvalue.replace(/\n/g,ptag);
}
function unkhol(t) {
textvalue=new String(t);
return textvalue.replace(new RegExp(ptag,'g'),'\n');
}
function code_to_html(t) {
t=nl2khol(t)
//remplacement des balises html
t=deblaie(/(<)/g,t)
t= remplace_tag(/</g,'<',t)
t=remblaie(t)
// balise Gras
t=deblaie(/(\[\/gras\])/g,t)
t=remplace_tag(/\[gras\](.+)\[\/gras\]/g,'<b>$1</b>',t)
t=remblaie(t)
// balise Italic
t=deblaie(/(\[\/i\])/g,t)
t=remplace_tag(/\[i\](.+)\[\/i\]/g,'<b>$1</b>',t)
t=remblaie(t)
//Citation
t=deblaie(/(\[\/citation\])/g,t)
t=remplace_tag(/\[citation\](.+)\[\/citation\]/g,'<br /><span class="citation">Citation</span><div class="citation2">$1</div>',t)
t=remblaie(t)
t=unkhol(t)
t=nl2br(t)
t=remblaie(t)
return t
} |
Partager