tags:

views:

163

answers:

1

I have problem with <pre>, here is my code, please check my screenshot attached, how to remove those indents?

%pre.code
    :escaped
        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
        <html>
            <head></head>
            <body>
                <form>
                    <input type="text" name="empID" />
                    <input type="submit"/>        
                </form>   
            </body>
        </html>

alt text

+2  A: 

You need to use the #preserve helper to convert the newlines in the pre to newline entities, like so:

%pre.code
    - preserve do
        :escaped
            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
            <html>
                <head></head>
                <body>
                    <form>
                        <input type="text" name="empID" />
                        <input type="submit"/>        
                    </form>   
                </body>
            </html>

In the future, you'll be able to nest filters, so you can do :preserve:escaped.

nex3
`- preserve do` works, but `:preserve ` doesn't. Thanks.
Cheng
`:preserve` won't escape your content, and `:escaped` won't preserve it. That's why you need the nested filters.
nex3