Mirinth / Raindrop

Other
0 stars 0 forks source link

Whitespace lines left if only a tag on that line #11

Open Mirinth opened 10 years ago

Mirinth commented 10 years ago

Raindrop outputs empty (whitespace) lines if only a tag (and whitespace) is present. e.g.:

<html>
    <body>
        <:cond name:>
            Hello, <:data name/:>!
        <:/cond name:>
    </body>
</html>

outputs:

<html>
    <body>

            Hello, name!

    </body>
</html>

Note the blank lines around "Hello, name!". These should be stripped by the parser for cleaner output code.

Mirinth commented 10 years ago

Counterpoint: Consider

<p>
    <:data paragraph /:>
</p>

In this case, the whitespace should be preserved.

A proper solution is going to be a little complicated since it'll involve telling a TextTag to strip out the last line, but only if it's either empty or whitespace, unless the next tag (which hasn't even been constructed yet) actually wants it preserved. Either the parser will need to have domain knowledge of the various tags (which probably makes it too complicated) or TextTags will have to be mutable (at least during construction) (which runs the risk of them being changed later when they should be immutable).

Maybe the parser could check for an empty-up-to-a-Raindrop-tag line and generate a seperate TextTag for the whitespace, then allow a newly added child of a BlockTag to examine the previous element and request that it be deleted.