8000 Limit line-width when pretty-printing edn · Issue #151 · borkdude/jet · GitHub
[go: up one dir, main page]

Skip to content

Limit line-width when pretty-printing edn #151

Open

Description

@grav

It would be great to be able to limit the width of lines when pretty-printing edn, so that eg

{:foo {:bar [42 43]}

became

{:foo 
  {:bar 
    [42
     43]}}

depending on the max-width specified.

Discussion: https://clojurians.slack.com/archives/CM5HRADAA/p1710930246744919

Activity

  1. changed the title [-]Limit line-width with pretty-printed output[/-] [+]Limit line-width whenpretty-printing edn[/+] on Mar 20, 2024
  2. changed the title [-]Limit line-width whenpretty-printing edn[/-] [+]Limit line-width when pretty-printing edn[/+] on Mar 20, 2024
  3. added a commit that references this issue on Mar 21, 2024
    ec23abf
  4. borkdude commented on Mar 22, 2024

    @borkdude
    Owner

    I'm playing around with this option, but I'm not sure if it would fit your needs this way. E.g., I'm using fipp (an EDN pretty printer):

    $ cat deps.edn | clj -M -e "(require '[fipp.edn :as e]) (e/pprint (clojure.edn/read-string (slurp *in*)) {:width 20})"
    {:paths ["src"
             "resources"],
     :deps {org.clojure/clojure {:mvn/version "1.11.1"},
            mvxcvi/puget {:mvn/version "1.3.4"},
            rewrite-clj/rewrite-clj {:mvn/version "1.1.47"},
            commons-io/commons-io {:mvn/version "2.11.0"},
            org.babashka/cli {:mvn/version "0.8.58"},
            com.cognitect/transit-clj {:mvn/version "1.0.333"},
            clj-commons/clj-yaml {:mvn/version "1.0.26"},
            cheshire/cheshire {:mvn/version "5.11.0"},
            org.babashka/sci {:mvn/version "0.8.41"},
            com.rpl/specter {:mvn/version "1.1.4"},
            camel-snake-kebab/camel-snake-kebab {:mvn/version "0.4.3"}},
     :aliases {:test {:extra-paths ["test"],
                      :extra-deps {clj-commons/conch {:mvn/version "0.9.2"}}}},
     :tools/usage {:ns-default jet.main}}
    

    as you can see it still is more than 20 characters wide but the output does change when I set it to 200

  5. grav commented on Apr 2, 2024

    @grav
    Author

    Bummer ... seems to work pretty well with clojure.pprint/pprint (see below, docs here).

    But I guess there's performance reasons that you're not using it? FWIW, I can always pipe through the snippet below, when I need to.

    cat deps.edn | clj -M -e "(require '[clojure.pprint :as pprint]) (binding [pprint/*print-right-margin* 15] (pprint/pprint (clojure.edn/read-string (slurp *in*))))"
    {:paths
     ["src"
      "resources"],
     :deps
     {org.clojure/clojure
      #:mvn{:version
            "1.11.1"},
      mvxcvi/puget
      #:mvn{:version
            "1.3.4"},
      rewrite-clj/rewrite-clj
      #:mvn{:version
            "1.1.47"},
      commons-io/commons-io
    [snip]
    
  6. borkdude commented on Apr 2, 2024

    @borkdude
    Owner

    You can also do that with babashka for faster startup

  7. borkdude commented on Apr 2, 2024

    @borkdude
    Owner

    I'm not exactly sure why I used fipp instead of pprint, I think it was because pprint didn't work properly with graalvm a long time ago.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0