[formatter] How to escape end expressions to handle JSON braces?
还没有人认领这个 Issue。
评估
调研方向
从 CLI::UI.puts 开始,使用 issue 中的 hash 和 command 示例复现 formatter 的行为。跟踪 end 表达式的解析方式,并确定字面大括号应如何转义或保留;完成的标准是闭合大括号仍然存在,并获得预期的颜色。
由索引模型根据 Issue 内容生成。
描述
Is there a way to color text and escape any braces in it?
Problem: ending braces aren't getting color or they're getting removed:
hash = {wtv: 3}
CLI::UI.puts("{{magenta:#{hash}}}") # last brace is not colored
hash2 = {wtv: {key: 3}}
CLI::UI.puts("{{magenta:#{hash2}}}") # last 2 braces are missing: "{wtv: {key: 3"
Here's one work-around I found:
CLI::UI.puts("#{CLI::UI::Color::MAGENTA.code}#{hash}", format: false)
Update: The work-around isn't as easy to do for command formatting, unless you wanna assume that commands are always cyan:
CLI::UI.puts("{{command:run { {json}}}}") # omits the ending "}}"
CLI::UI.puts("\e[#{CLI::UI::Formatter::SGR_MAP['command']}mrun { {json}}", format: false) # works
Update 2:
Using colorize also helps.
- 主要语言
- Ruby
- 星标
- 1.1k
- 派生
- 57
- 平均合并
- 2 小时 55 分钟
- 30 天内合并 PR
- 2
环境准备
我们还没有检查这个项目的环境配置文件。先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
Shopify/cli-ui 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 45/100
-
难度 2/5 1-3 小时 新手友好度 55/100
-
难度 2/5 1-3 小时 新手友好度 35/100
-
难度 3/5 1-2 天 新手友好度 35/100
-
难度 3/5 1-2 天 新手友好度 35/100
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 86/100
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
data error
难度 2/5 1-3 小时 新手友好度 82/100
riscv/riscv-unified-db#2648 ·
维护者通常 1 天内回复
-
P2 testing
难度 1/5 1 小时以内 新手友好度 90/100
维护者通常 1 天内回复