diff --git a/ansi/blockelement.go b/ansi/blockelement.go index 2ca7bb34..add6e05a 100644 --- a/ansi/blockelement.go +++ b/ansi/blockelement.go @@ -36,7 +36,7 @@ func (e *BlockElement) Finish(w io.Writer, ctx RenderContext) error { " ,.;-+|", ) - mw := NewMarginWriter(ctx, w, bs.Current().Style) + mw := NewMarginWriter(ctx, w, bs.Current().Style, true) if _, err := io.WriteString(mw, s); err != nil { return err } diff --git a/ansi/codeblock.go b/ansi/codeblock.go index 076f936b..87df9496 100644 --- a/ansi/codeblock.go +++ b/ansi/codeblock.go @@ -124,7 +124,7 @@ func (e *CodeBlockElement) Finish(w io.Writer, ctx RenderContext) error { mutex.Unlock() } - mw := NewMarginWriter(ctx, w, bs.Current().Style) + mw := NewMarginWriter(ctx, w, bs.Current().Style, false) renderText(mw, ctx.options.ColorProfile, bs.Current().Style.StylePrimitive, rules.BlockPrefix) if len(theme) > 0 { err := quick.Highlight(mw, e.Code, e.Language, "terminal256", theme) diff --git a/ansi/heading.go b/ansi/heading.go index b7e2e755..d9fdfe1c 100644 --- a/ansi/heading.go +++ b/ansi/heading.go @@ -59,7 +59,7 @@ func (e *HeadingElement) Render(w io.Writer, ctx RenderContext) error { func (e *HeadingElement) Finish(w io.Writer, ctx RenderContext) error { bs := ctx.blockStack rules := bs.Current().Style - mw := NewMarginWriter(ctx, w, rules) + mw := NewMarginWriter(ctx, w, rules, true) flow := wordwrap.NewWriter(int(bs.Width(ctx))) _, err := flow.Write(bs.Current().Block.Bytes()) diff --git a/ansi/margin.go b/ansi/margin.go index 1fd6e8cc..dbbf82be 100644 --- a/ansi/margin.go +++ b/ansi/margin.go @@ -24,7 +24,7 @@ type MarginWriter struct { } // NewMarginWriter returns a new MarginWriter. -func NewMarginWriter(ctx RenderContext, w io.Writer, rules StyleBlock) *MarginWriter { +func NewMarginWriter(ctx RenderContext, w io.Writer, rules StyleBlock, padded bool) *MarginWriter { bs := ctx.blockStack mw := &MarginWriter{ w: w, @@ -44,11 +44,15 @@ func NewMarginWriter(ctx RenderContext, w io.Writer, rules StyleBlock) *MarginWr mw.margin = *rules.Margin } - mw.pw = padding.NewWriterPipe(mw.w, bs.Width(ctx), func(wr io.Writer) { - renderText(mw.w, mw.profile, mw.rules, " ") - }) + fwd := mw.w + if padded { + mw.pw = padding.NewWriterPipe(mw.w, bs.Width(ctx), func(wr io.Writer) { + renderText(mw.w, mw.profile, mw.rules, "") + }) + fwd = mw.pw + } - mw.iw = indent.NewWriterPipe(mw.pw, mw.indentation+mw.margin, mw.indentFunc) + mw.iw = indent.NewWriterPipe(fwd, mw.indentation+(mw.margin*2), mw.indentFunc) return mw } diff --git a/ansi/paragraph.go b/ansi/paragraph.go index 96513275..b2582df0 100644 --- a/ansi/paragraph.go +++ b/ansi/paragraph.go @@ -35,7 +35,7 @@ func (e *ParagraphElement) Finish(w io.Writer, ctx RenderContext) error { bs := ctx.blockStack rules := bs.Current().Style - mw := NewMarginWriter(ctx, w, rules) + mw := NewMarginWriter(ctx, w, rules, true) if len(strings.TrimSpace(bs.Current().Block.String())) > 0 { flow := wordwrap.NewWriter(int(bs.Width(ctx))) flow.KeepNewlines = ctx.options.PreserveNewLines diff --git a/ansi/testdata/TestRenderer/block_quote.golden b/ansi/testdata/TestRenderer/block_quote.golden index 8bc88d84..383d0138 100644 --- a/ansi/testdata/TestRenderer/block_quote.golden +++ b/ansi/testdata/TestRenderer/block_quote.golden @@ -1,2 +1,2 @@ - -=> First line of quote Second line                                                + +=> First line of quote Second line diff --git a/ansi/testdata/TestRenderer/code.golden b/ansi/testdata/TestRenderer/code.golden index ba6f5d31..25790fd9 100644 --- a/ansi/testdata/TestRenderer/code.golden +++ b/ansi/testdata/TestRenderer/code.golden @@ -1 +1 @@ -This is a code. +This is a code. diff --git a/ansi/testdata/TestRenderer/code_block.golden b/ansi/testdata/TestRenderer/code_block.golden index 81107efb..5d6938d1 100644 --- a/ansi/testdata/TestRenderer/code_block.golden +++ b/ansi/testdata/TestRenderer/code_block.golden @@ -1,3 +1,3 @@ - -This is a code block.                                                            + +This is a code block.  \ No newline at end of file diff --git a/ansi/testdata/TestRenderer/emoji.golden b/ansi/testdata/TestRenderer/emoji.golden index 0d1abe49..204160da 100644 --- a/ansi/testdata/TestRenderer/emoji.golden +++ b/ansi/testdata/TestRenderer/emoji.golden @@ -1 +1 @@ -πŸ™ ⚑ 🐱 = ❀️ +πŸ™ ⚑ 🐱 = ❀️ diff --git a/ansi/testdata/TestRenderer/emph.golden b/ansi/testdata/TestRenderer/emph.golden index 2d963988..02b5ba66 100644 --- a/ansi/testdata/TestRenderer/emph.golden +++ b/ansi/testdata/TestRenderer/emph.golden @@ -1 +1 @@ -This text is emphasized. +This text is emphasized. diff --git a/ansi/testdata/TestRenderer/enumeration.golden b/ansi/testdata/TestRenderer/enumeration.golden index 13e62fcf..eee4f755 100644 --- a/ansi/testdata/TestRenderer/enumeration.golden +++ b/ansi/testdata/TestRenderer/enumeration.golden @@ -1,3 +1,3 @@ - -1. First Item                                                                    -2. Second Item                                                                   + +1. First Item +2. Second Item diff --git a/ansi/testdata/TestRenderer/heading.golden b/ansi/testdata/TestRenderer/heading.golden index 134dfc58..4de117ba 100644 --- a/ansi/testdata/TestRenderer/heading.golden +++ b/ansi/testdata/TestRenderer/heading.golden @@ -1,3 +1,3 @@ -=> h1 <= -## h2 +=> h1 <= +## h2 ### h3 \ No newline at end of file diff --git a/ansi/testdata/TestRenderer/image.golden b/ansi/testdata/TestRenderer/image.golden index e4ea8ac7..85a49191 100644 --- a/ansi/testdata/TestRenderer/image.golden +++ b/ansi/testdata/TestRenderer/image.golden @@ -1 +1 @@ -Image [Image: https://charm.sh/logo.png]. +Image [Image: https://charm.sh/logo.png]. diff --git a/ansi/testdata/TestRenderer/link.golden b/ansi/testdata/TestRenderer/link.golden index ed11bdb4..38b0da0f 100644 --- a/ansi/testdata/TestRenderer/link.golden +++ b/ansi/testdata/TestRenderer/link.golden @@ -1 +1 @@ -This is a link (https://charm.sh). +This is a link (https://charm.sh). diff --git a/ansi/testdata/TestRenderer/list.golden b/ansi/testdata/TestRenderer/list.golden index 4ba92dc8..f131caad 100644 --- a/ansi/testdata/TestRenderer/list.golden +++ b/ansi/testdata/TestRenderer/list.golden @@ -1,4 +1,4 @@ - -β€’ First Item                                                                     -    β€’ Nested List Item                                                           -β€’ Second Item                                                                    + +β€’ First Item +    β€’ Nested List Item +β€’ Second Item diff --git a/ansi/testdata/TestRenderer/ordered_list.golden b/ansi/testdata/TestRenderer/ordered_list.golden index c262de69..d2941ee7 100644 --- a/ansi/testdata/TestRenderer/ordered_list.golden +++ b/ansi/testdata/TestRenderer/ordered_list.golden @@ -1,4 +1,4 @@ - -3. 3 is first and numbered 3 -4. 4 is second and numbered 4 -5. ten is third and numbered 5 + +3. 3 is first and numbered 3 +4. 4 is second and numbered 4 +5. ten is third and numbered 5 diff --git a/ansi/testdata/TestRenderer/strikethrough.golden b/ansi/testdata/TestRenderer/strikethrough.golden index 7aae17a4..15c9485d 100644 --- a/ansi/testdata/TestRenderer/strikethrough.golden +++ b/ansi/testdata/TestRenderer/strikethrough.golden @@ -1 +1 @@ -Scratch this. +Scratch this. diff --git a/ansi/testdata/TestRenderer/strong.golden b/ansi/testdata/TestRenderer/strong.golden index 33470429..21be3040 100644 --- a/ansi/testdata/TestRenderer/strong.golden +++ b/ansi/testdata/TestRenderer/strong.golden @@ -1 +1 @@ -This text is strong. +This text is strong. diff --git a/ansi/testdata/TestRenderer/table.golden b/ansi/testdata/TestRenderer/table.golden index eae2429a..82e621f6 100644 --- a/ansi/testdata/TestRenderer/table.golden +++ b/ansi/testdata/TestRenderer/table.golden @@ -1,4 +1,4 @@ - + Label β”‚Value β”‚URL ──────────────────┼────────────────┼──────────────────────────────────────────── First β”‚foo β”‚https://charm.sh https://charm.sh diff --git a/ansi/testdata/TestRenderer/table_align.golden b/ansi/testdata/TestRenderer/table_align.golden index 4507bc62..73ceee6b 100644 --- a/ansi/testdata/TestRenderer/table_align.golden +++ b/ansi/testdata/TestRenderer/table_align.golden @@ -1,4 +1,4 @@ - + Label β”‚ Value β”‚ URL ──────────────────┼────────────────┼──────────────────────────────────────────── First β”‚ foo β”‚ charm.sh diff --git a/ansi/testdata/TestRenderer/task.golden b/ansi/testdata/TestRenderer/task.golden index ead71348..a7bc051d 100644 --- a/ansi/testdata/TestRenderer/task.golden +++ b/ansi/testdata/TestRenderer/task.golden @@ -1,3 +1,3 @@ - -βœ“ Finished Task                                                                  -βœ— Outstanding Task                                                               + +βœ“ Finished Task +βœ— Outstanding Task diff --git a/ansi/testdata/TestRendererIssues/106.golden b/ansi/testdata/TestRendererIssues/106.golden index 6a0e4633..1a5b46f9 100644 --- a/ansi/testdata/TestRendererIssues/106.golden +++ b/ansi/testdata/TestRendererIssues/106.golden @@ -1,17 +1,17 @@ -                                                                              - β€’ `hi`                                                                       - β€’ \hi                                                                        - β€’ *hi                                                                        - β€’ _hi                                                                        - β€’ {hi}                                                                       - β€’ [hi]                                                                       - β€’                                                                        - β€’ (hi)                                                                       - β€’ # hi                                                                       - β€’ + hi                                                                       - β€’ - hi                                                                       - β€’ . hi                                                                       - β€’ ! hi                                                                       - β€’ | hi                                                                       + + β€’ `hi` + β€’ \hi + β€’ *hi + β€’ _hi + β€’ {hi} + β€’ [hi] + β€’  + β€’ (hi) + β€’ # hi + β€’ + hi + β€’ - hi + β€’ . hi + β€’ ! hi + β€’ | hi diff --git a/ansi/testdata/TestRendererIssues/107.golden b/ansi/testdata/TestRendererIssues/107.golden index 0f11c0e6..10af51e3 100644 --- a/ansi/testdata/TestRendererIssues/107.golden +++ b/ansi/testdata/TestRendererIssues/107.golden @@ -1,7 +1,7 @@ -                                                                              -   [Mount]                                                                    -   Options=reconnect,ServerAliveInterval=15,ServerAliveCountMax=3,noauto,     - _netdev,allow_other,uid=1000,gid=1000,IdentityFile=/PATH/TO/SSH-KEY/id_rsa,  - StrictHostKeyChecking=no                                                     + +     [Mount] +     Options=reconnect,ServerAliveInterval=15,ServerAliveCountMax=3,noauto, + _netdev,allow_other,uid=1000,gid=1000,IdentityFile=/PATH/TO/SSH-KEY/id_rsa, + StrictHostKeyChecking=no  diff --git a/ansi/testdata/TestRendererIssues/117.golden b/ansi/testdata/TestRendererIssues/117.golden index 6456bf56..3e2d9842 100644 --- a/ansi/testdata/TestRendererIssues/117.golden +++ b/ansi/testdata/TestRendererIssues/117.golden @@ -1,6 +1,6 @@ -                                                                              - cmd β”‚descr - ────────────────────────────────────┼─────────────────────────────────────── -  glow config  β”‚open glow config + + cmd β”‚descr + ────────────────────────────────────┼─────────────────────────────────────── +  glow config  β”‚open glow config diff --git a/ansi/testdata/TestRendererIssues/149.golden b/ansi/testdata/TestRendererIssues/149.golden index 86069be8..a790ebd5 100644 --- a/ansi/testdata/TestRendererIssues/149.golden +++ b/ansi/testdata/TestRendererIssues/149.golden @@ -1,5 +1,5 @@ - a http://example.com/with-a-big-path/likely-to-use-more-than-one-line?why-   - not=after-all-                                                               - why-not-use-queryparams-too&abc=123                                          + a http://example.com/with-a-big-path/likely-to-use-more-than-one-line?why- + not=after-all- + why-not-use-queryparams-too&abc=123 diff --git a/ansi/testdata/TestRendererIssues/172.golden b/ansi/testdata/TestRendererIssues/172.golden index 5afc5636..f9acb1db 100644 --- a/ansi/testdata/TestRendererIssues/172.golden +++ b/ansi/testdata/TestRendererIssues/172.golden @@ -1,7 +1,7 @@ -                                                                              - β”‚ The quick brown fox jumps over the lazy dog. The quick brown fox jumps     - over                                                                         - β”‚ the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown - β”‚ fox jumps over the lazy dog.                                               + + β”‚ The quick brown fox jumps over the lazy dog. The quick brown fox jumps + over + β”‚ the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown + β”‚ fox jumps over the lazy dog. diff --git a/ansi/testdata/TestRendererIssues/237.golden b/ansi/testdata/TestRendererIssues/237.golden index 28c37995..be61ffb4 100644 --- a/ansi/testdata/TestRendererIssues/237.golden +++ b/ansi/testdata/TestRendererIssues/237.golden @@ -1,10 +1,10 @@ -                                                                              - β”‚ Content Security Policy (CSP) is an added layer of security that helps to  - β”‚ detect and mitigate certain types of attacks, including Cross-Site         - β”‚ Scripting                                                                  - β”‚ (XSS) and data injection attacks. These attacks are used for everything    - β”‚ from data theft, to site defacement, to malware distribution.              - β”‚                                                                            - β”‚ from MDN                                                                   + + β”‚ Content Security Policy (CSP) is an added layer of security that helps to + β”‚ detect and mitigate certain types of attacks, including Cross-Site + β”‚ Scripting + β”‚ (XSS) and data injection attacks. These attacks are used for everything + β”‚ from data theft, to site defacement, to malware distribution. + β”‚  + β”‚ from MDN diff --git a/ansi/testdata/TestRendererIssues/239.golden b/ansi/testdata/TestRendererIssues/239.golden index 0d88ee10..fd24d448 100644 --- a/ansi/testdata/TestRendererIssues/239.golden +++ b/ansi/testdata/TestRendererIssues/239.golden @@ -1,9 +1,9 @@ -                                                                              - First term                                                                   - 🠢 Definition one of first term.                                              -                                                                              - Second term                                                                  - 🠢 Definition one of second term.                                             -                                                                              + + First term + 🠢 Definition one of first term. + + Second term + 🠢 Definition one of second term. + diff --git a/ansi/testdata/TestRendererIssues/257.golden b/ansi/testdata/TestRendererIssues/257.golden index 56a7d22d..261dfd63 100644 --- a/ansi/testdata/TestRendererIssues/257.golden +++ b/ansi/testdata/TestRendererIssues/257.golden @@ -1,4 +1,4 @@ -                                                                              -   set runtimepath^=$XDG_CONFIG_HOME/vim                                      + +     set runtimepath^=$XDG_CONFIG_HOME/vim  diff --git a/ansi/testdata/TestRendererIssues/290.golden b/ansi/testdata/TestRendererIssues/290.golden index 1cc53087..cd8f602a 100644 --- a/ansi/testdata/TestRendererIssues/290.golden +++ b/ansi/testdata/TestRendererIssues/290.golden @@ -1,6 +1,6 @@ -                                                                              - β€’ test@example.com mailto:test@example.com                                   - β€’ https://google.com https://google.com                                      - β€’ https://google.com https://google.com                                      + + β€’ test@example.com mailto:test@example.com + β€’ https://google.com https://google.com + β€’ https://google.com https://google.com diff --git a/ansi/testdata/TestRendererIssues/312.golden b/ansi/testdata/TestRendererIssues/312.golden index 48c9c0ba..ccaa2334 100644 --- a/ansi/testdata/TestRendererIssues/312.golden +++ b/ansi/testdata/TestRendererIssues/312.golden @@ -1,17 +1,17 @@ -  File                                                                        -                                                                              - bold text with URL https://www.example.com                                   -                                                                              - italic text with URL https://www.example.com                                 -                                                                              - URL https://www.example.com                                                  -                                                                              - url with bold within https://www.example.com                                 -                                                                              - url with italic within https://www.example.com                               -                                                                              - entire url text is bold https://www.example.com                              -                                                                              - entire url text is italic https://www.example.com                            +  File  + + bold text with URL https://www.example.com + + italic text with URL https://www.example.com + + URL https://www.example.com + + url with bold within https://www.example.com + + url with italic within https://www.example.com + + entire url text is bold https://www.example.com + + entire url text is italic https://www.example.com diff --git a/ansi/testdata/TestRendererIssues/313.golden b/ansi/testdata/TestRendererIssues/313.golden index 127f65e2..9c89ffa5 100644 --- a/ansi/testdata/TestRendererIssues/313.golden +++ b/ansi/testdata/TestRendererIssues/313.golden @@ -1,8 +1,8 @@ -                                                                              - β”‚ This is a block quote                                                      - β”‚                                                                            - β”‚ β”‚ This is the nested quote                                                 - β”‚                                                                            - β”‚ This is part of the outer block quote.                                     + + β”‚ This is a block quote + β”‚  + β”‚ β”‚ This is the nested quote + β”‚  + β”‚ This is part of the outer block quote. diff --git a/ansi/testdata/TestRendererIssues/315.golden b/ansi/testdata/TestRendererIssues/315.golden index 4cbc3d8e..39f969be 100644 --- a/ansi/testdata/TestRendererIssues/315.golden +++ b/ansi/testdata/TestRendererIssues/315.golden @@ -1,6 +1,6 @@ -                                                                              - Expression β”‚Value β”‚Type - ───────────────────────────────────────────┼────────────────┼─────────────── -  (1 >= 26) || (12 >= 6) {.java} β”‚s β”‚a + + Expression β”‚Value β”‚Type + ───────────────────────────────────────────┼────────────────┼─────────────── +  (1 >= 26) || (12 >= 6) {.java} β”‚s β”‚a diff --git a/ansi/testdata/TestRendererIssues/316.golden b/ansi/testdata/TestRendererIssues/316.golden index 4a7e2032..5226de60 100644 --- a/ansi/testdata/TestRendererIssues/316.golden +++ b/ansi/testdata/TestRendererIssues/316.golden @@ -1,7 +1,7 @@ -                                                                              - Aβ”‚B - ────────────────────────────────────────────────────────┼─────────────────── - Here https://example.comβ”‚hello - https://autolink.com https://autolink.comβ”‚world + + Aβ”‚B + ────────────────────────────────────────────────────────┼─────────────────── + Here https://example.comβ”‚hello + https://autolink.com https://autolink.comβ”‚world diff --git a/ansi/testdata/TestRendererIssues/42.golden b/ansi/testdata/TestRendererIssues/42.golden index 19478759..e6871a95 100644 --- a/ansi/testdata/TestRendererIssues/42.golden +++ b/ansi/testdata/TestRendererIssues/42.golden @@ -1,7 +1,7 @@ - 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.                                                                   + 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/ansi/testdata/TestRendererIssues/43.golden b/ansi/testdata/TestRendererIssues/43.golden index f88488f2..a22ecc05 100644 --- a/ansi/testdata/TestRendererIssues/43.golden +++ b/ansi/testdata/TestRendererIssues/43.golden @@ -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/ansi/testdata/TestRendererIssues/44.golden b/ansi/testdata/TestRendererIssues/44.golden index 60fb0347..76b33f03 100644 --- a/ansi/testdata/TestRendererIssues/44.golden +++ b/ansi/testdata/TestRendererIssues/44.golden @@ -1,9 +1,9 @@ -                                                                              - Distri…β”‚Architectures β”‚Package - ───────┼─────────────────────────────────┼────────────────────────────────── - Debian β”‚ amd64 ,  arm64 ,  armel ,  i386…β”‚ deb  https://github.com/twpayne/… - RedHat β”‚ aarch64 ,  armhfp ,  i686 ,  pp…β”‚ rpm  https://github.com/twpayne/… - OpenSU…β”‚ aarch64 ,  armhfp ,  i686 ,  pp…β”‚ rpm  https://github.com/twpayne/… - Ubuntu β”‚ amd64 ,  arm64 ,  armel ,  i386…β”‚ deb  https://github.com/twpayne/… + + Distri…β”‚Architectures β”‚Package + ───────┼─────────────────────────────────┼────────────────────────────────── + Debian β”‚ amd64 ,  arm64 ,  armel ,  i386…β”‚ deb  https://github.com/twpayne/… + RedHat β”‚ aarch64 ,  armhfp ,  i686 ,  pp…β”‚ rpm  https://github.com/twpayne/… + OpenSU…β”‚ aarch64 ,  armhfp ,  i686 ,  pp…β”‚ rpm  https://github.com/twpayne/… + Ubuntu β”‚ amd64 ,  arm64 ,  armel ,  i386…β”‚ deb  https://github.com/twpayne/… diff --git a/ansi/testdata/TestRendererIssues/46_1.golden b/ansi/testdata/TestRendererIssues/46_1.golden index 0eb404ed..be7831a3 100644 --- a/ansi/testdata/TestRendererIssues/46_1.golden +++ b/ansi/testdata/TestRendererIssues/46_1.golden @@ -1,6 +1,6 @@ -                                                                              - β€’ Navigation                                                                 -   β€’ Familiar shortcuts (arrows, ~, -, @), quick reference                    -                                                                              + + β€’ Navigation +   β€’ Familiar shortcuts (arrows, ~, -, @), quick reference + diff --git a/ansi/testdata/TestRendererIssues/46_2.golden b/ansi/testdata/TestRendererIssues/46_2.golden index 745200bc..5512df15 100644 --- a/ansi/testdata/TestRendererIssues/46_2.golden +++ b/ansi/testdata/TestRendererIssues/46_2.golden @@ -1,14 +1,14 @@ -                                                                              - Dependency β”‚Installa…β”‚Operation - ─────────────────────────────────────────┼─────────┼──────────────────────── - xdg-open (Linux), open(1) (macOS), cygst…β”‚base β”‚desktop opener - file, coreutils (cp, mv, rm), xargs β”‚base β”‚file type, copy, move a… - tar, (un)zip [atool/bsdtar for more form…β”‚base β”‚create, list, extract t… - archivemount, fusermount(3) β”‚optional β”‚mount, unmount archives - sshfs, rclone https://rclone.org/, fuser…β”‚optional β”‚mount, unmount remotes - trash-cli β”‚optional β”‚trash files (default ac… - vlock (Linux), bashlock (macOS), lock(1)…β”‚optional β”‚terminal locker (fallba… - advcpmv (Linux) (integration https://git…β”‚optional β”‚copy, move progress -  $VISUAL  (else  $EDITOR ),  $PAGER ,  $…β”‚optional β”‚fallback vi, less, sh + + Dependency β”‚Installa…β”‚Operation + ─────────────────────────────────────────┼─────────┼──────────────────────── + xdg-open (Linux), open(1) (macOS), cygst…β”‚base β”‚desktop opener + file, coreutils (cp, mv, rm), xargs β”‚base β”‚file type, copy, move a… + tar, (un)zip [atool/bsdtar for more form…β”‚base β”‚create, list, extract t… + archivemount, fusermount(3) β”‚optional β”‚mount, unmount archives + sshfs, rclone https://rclone.org/, fuser…β”‚optional β”‚mount, unmount remotes + trash-cli β”‚optional β”‚trash files (default ac… + vlock (Linux), bashlock (macOS), lock(1)…β”‚optional β”‚terminal locker (fallba… + advcpmv (Linux) (integration https://git…β”‚optional β”‚copy, move progress +  $VISUAL  (else  $EDITOR ),  $PAGER ,  $…β”‚optional β”‚fallback vi, less, sh diff --git a/ansi/testdata/TestRendererIssues/47.golden b/ansi/testdata/TestRendererIssues/47.golden index 5422c7c3..c663b3d4 100644 --- a/ansi/testdata/TestRendererIssues/47.golden +++ b/ansi/testdata/TestRendererIssues/47.golden @@ -1,3 +1,3 @@ - Example:                                                    + Example:   diff --git a/ansi/testdata/TestRendererIssues/48.golden b/ansi/testdata/TestRendererIssues/48.golden index 719d8b1c..379dce4f 100644 --- a/ansi/testdata/TestRendererIssues/48.golden +++ b/ansi/testdata/TestRendererIssues/48.golden @@ -1,17 +1,17 @@ - emoji in text                                                                -                                                                              - πŸ™ ⚑ 🐱 = ❀️                                                                -                                                                              - emoji in header                                                              -                                                                              - ## πŸ™ ⚑ 🐱 = ❀️                                                             -                                                                              - no emoji in code blocks                                                      -                                                                              -   :octopus: :zap: :cat: = :heart:                                            -                                                                              - no emoji in inline code                                                      -                                                                              -  :octopus: :zap: :cat: = :heart:                                             + emoji in text + + πŸ™ ⚑ 🐱 = ❀️ + + emoji in header +  + ## πŸ™ ⚑ 🐱 = ❀️ + + no emoji in code blocks + +     :octopus: :zap: :cat: = :heart: + + no emoji in inline code + +  :octopus: :zap: :cat: = :heart:  diff --git a/ansi/testdata/TestRendererIssues/60.golden b/ansi/testdata/TestRendererIssues/60.golden index c9c8688a..3ee492bd 100644 --- a/ansi/testdata/TestRendererIssues/60.golden +++ b/ansi/testdata/TestRendererIssues/60.golden @@ -1,28 +1,28 @@ -                                                                              - Library β”‚Version - ─────────────────────────────────────────────────────────────┼────────────── - ESMF https://github.com/esmf-org/esmf β”‚v8.6.1 - FMS https://github.com/NOAA-GFDL/FMS/ β”‚2024.01.02 - netCDF https://github.com/Unidata/netcdf-c β”‚4.9.2 - netCDF Fortran https://github.com/Unidata/netcdf-fortran β”‚4.6.1 - netCDF C++ https://github.com/Unidata/netcdf-cxx4 β”‚4.3.1 - HDF5 https://portal.hdfgroup.org/display/support β”‚1.10.11 - HDF4 https://portal.hdfgroup.org/display/support β”‚4.2.16-2 - GFE https://github.com/Goddard-Fortran-Ecosystem/GFE β”‚v1.16.0 - xgboost https://github.com/dmlc/xgboost β”‚v1.6.0 - libyaml https://github.com/yaml/libyaml.git β”‚0.2.5 - antlr2 https://www.antlr2.org/ β”‚2.7.7 - GSL https://www.gnu.org/software/gsl/ β”‚2.7 - jpeg http://www.ijg.org/ β”‚9e - zlib http://www.zlib.net/ β”‚1.3.1 - szip https://support.hdfgroup.org/doc_resource/SZIP/ β”‚2.1.1 - cURL https://curl.haxx.se/ β”‚8.8.0 - UDUNITS2 https://github.com/GMAO-SI-Team/UDUNITS-2.git β”‚2.2.28 - NCO http://nco.sourceforge.net/ β”‚5.2.6 - CDO https://code.mpimet.mpg.de/projects/cdo β”‚2.3.0 - nccmp https://gitlab.com/remikz/nccmp β”‚1.9.1.0 - HDF-EOS2 https://wiki.earthdata.nasa.gov/display/DAS β”‚3.0 - HDF-EOS5 https://wiki.earthdata.nasa.gov/display/DAS β”‚2.0 - SDP Toolkit https://wiki.earthdata.nasa.gov/display/DAS β”‚5.2.20 + + Library β”‚Version + ─────────────────────────────────────────────────────────────┼────────────── + ESMF https://github.com/esmf-org/esmf β”‚v8.6.1 + FMS https://github.com/NOAA-GFDL/FMS/ β”‚2024.01.02 + netCDF https://github.com/Unidata/netcdf-c β”‚4.9.2 + netCDF Fortran https://github.com/Unidata/netcdf-fortran β”‚4.6.1 + netCDF C++ https://github.com/Unidata/netcdf-cxx4 β”‚4.3.1 + HDF5 https://portal.hdfgroup.org/display/support β”‚1.10.11 + HDF4 https://portal.hdfgroup.org/display/support β”‚4.2.16-2 + GFE https://github.com/Goddard-Fortran-Ecosystem/GFE β”‚v1.16.0 + xgboost https://github.com/dmlc/xgboost β”‚v1.6.0 + libyaml https://github.com/yaml/libyaml.git β”‚0.2.5 + antlr2 https://www.antlr2.org/ β”‚2.7.7 + GSL https://www.gnu.org/software/gsl/ β”‚2.7 + jpeg http://www.ijg.org/ β”‚9e + zlib http://www.zlib.net/ β”‚1.3.1 + szip https://support.hdfgroup.org/doc_resource/SZIP/ β”‚2.1.1 + cURL https://curl.haxx.se/ β”‚8.8.0 + UDUNITS2 https://github.com/GMAO-SI-Team/UDUNITS-2.git β”‚2.2.28 + NCO http://nco.sourceforge.net/ β”‚5.2.6 + CDO https://code.mpimet.mpg.de/projects/cdo β”‚2.3.0 + nccmp https://gitlab.com/remikz/nccmp β”‚1.9.1.0 + HDF-EOS2 https://wiki.earthdata.nasa.gov/display/DAS β”‚3.0 + HDF-EOS5 https://wiki.earthdata.nasa.gov/display/DAS β”‚2.0 + SDP Toolkit https://wiki.earthdata.nasa.gov/display/DAS β”‚5.2.20 diff --git a/ansi/testdata/TestRendererIssues/79.golden b/ansi/testdata/TestRendererIssues/79.golden index a8065704..8180b20f 100644 --- a/ansi/testdata/TestRendererIssues/79.golden +++ b/ansi/testdata/TestRendererIssues/79.golden @@ -1,9 +1,9 @@ - Preceding blockquote paragraph                                               -                                                                              - β”‚ 1st blockquote paragraph                                                   - β”‚                                                                            - β”‚   quoted code block                                                        - β”‚                                                                            - β”‚ 2nd blockquote paragraph                                                   + Preceding blockquote paragraph + + β”‚ 1st blockquote paragraph + β”‚  + β”‚     quoted code block + β”‚  + β”‚ 2nd blockquote paragraph diff --git a/examples/artichokes/main.go b/examples/artichokes/main.go index 231f154e..fc6903b7 100644 --- a/examples/artichokes/main.go +++ b/examples/artichokes/main.go @@ -6,8 +6,9 @@ import ( "log" "os" - "github.com/charmbracelet/glamour" "github.com/muesli/termenv" + + "github.com/charmbracelet/glamour" ) //go:embed artichokes.md diff --git a/glamour.go b/glamour.go index 6a8a1c38..c7c50229 100644 --- a/glamour.go +++ b/glamour.go @@ -16,7 +16,7 @@ import ( "golang.org/x/term" "github.com/charmbracelet/glamour/ansi" - styles "github.com/charmbracelet/glamour/styles" + "github.com/charmbracelet/glamour/styles" ) const ( diff --git a/glamour_test.go b/glamour_test.go index dc152a72..cf00b930 100644 --- a/glamour_test.go +++ b/glamour_test.go @@ -8,8 +8,9 @@ import ( "strings" "testing" - styles "github.com/charmbracelet/glamour/styles" "github.com/charmbracelet/x/exp/golden" + + styles "github.com/charmbracelet/glamour/styles" ) const markdown = "testdata/readme.markdown.in" diff --git a/testdata/TestCapitalization.golden b/testdata/TestCapitalization.golden index 2c684356..cb35a6b8 100644 --- a/testdata/TestCapitalization.golden +++ b/testdata/TestCapitalization.golden @@ -1,7 +1,7 @@ -  EVERYTHING IS UPPERCASE                                                     -                                                                              - ## Everything Is Titled                                                      -                                                                              - ### everything is lowercase                                                  +  EVERYTHING IS UPPERCASE  +  + ## Everything Is Titled +  + ### everything is lowercase  diff --git a/testdata/TestRenderHelpers.golden b/testdata/TestRenderHelpers.golden index 04a122cc..7c3344ab 100644 --- a/testdata/TestRenderHelpers.golden +++ b/testdata/TestRenderHelpers.golden @@ -1,40 +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! diff --git a/testdata/TestTermRenderer.golden b/testdata/TestTermRenderer.golden index 04a122cc..7c3344ab 100644 --- a/testdata/TestTermRenderer.golden +++ b/testdata/TestTermRenderer.golden @@ -1,40 +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! diff --git a/testdata/TestTermRendererWriter.golden b/testdata/TestTermRendererWriter.golden index 04a122cc..7c3344ab 100644 --- a/testdata/TestTermRendererWriter.golden +++ b/testdata/TestTermRendererWriter.golden @@ -1,40 +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! diff --git a/testdata/TestWithPreservedNewLines.golden b/testdata/TestWithPreservedNewLines.golden index 54f4f7c5..4bfc295f 100644 --- a/testdata/TestWithPreservedNewLines.golden +++ b/testdata/TestWithPreservedNewLines.golden @@ -1,5 +1,5 @@ -Preserving line breaks will ensure -that this text displays on two separate lines - -While this text appears on one line, it will wrap when the text meets the -renderer's default value of 80 characters +Preserving line breaks will ensure +that this text displays on two separate lines + +While this text appears on one line, it will wrap when the text meets the +renderer's default value of 80 characters