PrettyCSS icon indicating copy to clipboard operation
PrettyCSS copied to clipboard

atblock_pre and atblock_post don't seem to have an effect

Open cwallacetlc opened this issue 8 years ago • 3 comments

I'd like my @media blocks to have a newline after the brace, so I've set atblock_pre to {\n in the config file (pasted below), but when I run it, the @media blocks come out like this:

@media screen and (max-width:1130px) {.header-logo {
        margin-top: 20px;
    }

There should be a newline and four spaces before .header-logo. It looks like atblock_pre is ignored, and it always just puts a single brace.

Also, I've compared the output between a config file that defines atblock_pre and atblock_post and one that doesn't, and the output files were identical. It seems those two options are completely ignored.

Config file:

{
    "selector_comma": ",\n",
    "indent": "    ",
    "atblock_pre": "{\n    "
}

cwallacetlc avatar Feb 22 '17 20:02 cwallacetlc

It looks like atblock_pre and atblock_post are not honored, but instead it is using block_pre and block_post. Please give that a shot. This is a bug and should get fixed, though I would much rather rewrite the parser and eliminate the mess of code that I have inside this project.

fidian avatar Feb 22 '17 21:02 fidian

Using block_pre, it is better. I'm able to put a newline + spaces after the opening brace for the at-block. But then I get an extra blank line at the beginning of normal blocks. It seems that's caused by property_pre, which I can set to the empty string.

That just about gets me where I want to be! The only issue now is two trailing lines at the end of at-blocks, caused by stylesheet_whitespace being two newlines. But if I do anything with that, I won't get a blank line between rules, which I do want. I think I'll just write a script to delete blank lines before a closing brace.

Thanks!

cwallacetlc avatar Feb 22 '17 22:02 cwallacetlc

I've tried poking into the issue myself and modifying code so it uses atblock_pre and atblock_post. It looks like I will need to rewrite the entire block output code because I should have something to strip the whitespace between the inside block and the outer atblock. Unfortunately, this affects a lot more than what I had intended and will likely change how the CSS is generated across the tool.

While it is a good idea for me to rewrite this, I don't know when I'll have enough time to dedicate to the project. :-( Even if I did make atblock_pre and atblock_post honored, you would end up with the same issues as what you're having right now.

Edit: Leaving this open because it is certainly a flaw in the software. I'll retain hope that I will return to this project and fix it in the future.

fidian avatar Feb 23 '17 15:02 fidian