Giter Club home page Giter Club logo

Comments (3)

asottile avatar asottile commented on May 24, 2024

blacken-docs is just a thin wrapper around black -- if black can't parse it I don't think we can either

and even if we did put some weird substitution in place, I'm not sure how it could survive a round of formatting

so I think the answer here is "probably not" -- thanks for the issue though!

from blacken-docs.

grst avatar grst commented on May 24, 2024

I would also be interested in this.
Since the cell magics can only occur at the first line of a code chunk, I think it should be rather easy to exclude them.

In fact, adding a line to your regex parser that skips a line starting with % should already solve the problem.

from blacken-docs.

MarcoGorelli avatar MarcoGorelli commented on May 24, 2024

In fact, adding a line to your regex parser that skips a line starting with % should already solve the problem.

Unfortunately, this would break:

foo = (
'%s'
% 'bar'
)

if black can't parse it I don't think we can either
and even if we did put some weird substitution in place, I'm not sure how it could survive a round of formatting

Just FYI, this might soon be happening (psf/black#2357)

In the meantime, there's my little project nbQA which, like the above PR to black, transform cells using IPython's TransformerManager and ast.parse to preserve/round-trip magics

from blacken-docs.

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.