question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Keeps line and indentation on remove()

See original GitHub issue

When I remove an indented element that makes up the whole line it preserves the line and the indentation. This makes a document with many remove() look dirty, since it’s filled with indented whitespace on empty lines.

    <span>lorem ipsum</span>

It should IMO remove the line if all the contents is gone.

Issue Analytics

  • State:closed
  • Created 11 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
sindresorhuscommented, Nov 24, 2012

Not saying it would be hard to add to Yeoman, obviously it’s not, just would be a nice convenience in Cheerio, not having to evaluate the options, add as dep, import it, look up the API and the finally beautify, but whatever.

1reaction
ironchefpythoncommented, Nov 20, 2012
<div>
    <div id="test">dsf</div>
</div>

This is a div element with three children. A textnode containing a newline and 4 spaces, a div element with an id of “test”, and a textnode containing a newline. Removing the div child element does not (and should not) remove the text nodes.

I do understand what you want, you want the HTML resulting from Cheerio to be reformatted accoring to your preferred style. However this is not (currently) a functional goal of Cheerio, and is functionality that can best be achieved by processing the output of Cheerio with another function. I would recommend the mature and stable js-beautify) for HTML post-processing. It provides a number of options to format HTML to your standards

Read more comments on GitHub >

github_iconTop Results From Across the Web

Remove or clear a hanging indent - Microsoft Support
Select the text where you want to remove a hanging indent. Go to Home > Paragraph dialog launcher Button image > Indents and...
Read more >
Remove unecessary indents while keeping the relative ...
I a nutshell, I need to keep the minimal indentation level without loosing the relative indentations of the lines. So just drop the...
Read more >
XSLT output formatting: keep line breaks, remove indent
When I set output indent to "yes", I get both, line-breaks and indents. When I set output indent to "no", I get none....
Read more >
How to remove indentation on newline - CodeMirror
Bind Enter to a command like cm => cm.replaceSelection("\n") rather than the default, the newlineAndIndent command. 2 Likes.
Read more >
Q. How to remove first line indent? - Ask COM Library
In order to remove the first line indentation, select the "Home" menu on the ribbon. Then select the arrow for the Paragraph settings....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found