Skip to content

fix: Keep the markdown pipeline ASCII in plain view - #30

Merged
rethab merged 2 commits into
mainfrom
fix/plain-view-ascii
Jul 12, 2026
Merged

fix: Keep the markdown pipeline ASCII in plain view#30
rethab merged 2 commits into
mainfrom
fix/plain-view-ascii

Conversation

@rethab

@rethab rethab commented Jul 12, 2026

Copy link
Copy Markdown
Owner

Follow-up to #7, which made the issue view's own decorations ASCII in plain mode but left the layers underneath it alone. LC_ALL=C jira issue view --plain still emitted characters the locale can't represent, because plain output is not printed straight from Issue.String(): it is rendered by glamour, and on Jira cloud the description and comments are translated from ADF before that. Both layers decorate.

Three sources, all of them markup the tool adds around issue data:

  • glamour's notty style prefixes list items with and suffixes image alt text with . Its ascii style is a byte-for-byte copy of notty, so asking for that style instead does nothing — plain view now builds the style itself and overrides those two fields.
  • the ADF translator marks inline cards with 📍.
  • the ADF translator swaps < and > for the lookalikes /, because the markdown renderer would otherwise consume them as an HTML tag and drop the text. In ASCII mode it backslash-escapes them instead, which renders as the original character — so plain output can now be grepped for <foo>, which it couldn't before. Code blocks and inline code keep the raw brackets, since the renderer prints those verbatim and an escape would show up as a literal backslash.

Non-plain output is byte-identical: the ADF translator only drops to ASCII when the view asks it to, which it does when Display.Plain is set.

Checked against real issues in a LC_ALL=C shell: where the old binary emitted six bullets and an , the new one emits neither. What remains is the issue text itself — a curly apostrophe someone typed into a description still prints. Deciding whether to transliterate content is a different question from not decorating it, and I left it alone.

Refs ankitpokhrel#213.

rethab added 2 commits July 12, 2026 14:34
#7 made the issue view's own decorations ASCII in plain mode, but plain
output isn't printed from Issue.String() — it goes through glamour, and
descriptions and comments from Jira cloud go through the ADF translator
first. Both layers add non-ASCII of their own, so `LC_ALL=C jira issue
view --plain` still emitted characters the locale can't represent.

Three sources, all decorations the tool adds around issue data:

- glamour's `notty` style prefixes list items with a bullet and suffixes
  image alt text with an arrow. Its `ascii` style is a byte-for-byte copy
  of `notty`, so switching styles doesn't help; plain view now builds the
  style itself and overrides those two.
- the ADF translator marks inline cards with a pin emoji.
- the ADF translator replaces `<` and `>` with lookalike glyphs, because
  the markdown renderer would otherwise eat them as an HTML tag. In ASCII
  mode we backslash-escape instead, which renders as the original
  character — so `--plain` output can now be grepped for `<foo>`. Code
  blocks and inline code are left alone, since the renderer prints those
  verbatim and an escape would show up as a literal backslash.

Non-plain output is unchanged: the ADF translator only drops to ASCII
when the view asks it to, which it does when Display.Plain is set.

What's left in plain output is the issue text itself — if someone typed a
curly apostrophe into a description, it still prints. Transliterating user
content is a separate decision from not decorating it.

Addresses ankitpokhrel#213.
Render() already routed dumb terminals and pipes through renderPlain, but
only the glamour style followed: the header and the ADF translator branch
on Display.Plain, which is set solely by the --plain flag. Piping without
the flag thus mixed ASCII bullets with emoji headers and Unicode ADF
decorations. Setting the flag on the (value) receiver before rendering
makes every layer agree.

Also pin the one leak the renderer can't avoid: glamour truncates a table
cell's link URL with a hardcoded ellipsis (ansi/table_links.go), out of
reach of the style config. The new test documents it as a known issue and
will flag when a glamour upgrade changes the behavior. Getting the leak to
reproduce needs a real table — the ADF translator only writes pipes
between cells, so a one-column table is never parsed as one.
@rethab
rethab merged commit c0e0af2 into main Jul 12, 2026
8 checks passed
@rethab
rethab deleted the fix/plain-view-ascii branch July 12, 2026 13:14
rethab added a commit that referenced this pull request Aug 5, 2026
Follow-up to #7, which made the issue view's own decorations ASCII in
plain mode but left the layers underneath it alone. `LC_ALL=C jira issue
view --plain` still emitted characters the locale can't represent,
because plain output is not printed straight from `Issue.String()`: it
is rendered by glamour, and on Jira cloud the description and comments
are translated from ADF before that. Both layers decorate.

Three sources, all of them markup the tool adds around issue data:

- glamour's `notty` style prefixes list items with `•` and suffixes
image alt text with `→`. Its `ascii` style is a byte-for-byte copy of
`notty`, so asking for that style instead does nothing — plain view now
builds the style itself and overrides those two fields.
- the ADF translator marks inline cards with 📍.
- the ADF translator swaps `<` and `>` for the lookalikes `❬`/`❭`,
because the markdown renderer would otherwise consume them as an HTML
tag and drop the text. In ASCII mode it backslash-escapes them instead,
which renders as the original character — so plain output can now be
grepped for `<foo>`, which it couldn't before. Code blocks and inline
code keep the raw brackets, since the renderer prints those verbatim and
an escape would show up as a literal backslash.

Non-plain output is byte-identical: the ADF translator only drops to
ASCII when the view asks it to, which it does when `Display.Plain` is
set.

Checked against real issues in a `LC_ALL=C` shell: where the old binary
emitted six bullets and an `❭`, the new one emits neither. What remains
is the issue text itself — a curly apostrophe someone typed into a
description still prints. Deciding whether to transliterate *content* is
a different question from not decorating it, and I left it alone.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant