I currently have the following html within a pre-code block:
<pre class="prettyprint"><code> <html> <body> <form name="input" action="html_form_action.asp" method="get"> <input type="radio" name="sex" value="male">Male<br> <input type="radio" name="sex" value="female">Female<br> <input type="submit" value="Submit"> </form> <p>If you click the "Submit" button, the form-data will be sent to a page called "html_form_action.asp".</p> </body> </html> </code></pre>
It is indented within the html source for better structure within the document. How can I remove the leading whitespace? Through the use of javascript or is there a more simple method.
Advertisement
Answer
You may want to just change how it is output, but it is fairly simple to do with JavaScript
var p = document.querySelector(".prettyprint"); p.textContent = p.textContent.replace(/^s+/mg, "");