From 94496df3b01dc874071b7e23fe52bd0aec332b74 Mon Sep 17 00:00:00 2001 From: David Peter Date: Tue, 16 Feb 2021 21:39:38 +0100 Subject: [PATCH] Fix broken resolv.conf highlighting closes #1510 The change in `create_highlighted_versions.py` fixes a "unknown theme "'1337'" warning. The single quotes were wrong. `bat` was always falling back to the default theme, so let's use that for now. --- src/syntax_mapping.rs | 5 +++++ tests/syntax-tests/create_highlighted_versions.py | 6 ++++-- tests/syntax-tests/highlighted/resolv.conf/resolv.conf | 4 ++++ tests/syntax-tests/source/resolv.conf/resolv.conf | 4 ++++ 4 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 tests/syntax-tests/highlighted/resolv.conf/resolv.conf create mode 100644 tests/syntax-tests/source/resolv.conf/resolv.conf diff --git a/src/syntax_mapping.rs b/src/syntax_mapping.rs index da6e45c7..2451a752 100644 --- a/src/syntax_mapping.rs +++ b/src/syntax_mapping.rs @@ -57,6 +57,11 @@ impl<'a> SyntaxMapping<'a> { .insert("*.conf", MappingTarget::MapToUnknown) .unwrap(); + // Re-insert a mapping for resolv.conf, see #1510 + mapping + .insert("resolv.conf", MappingTarget::MapTo("resolv")) + .unwrap(); + for glob in &[ "/etc/nginx/**/*.conf", "/etc/nginx/sites-*/**/*", diff --git a/tests/syntax-tests/create_highlighted_versions.py b/tests/syntax-tests/create_highlighted_versions.py index 4319f47a..75ae9a4d 100755 --- a/tests/syntax-tests/create_highlighted_versions.py +++ b/tests/syntax-tests/create_highlighted_versions.py @@ -12,7 +12,7 @@ BAT_OPTIONS = [ "--no-config", "--style=plain", "--color=always", - "--theme='1337'", + "--theme=default", "--italic-text=always", ] @@ -41,7 +41,9 @@ def create_highlighted_versions(output_basepath): root = os.path.dirname(os.path.abspath(__file__)) sources = path.join(root, "source", "*") - for source in glob.glob(path.join(sources, "*")) + glob.glob(path.join(sources, ".*")): + for source in glob.glob(path.join(sources, "*")) + glob.glob( + path.join(sources, ".*") + ): try: env = os.environ.copy() env.pop("PAGER", None) diff --git a/tests/syntax-tests/highlighted/resolv.conf/resolv.conf b/tests/syntax-tests/highlighted/resolv.conf/resolv.conf new file mode 100644 index 00000000..f0448562 --- /dev/null +++ b/tests/syntax-tests/highlighted/resolv.conf/resolv.conf @@ -0,0 +1,4 @@ +# A comment +domain example.com +nameserver 192.168.123.123 +nameserver aa00::aaaa:0000:1234:abcd diff --git a/tests/syntax-tests/source/resolv.conf/resolv.conf b/tests/syntax-tests/source/resolv.conf/resolv.conf new file mode 100644 index 00000000..def2f2d9 --- /dev/null +++ b/tests/syntax-tests/source/resolv.conf/resolv.conf @@ -0,0 +1,4 @@ +# A comment +domain example.com +nameserver 192.168.123.123 +nameserver aa00::aaaa:0000:1234:abcd