Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

newline added to block when 'keepUnassigned' and 'keepBlockTags' are true #51

Closed
schmuli opened this issue Aug 25, 2016 · 0 comments
Closed

Comments

@schmuli
Copy link

schmuli commented Aug 25, 2016

When using GHR with options keepUnassigned and keepBlockTags, every time I run the plugin, a newline is added below the content, but above the 'endbuild' comment.

For example:

    <!-- build:icon -->
    <link rel="shortcut icon"
        href="../assets/favicon64.png" />
    <!-- endbuild -->

    <link href='https://fonts.googleapis.com/css?family=Inconsolata|Open+Sans:300,400'
        rel='stylesheet'
        type='text/css'>

After a few runs, I get this:

    <!-- build:icon -->
    <link rel="shortcut icon"
        href="../assets/favicon64.png" />




    <!-- endbuild -->

    <link href='https://fonts.googleapis.com/css?family=Inconsolata|Open+Sans:300,400'
        rel='stylesheet'
        type='text/css'>

This is very similar to #42 but here the newline is getting added before the closing comment, rather than below.

By the way, I tried debugging this issue, and what I noticed is that because during this particular run of the plugin, the icon block didn't have any matching task in the config and therefore no replacements, the Block class is returning originalContent, and since it already has a newline, joining that with the beginTag and the endTag is what is adding extra linefeeds. I was able to fix this locally by changing:

    if (!this.replacements.length) {
        return this.config.keepUnassigned ? [this.originalContent] : [];
    }

to:

    if (!this.replacements.length) {
        return this.config.keepUnassigned ? [this.indent + this.originalContent.trim()] : [];
    }
@vahpetr vahpetr mentioned this issue Oct 24, 2016
@schmuli schmuli closed this as completed Jan 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant