From 5b9bff41edf1b03943e959f92c9298fdf333ead5 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Sun, 9 May 2021 02:50:44 -0500 Subject: [PATCH] lesson_check.py: harden single-line image/link pattern This change hardens the pattern that matches single-line image or link: 1. It extends the pattern to be matched in a heading 2. It allows the line to contain {: ...} customizations 3. It allows the line to end with \ --- bin/lesson_check.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/bin/lesson_check.py b/bin/lesson_check.py index 2216fa7..8416fa8 100644 --- a/bin/lesson_check.py +++ b/bin/lesson_check.py @@ -57,7 +57,16 @@ P_INTERNAL_INCLUDE_LINK = re.compile(r'^{% include ([^ ]*) %}$') # Pattern to match image-only and link-only lines -P_LINK_IMAGE_LINE = re.compile("^[> ]*(!?)\[([^]]+)\][([]([^)]+)[])][ ]*$") +P_LINK_IMAGE_LINE = re.compile(r''' + [> #]* # any number of '>', '#', and spaces + !? # ! or nothing + \[[^]]+\] # [any text] + [([] # ( or [ + [^])]+ # 1+ characters that are neither ] nor ) + [])] # ] or ) + (?:{:[^}]+})? # {:any text} or nothing + [ ]* # any number of spaces + \\?$ # \ or nothing + end of line''', re.VERBOSE) # What kinds of blockquotes are allowed? KNOWN_BLOCKQUOTES = {