- From: Robin Berjon via cvs-syncmail <cvsmail@w3.org>
- Date: Thu, 03 Dec 2009 12:36:58 +0000
- To: public-dap-commits@w3.org
Update of /sources/public/2009/dap/ReSpec.js/js In directory hutz:/tmp/cvs-serv22728/js Modified Files: respec.js Log Message: trim leading space in examples Index: respec.js =================================================================== RCS file: /sources/public/2009/dap/ReSpec.js/js/respec.js,v retrieving revision 1.59 retrieving revision 1.60 diff -u -d -r1.59 -r1.60 --- respec.js 3 Dec 2009 12:21:52 -0000 1.59 +++ respec.js 3 Dec 2009 12:36:55 -0000 1.60 @@ -463,6 +463,23 @@ }, examples: function () { + // reindent + var exes = document.querySelectorAll("pre.example"); + for (var i = 0; i < exes.length; i++) { + var ex = exes[i]; + var lines = ex.textContent.split("\n"); + while (lines.length && /^\s*$/.test(lines[0])) lines.shift(); + while (/^\s*$/.test(lines[lines.length - 1])) lines.pop(); + var matches = /^(\s+)/.exec(lines[0]); + if (matches) { + var rep = new RegExp("^" + matches[1]); + for (var j = 0; j < lines.length; j++) { + lines[j] = lines[j].replace(rep, ""); + } + } + ex.textContent = lines.join("\n"); + } + // highlight sh_highlightDocument(this.base + "js/lang/", ".min.js"); },
Received on Thursday, 3 December 2009 12:37:06 UTC