Code Monkey home page Code Monkey logo

Comments (2)

jmdavis avatar jmdavis commented on September 27, 2024

No, stripIndent doesn't care what combination of ' ', '\t', and '\r' is used - only how many whitespace characters there are. It's designed with the idea that for it to have any chance of working reasonably, the text has to be reasonably formatted. If a file does something like mix normal spaces and tabs, then there's pretty much no way that you're going to be able to cleanly strip whitespace. stripIndent could certainly be made to remember exactly what the whitespace was on the first line and only strip that, but I would expect it to be less efficient, and I seriously question that it would actually work well in the general case. If the text isn't cleanly formatted, then the best way to strip the whitespace is going to depend on exactly what was done with that particular document.

I don't know. I can see why someone might want to strip only a specific sequence of whitespace, but stripIndent is doing exactly what it was intended to do, and the assumption from the get-go was that a function like this was only going to have any chance of working if the document was well-formatted.

from dxml.

MWumpusZ avatar MWumpusZ commented on September 27, 2024

Fair enough.
For our case, we decided we don't want to do stripIndent at all - at least not in the very general case where we were doing it until now.

from dxml.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.