Comments (2)
A few things:
- Fipp doesn't currently make newline handling configurable because it relies on
pr
for fast serialization to EDN for strings. - The visit machinery is designed precisely so that it's small enough for you to copy/paste/edit if you need customized pretty documents.
- If you just want to monkey-patch the
visit-string
method, it should be possible to useextend
(orextend-type
orextend-protocol
) instead of copy/pasting the whole of the EdnParser. - 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] "\""]
. - 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. - 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:
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.
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)
- Just a small warning in CLJS (undeclared var `fipp.edn/*file*`) HOT 1
- Cannot load fipp in Java 9 using bootclasspath HOT 10
- Optional println? HOT 1
- Make usage of commas optional HOT 3
- :pass rendered before indentation HOT 4
- clojurescript tests failing HOT 2
- consider automating tests on circleci HOT 3
- print-table of nested map HOT 1
- Use of undeclared Var clojure.core.rrb-vector.rrbt/Transient HOT 3
- java.sql.Timestamp not guaranteed to exist HOT 9
- BigDecimal Handling HOT 10
- Incompatible with Java 11 due to org.clojure/core.rrb-vector dependency HOT 1
- a strange case in generating regex with slashes, related to ClojureScript HOT 5
- print unreadable symbol utilizing #=(symbol ...) for *read-eval* HOT 1
- Babashka compatibility HOT 19
- How to specify fixed width floats in specific tagged-literals for output purposes HOT 2
- ClojureScript: fipp interacts badly with console.log as default print strategy HOT 6
- UnsupportedOperationException when printing java.sql.Date HOT 2
- Optionally print without trailing comma HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fipp.