Striptags cause indent in code

  • I'm using blocks to add chunks of example code to posts and pages.

    The default editors seem a little wonky to me when it comes to code blocks, else I would have just used them. To overcome the wonkiness, I thought to just make the <code> element a part of the block and use striptags to remove any default tags(<p>) from the output. I've not had a problem with striptags adding an indent before, but yeah. I also checked the CSS and JS to see if it might be there, even though it works fine in the template, but alas, I can see no reason why this should occur.

    Not exactly sure what, I'm missing here.

    Here's the code:

    This is the input in the editor:


    And here's the output:


  • So, apparently, this is due to an obscure white space issue in Perch's templating engine.

    Indents in the template code were reflected in the rendered HTML. I only needed to remove all indents in the template code and it rendered as it was supposed to.

    1. <!--* HTML Block — START *-->
    2. <perch:block type="html" label="HTML">
    3. <pre class="snippet language-html">
    4. <code>
    5. <perch:blog id="htmlBlock" type="textarea" markdown striptags editor="simplemde" size="xl" help="To render code, tab or indent four spaces.">
    6. </code>
    7. </pre>
    8. </perch:block>
    9. <!--* HTML Block — END *-->

    I found this out by using the Developer Console and looking at the actual source and not the Element Inspector. This also revealed a white space issue with blocks as well. Template comments(<!--* *-->) seem to alleviate this spacing issue to some degree, as found on the old forum.

    While I don't like that I cannot maintain indentation in the actual source code, I am happy that everything is now displayed as it should be.

  • drewm

    Approved the thread.