Solvency String Format

by ibroom

HTML

<p><button name="Go">Test</button></p>

<p><textarea rows=40 cols=90>

</textarea></p>
<p>
<button name="Go">Test</button>
</p>
<div id=output></div>

JavaScript

$('button').on("click", function(){

/*
toto
- find sub roman numeral number and replace with LI
- find roman number LI and wrap in an OL
*/

var text = $('textarea').val();
debugger;
text = text.replace(/\r\n|\r|\n/g,'</p>\n<p>');
text = text.replace(/<p>\t/g,'<p>');
text = text.replace(/\t/g,'&emsp;');
text = text.replace(/\.&emsp;/g,'&emsp;');
text = text.replace(/<p>\([A-Z]\)&emsp;(.*?)<\/p>/gi,'<li>$1</li>');
text = text.replace(/<\/p>\n<li>/gi,'</p>\n<ol style="list-style-type: upper-alpha;"><li>');
text = text.replace(/<\/li>\n<p>/gi,'</li></ol>\n<p>');

text = text.replace(/<\/li>\n<p>/gi,'</li></ol>\n<p>');

debugger;
$('#output').html(text);


})