From e859bb067c06930f6cf7a8ab23fbc16786ba6d76 Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Thu, 21 May 2020 11:03:59 -0400 Subject: [PATCH] Use margins at the document level (versus indent) in default styles (#67) * Use margins at the document level (versus indent) in default styles * Fix tests per the style changes in the previous commit --- styles.go | 8 ++--- styles/ascii.json | 2 +- styles/dark.json | 2 +- styles/light.json | 2 +- styles/notty.json | 2 +- testdata/issues/42.test | 6 ++-- testdata/issues/43.test | 16 ++++----- testdata/issues/44.test | 22 ++++++------ testdata/issues/46_1.test | 8 ++--- testdata/issues/46_2.test | 35 +++++++++--------- testdata/issues/47.test | 2 +- testdata/readme.test | 75 ++++++++++++++++++++------------------- 12 files changed, 91 insertions(+), 89 deletions(-) diff --git a/styles.go b/styles.go index 12640ee..caac382 100644 --- a/styles.go +++ b/styles.go @@ -14,7 +14,7 @@ var ( BlockPrefix: "\n", BlockSuffix: "\n", }, - Indent: uintPtr(2), + Margin: uintPtr(2), }, BlockQuote: ansi.StyleBlock{ StylePrimitive: ansi.StylePrimitive{}, @@ -122,7 +122,7 @@ var ( BlockSuffix: "\n", Color: stringPtr("252"), }, - Indent: uintPtr(2), + Margin: uintPtr(2), }, BlockQuote: ansi.StyleBlock{ StylePrimitive: ansi.StylePrimitive{}, @@ -335,7 +335,7 @@ var ( BlockSuffix: "\n", Color: stringPtr("234"), }, - Indent: uintPtr(2), + Margin: uintPtr(2), }, BlockQuote: ansi.StyleBlock{ StylePrimitive: ansi.StylePrimitive{}, @@ -546,7 +546,7 @@ var ( BlockPrefix: "\n", BlockSuffix: "\n", }, - Indent: uintPtr(2), + Margin: uintPtr(2), }, BlockQuote: ansi.StyleBlock{ StylePrimitive: ansi.StylePrimitive{}, diff --git a/styles/ascii.json b/styles/ascii.json index 52e1da5..048a729 100644 --- a/styles/ascii.json +++ b/styles/ascii.json @@ -2,7 +2,7 @@ "document": { "block_prefix": "\n", "block_suffix": "\n", - "indent": 2 + "margin": 2 }, "block_quote": { "indent": 1, diff --git a/styles/dark.json b/styles/dark.json index 44fb41c..0ba3bd5 100644 --- a/styles/dark.json +++ b/styles/dark.json @@ -3,7 +3,7 @@ "block_prefix": "\n", "block_suffix": "\n", "color": "252", - "indent": 2 + "margin": 2 }, "block_quote": { "indent": 1, diff --git a/styles/light.json b/styles/light.json index 8845006..ced0b54 100644 --- a/styles/light.json +++ b/styles/light.json @@ -3,7 +3,7 @@ "block_prefix": "\n", "block_suffix": "\n", "color": "234", - "indent": 2 + "margin": 2 }, "block_quote": { "indent": 1, diff --git a/styles/notty.json b/styles/notty.json index 8438de1..b49ec1d 100644 --- a/styles/notty.json +++ b/styles/notty.json @@ -2,7 +2,7 @@ "document": { "block_prefix": "\n", "block_suffix": "\n", - "indent": 2 + "margin": 2 }, "block_quote": { "indent": 1, diff --git a/testdata/issues/42.test b/testdata/issues/42.test index 607caa5..c3539cd 100644 --- a/testdata/issues/42.test +++ b/testdata/issues/42.test @@ -1,6 +1,6 @@ - If you want to make a more significant change, please first open an issue      - https://github.com/twpayne/chezmoi/issues/new to discuss the change that you   - want to make. Dave Cheney gives a good rationale                               + If you want to make a more significant change, please first open an issue    + https://github.com/twpayne/chezmoi/issues/new to discuss the change that you + want to make. Dave Cheney gives a good rationale                              https://dave.cheney.net/2019/02/18/talk-then-code as to why this is important. diff --git a/testdata/issues/43.test b/testdata/issues/43.test index 72d3c55..4428d7d 100644 --- a/testdata/issues/43.test +++ b/testdata/issues/43.test @@ -1,10 +1,10 @@ -                                                                                - • Getting started                                                              - • Developing locally                                                           - • Documentation changes                                                        - • Contributing changes                                                         - • Managing releases                                                            - • Packaging                                                                    - • Updating the website                                                         +                                                                              + • Getting started                                                            + • Developing locally                                                         + • Documentation changes                                                      + • Contributing changes                                                       + • Managing releases                                                          + • Packaging                                                                  + • Updating the website                                                       diff --git a/testdata/issues/44.test b/testdata/issues/44.test index fe04fb8..63da718 100644 --- a/testdata/issues/44.test +++ b/testdata/issues/44.test @@ -1,13 +1,13 @@ -                                                                                -  DISTRIBUTION │ ARCHITECTURES │ PACKAGE                     - ───────────────┼────────────────────────────────┼──────────                    -  Debian │ amd64, arm64, armel, i386, │ deb                     -  │ ppc64, ppc64le │                     -  RedHat │ aarch64, armhfp, i686, ppc64, │ rpm                     -  │ ppc64le, x86_64 │                     -  OpenSUSE │ aarch64, armhfp, i686, ppc64, │ rpm                     -  │ ppc64le, x86_64 │                     -  Ubuntu │ amd64, arm64, armel, i386, │ deb                     -  │ ppc64, ppc64le │                     +                                                                              +  DISTRIBUTION │ ARCHITECTURES │ PACKAGE                   + ───────────────┼────────────────────────────────┼──────────                  +  Debian │ amd64, arm64, armel, i386, │ deb                   +  │ ppc64, ppc64le │                   +  RedHat │ aarch64, armhfp, i686, ppc64, │ rpm                   +  │ ppc64le, x86_64 │                   +  OpenSUSE │ aarch64, armhfp, i686, ppc64, │ rpm                   +  │ ppc64le, x86_64 │                   +  Ubuntu │ amd64, arm64, armel, i386, │ deb                   +  │ ppc64, ppc64le │                    diff --git a/testdata/issues/46_1.test b/testdata/issues/46_1.test index 6ffe1d9..1e69f5c 100644 --- a/testdata/issues/46_1.test +++ b/testdata/issues/46_1.test @@ -1,6 +1,6 @@ -                                                                                - • Navigation                                                                   -   • Familiar shortcuts (arrows, ~, -, @), quick reference                      -                                                                                +                                                                              + • Navigation                                                                 +   • Familiar shortcuts (arrows, ~, -, @), quick reference                    +                                                                              diff --git a/testdata/issues/46_2.test b/testdata/issues/46_2.test index 49e2e62..8bb4977 100644 --- a/testdata/issues/46_2.test +++ b/testdata/issues/46_2.test @@ -1,20 +1,21 @@ -                                                                                -  DEPENDENCY │ INSTALLATION │ OPERATION          +                                                                              +  DEPENDENCY │ INSTALLATION │ OPERATION         ─────────────────────────────────┼──────────────┼───────────────────────────────── -  xdg-open (Linux), open(1) │ base │ desktop opener               -  (macOS), cygstart (Cygwin) │ │                              -  file, coreutils (cp, mv, rm), │ base │ file type, copy, move and    -  xargs │ │ remove                       -  tar, (un)zip [atool/bsdtar for │ base │ create, list, extract tar,   -  more formats] │ │ gzip, bzip2, zip             -  archivemount, fusermount(3) │ optional │ mount, unmount archives      -  sshfs, rclone, fusermount(3) │ optional │ mount, unmount remotes       -  trash-cli │ optional │ trash files (default action: -  │ │ rm)                          -  vlock (Linux), bashlock │ optional │ terminal locker (fallback:   -  (macOS), lock(1) (BSD) │ │ cmatrix)                     -  advcpmv (Linux) (integration) │ optional │ copy, move progress          -  $VISUAL (else $EDITOR), │ optional │ fallback vi, less, sh        -  $PAGER, $SHELL │ │                              +  xdg-open (Linux), open(1) │ base │ desktop opener             +  (macOS), cygstart (Cygwin) │ │                            +  file, coreutils (cp, mv, rm), │ base │ file type, copy, move and  +  xargs │ │ remove                     +  tar, (un)zip [atool/bsdtar for │ base │ create, list, extract tar, +  more formats] │ │ gzip, bzip2, zip           +  archivemount, fusermount(3) │ optional │ mount, unmount archives    +  sshfs, rclone, fusermount(3) │ optional │ mount, unmount remotes     +  trash-cli │ optional │ trash files (default       + action:                                                                   +  │ │ rm)                        +  vlock (Linux), bashlock │ optional │ terminal locker (fallback: +  (macOS), lock(1) (BSD) │ │ cmatrix)                   +  advcpmv (Linux) (integration) │ optional │ copy, move progress        +  $VISUAL (else $EDITOR), │ optional │ fallback vi, less, sh      +  $PAGER, $SHELL │ │                             diff --git a/testdata/issues/47.test b/testdata/issues/47.test index 461e1a8..7556767 100644 --- a/testdata/issues/47.test +++ b/testdata/issues/47.test @@ -1,3 +1,3 @@ - Example:                                                       + Example:                                                     diff --git a/testdata/readme.test b/testdata/readme.test index e9c4a9d..356f124 100644 --- a/testdata/readme.test +++ b/testdata/readme.test @@ -1,39 +1,40 @@ -  Gold                                                                          -                                                                                - Render markdown on the CLI, with pizzazz!                                      -                                                                                - ## What is it?                                                                 -                                                                                - Gold is a Golang library that allows you to use JSON based stylesheets to      - render Markdown files in the terminal. Just like CSS, you can define color and - style attributes on Markdown elements. The difference is that you use ANSI     - color and terminal codes instead of CSS properties and hex colors.             -                                                                                - ## Usage                                                                       -                                                                                - See cmd/gold /cmd/gold/.                                                       -                                                                                - ## Example Output                                                              -                                                                                - Image: Gold Dark Style →                                                       - https://github.com/charmbracelet/gold/raw/master/styles/gallery/dark.png       -                                                                                - Check out the Gold Style Gallery                                               - https://github.com/charmbracelet/gold/blob/master/styles/gallery/README.md!    -                                                                                - ## Colors                                                                      -                                                                                - Currently  gold  uses the Aurora ANSI colors                                   - https://godoc.org/github.com/logrusorgru/aurora#Index.                         -                                                                                - ## Development                                                                 -                                                                                - Style definitions located in  styles/  can be embedded into the binary by      - running statik https://github.com/rakyll/statik:                               -                                                                                -   statik -f -src styles -include "*.json"                                      -                                                                                - You can re-generate screenshots of all available styles by running  gallery.sh - . This requires  termshot  and  pngcrush  installed on your system!            +  Gold                                                                        +                                                                              + Render markdown on the CLI, with pizzazz!                                    +                                                                              + ## What is it?                                                               +                                                                              + Gold is a Golang library that allows you to use JSON based stylesheets to    + render Markdown files in the terminal. Just like CSS, you can define color   + and style attributes on Markdown elements. The difference is that you use    + ANSI color and terminal codes instead of CSS properties and hex colors.      +                                                                              + ## Usage                                                                     +                                                                              + See cmd/gold /cmd/gold/.                                                     +                                                                              + ## Example Output                                                            +                                                                              + Image: Gold Dark Style →                                                     + https://github.com/charmbracelet/gold/raw/master/styles/gallery/dark.png     +                                                                              + Check out the Gold Style Gallery                                             + https://github.com/charmbracelet/gold/blob/master/styles/gallery/README.md!  +                                                                              + ## Colors                                                                    +                                                                              + Currently  gold  uses the Aurora ANSI colors                                 + https://godoc.org/github.com/logrusorgru/aurora#Index.                       +                                                                              + ## Development                                                               +                                                                              + Style definitions located in  styles/  can be embedded into the binary by    + running statik https://github.com/rakyll/statik:                             +                                                                              +   statik -f -src styles -include "*.json"                                    +                                                                              + You can re-generate screenshots of all available styles by running           + gallery.sh . This requires  termshot  and  pngcrush  installed on your       + system!