Coder Social home page Coder Social logo

Comments (4)

cjw296 avatar cjw296 commented on August 19, 2024

I don't suppose there's any chance you could not use Windows line endings?

from sybil.

jborbely avatar jborbely commented on August 19, 2024

It would be a challenge for me to enforce that all of my colleagues modify their git configuration to only push LF and not CRLF line separators to the repository.

I have discovered that the root of this issue is not in Sybil but in the open function and is dependent on the platform and Python version. The following is taken from the docs,

In text mode, the default when reading is to convert platform-specific line endings (\n on Unix, \r\n on Windows) to just \n.

So Sybil should never encounter a \r. My example above that showed how to raise an IndentationError was not fair because that is not how Sybil is supposed to be used -- I would never manually create a Document in my code, but, through this example, I was able to get to the real root of this issue.

My proposed solution is to modify how text is defined. To replace

text = source.read()

with

text = '\n'.join(line.rstrip() for line in source)

I think that there is very little overhead in this change and it does help to protect Sybil against future changes to the default behaviour of the open function. I also can't think of an example where right-stripping white space from each line would cause a code-block or capture to pass when it should have failed or fail when it should have passed. It also solves the IndentationError that I experienced.

The question is whether you want to fix this issue as it appears to be unique to Python 2.7 and linux and macOS.

from sybil.

cjw296 avatar cjw296 commented on August 19, 2024

Sorry, not following: sybil opens the file in text mode, so what's happening to result in \r getting through to where it's causing you problems?

from sybil.

cjw296 avatar cjw296 commented on August 19, 2024

I think 141b3a3, which is in the 1.2.2 release, will fix your issue.

from sybil.

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.