From 5c01b5f37d19f13db31f31aa383826b75b988a68 Mon Sep 17 00:00:00 2001 From: frogtd <31412003+frogtd@users.noreply.github.com> Date: Fri, 9 Jul 2021 14:32:44 -0400 Subject: [PATCH 1/2] Fix syntax highlighting for no_run blocks I was reading the lint documentation and I noticed that some of the lints weren't getting syntax highlighting. --- util/export.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/export.py b/util/export.py index 1248e6b6a26a..bd4bcc89a209 100755 --- a/util/export.py +++ b/util/export.py @@ -10,7 +10,7 @@ from lintlib import parse_all, log lint_subheadline = re.compile(r'''^\*\*([\w\s]+?)[:?.!]?\*\*(.*)''') -rust_code_block = re.compile(r'''```rust.+?```''', flags=re.DOTALL) +rust_code_block = re.compile(r'''```(rust|no_run).+?```''', flags=re.DOTALL) CONF_TEMPLATE = """\ This lint has the following configuration variables: @@ -23,7 +23,7 @@ def parse_code_block(match): for line in match.group(0).split('\n'): # fix syntax highlighting for headers like ```rust,ignore - if line.startswith('```rust'): + if line.startswith('```rust') | line.startswith('```no_run'): lines.append('```rust') elif not line.startswith('# '): lines.append(line) From 8fb3f7e262bc5a8d52e4cbdbec8d9d6c94e65b6b Mon Sep 17 00:00:00 2001 From: frogtd <31412003+frogtd@users.noreply.github.com> Date: Fri, 9 Jul 2021 15:30:17 -0400 Subject: [PATCH 2/2] Python uses `or` not `|`. `|` is binary or and it would work in this case, but `or` is more precise. --- util/export.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/export.py b/util/export.py index bd4bcc89a209..937bca52e0f4 100755 --- a/util/export.py +++ b/util/export.py @@ -23,7 +23,7 @@ def parse_code_block(match): for line in match.group(0).split('\n'): # fix syntax highlighting for headers like ```rust,ignore - if line.startswith('```rust') | line.startswith('```no_run'): + if line.startswith('```rust') or line.startswith('```no_run'): lines.append('```rust') elif not line.startswith('# '): lines.append(line)