Repository: zng-ui/zng (language: rust)

Issue:
AnsiText does not clear style sometimes
<!--
Please, make sure:

- The issue happens in the latest crate release or newer (master branch).
- The issue happens after `cargo update`.
-->

I tried this code:

```ansi
&#x1b;[31mRED&#x1b;[47m normal text
&#x1b;[32;1mGREEN&amp;BOLD&#x1b;[47m normal text
&#x1b;[34mBLUE&#x1b;[47m normal text
```

Following these steps:

1 - Run markdown example.
2 - Scroll to ANSI example.

I saw this happen:

"normal text" in the second line is bold.

I expected this to happen:

All style cleared.

This also happens in the respawn example crash dialog window.


Discussion / hints:

Fix patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d8eb4c4f5..59f2e6da1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -19,6 +19,8 @@
 * Fix potential issue retrieving current_exe trough symbolic links.
 * Fix view-process panic message.
 * Add `APP.about`.
+* Fix `AnsiText!` not resetting style.
+* `Markdown!` widget now uses `AnsiText!` for ```console code block.
 
 # 0.3.4
 
diff --git a/crates/zng-wgt-ansi-text/src/lib.rs b/crates/zng-wgt-ansi-text/src/lib.rs
index f4c586bcd..bc0b1b630 100644
--- a/crates/zng-wgt-ansi-text/src/lib.rs
+++ b/crates/zng-wgt-ansi-text/src/lib.rs
@@ -270,6 +270,7 @@ mod ansi_parse {
             let mut esc_codes = esc_codes.split(';');
             while let Some(code) = esc_codes.next() {
                 match code {
+                    "0" => *self = Self::default(),
                     "1" => self.weight = AnsiWeight::Bold,
                     "2" => self.weight = AnsiWeight::Faint,
                     "3" => self.italic = true,
diff --git a/crates/zng-wgt-markdown/src/view_fn.rs b/crates/zng-wgt-markdown/src/view_fn.rs
index 123f8d955..4fc375655 100644
--- a/crates/zng-wgt-markdown/src/view_fn.rs
+++ b/crates/zng-wgt-markdown/src/view_fn.rs
@@ -495,13 +495,13 @@ pub fn default_link_fn(args: LinkFnArgs) -> impl UiNode {
 
 /// Default code block view.
 ///
-/// Is [`AnsiText!`] for the `ansi` language, and only raw text for the rest.
+/// Is [`AnsiText!`] for the `ansi` and `console` languages, and only raw text for the rest.
 ///
 /// See [`CODE_BLOCK_FN_VAR`] for more details.
 ///
 /// [`AnsiText!`]: struct@zng_wgt_ansi_text::AnsiText
 pub fn default_code_block_fn(args: CodeBlockFnArgs) -> impl UiNode {
-    if args.lang == "ansi" {
+    if ["ansi", "console"].contains(&args.lang.as_str()) {
         zng_wgt_ansi_text::AnsiText! {
             txt = args.txt;
             padding = 6;
diff --git a/examples/res/markdown/sample.md b/examples/res/markdown/sample.md
index 8684ddfcf..be8e71a74 100644
--- a/examples/res/markdown/sample.md
+++ b/examples/res/markdown/sample.md
@@ -72,12 +72,12 @@ Text
 * Manually formatted.
 ```
 
-ANSI escape codes with lang `ansi`:
+ANSI escape codes with lang `console` or `ansi`:
 
-```ansi
-&#x1b;[31mRED&#x1b;[47m normal text
-&#x1b;[32;1mGREEN&amp;BOLD&#x1b;[47m normal text
-&#x1b;[34mBLUE&#x1b;[47m normal text
+```console
+&#x1b;[31mRED&#x1b;[0m normal text
+&#x1b;[32;1mGREEN&amp;BOLD&#x1b;[0m normal text
+&#x1b;[34mBLUE&#x1b;[0m normal text
 ```
 
 ### Rule


Test patch: