Skip to content

Commit af7efa5

Browse files
authored
Merge pull request carpentries/styles#597
lesson_check.py: harden single-line image/link pattern Fixes carpentries/styles#591
2 parents c82a669 + 5b9bff4 commit af7efa5

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

bin/lesson_check.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,16 @@
5757
P_INTERNAL_INCLUDE_LINK = re.compile(r'^{% include ([^ ]*) %}$')
5858

5959
# Pattern to match image-only and link-only lines
60-
P_LINK_IMAGE_LINE = re.compile("^[> ]*(!?)\[([^]]+)\][([]([^)]+)[])][ ]*$")
60+
P_LINK_IMAGE_LINE = re.compile(r'''
61+
[> #]* # any number of '>', '#', and spaces
62+
!? # ! or nothing
63+
\[[^]]+\] # [any text]
64+
[([] # ( or [
65+
[^])]+ # 1+ characters that are neither ] nor )
66+
[])] # ] or )
67+
(?:{:[^}]+})? # {:any text} or nothing
68+
[ ]* # any number of spaces
69+
\\?$ # \ or nothing + end of line''', re.VERBOSE)
6170

6271
# What kinds of blockquotes are allowed?
6372
KNOWN_BLOCKQUOTES = {

0 commit comments

Comments
 (0)