From 3019b992353ee1dd70833d3b63492a6883f87015 Mon Sep 17 00:00:00 2001 From: Donaldttt Date: Sun, 3 Jul 2022 00:47:10 -0400 Subject: [PATCH] improve style --- bash_tools/dict.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bash_tools/dict.py b/bash_tools/dict.py index 535edfe..57119f0 100644 --- a/bash_tools/dict.py +++ b/bash_tools/dict.py @@ -1,5 +1,7 @@ import json import sys +import re + from urllib.request import urlopen Usage = """ @@ -11,6 +13,7 @@ try: from rich.console import Console from rich.panel import Panel from rich.text import Text + from rich import print HAS_RICH = 1 except: pass @@ -63,11 +66,12 @@ def rich_paring(data): for s in samples[:2]: ens = s['en'].replace('"', '\"') - panel = Panel(Text(ens, style="rgb(12,122,108)", justify="left")) + ens = re.sub(r'\*\*([^ ]*?)\*\*', r'[/][red]\1[/][yellow4]', ens) + + text = Text.from_markup("[yellow4]" + ens + "[/]", justify="left") + panel = Panel(text) - #console.print(ens, style="rgb(165,38,28)") console.print(panel) - #console.print(s['cn'], style="rgb(13,245,86)") if __name__ == "__main__":