Coder Social home page Coder Social logo

Comments (2)

brandonbloom avatar brandonbloom commented on June 1, 2024 1

A few things:

  1. Fipp doesn't currently make newline handling configurable because it relies on pr for fast serialization to EDN for strings.
  2. The visit machinery is designed precisely so that it's small enough for you to copy/paste/edit if you need customized pretty documents.
  3. If you just want to monkey-patch the visit-string method, it should be possible to use extend (or extend-type or extend-protocol) instead of copy/pasting the whole of the EdnParser.
  4. I'm not sure that syntax you used is valid. Did you mean [:span "\"" [:pass x] [:span "\\""]]? Which could also be simplified to [:span "\"" [:pass x] "\""].
  5. Have you seen https://github.com/brandonbloom/fipp/blob/master/doc/primitives.md ? I don't think you want :pass at all, as it's designed for zero-width control sequences.
  6. It's also worth calling out the fact that Fipp is not a code formatter: #21 (comment)

If you wanted to do this "right", I'd probably look at inlining & editing the definition of print-method for strings:

https://github.com/clojure/clojure/blob/3b6256e654bf250ddfd01cdaa4be9f39a74c2de6/src/clj/clojure/core_print.clj#L212-L221

That would allow you to get proper newlines behavior by simply changing char-escape-string to return a [:break] node to get hard breaks that are measurement aware.

Another potential trick would be to wrap the output in a [:group ...] use a :line node with an inline form of the escape sequence: [:line "\\n"]. However, I'm not sure how to make this work correctly because Clojure does not strip prefix indentation, so using this trick would change the content of the strings. SQL doesn't care, but this would be a disaster for many other use cases. You might want a custom tagged-literal type to opt-in to this behavior.

Let me know if any of that helps.

from fipp.

isaksky avatar isaksky commented on June 1, 2024

Ok, thanks for explaining. That makes sense, especially with the design thoughts in 6. I'll go with one of those methods you suggested.

That means this is not an issue, so I'll close it. Thanks for the awesome library!

from fipp.

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.