clean up regex

This commit is contained in:
craig-osterhout 2022-11-17 14:06:06 -08:00
parent 597d898942
commit 9542114e76
No known key found for this signature in database
GPG Key ID: 497A5E49261C73B5
3 changed files with 18 additions and 4 deletions

View File

@ -6,4 +6,7 @@ scope: raw
# check for 1, 2, 4, 6 or more spaces at start of line before code fence (```)
#If not indented by 3 spaces at first level or 5 spaces at second level, then a hidden space is inserted and copied by the copy code feature.
raw:
- '(?m:^[ ]{4}\`\`\`|^[ ]{6,}\`\`\`|^[ ]{1}\`\`\`|^[ ]{2}\`\`\`)'
- '(?m:^[ ]{1}\`\`\`)|'
- '(?m:^[ ]{2}\`\`\`)|'
- '(?m:^[ ]{4}\`\`\`)|'
- '(?m:^[ ]{6,}\`\`\`)'

View File

@ -5,4 +5,8 @@ level: warning
scope: raw
#check for console code fence followed by one line with $ or #, and not ending in `or \. Followed by more lines without $ or # and terminated by code fence
raw:
- '(?m:\`\`\`console\n+(\s*.*(\$|#).*[^\`\\]$)([^\$#(\`\`\`)]+\n)\s*\`\`\`)'
- '(\`\`\`console\n)' # start ```console
- '[^(\$|#)]*' # 0 or more characters without $ or #
- '.*(\$|#).*[^\`\\]\n' # 1 line with $ or #, without ` or \ at end
- '((?!\`\`\`|\$|#)(.|\n))*' # 0 or more lines without ```, $, or #
- '\`\`\`' # stop ```

View File

@ -3,6 +3,13 @@ message: "If you expect users to copy and run the command, specify one command p
link: https://docs.docker.com/contribute/style/formatting/#best-practice-for-commands
level: warning
scope: raw
#check for console code fence followed by two or more newlines with $ or #
#check for console code fence followed by at least two lines with $ or #
raw:
- '(?m:\`\`\`console\n+(\s*.*(\$|#).*\n){2,})'
- '\`\`\`console\n' # start at ```console
- '[^(\$|#)]*' # 0 or more characters without $ or #
- '.*(\$|#).*\n' # 1 line with $ or #
- '[^(\$|#)]*' # 0 or more characters without $ or #
- '.*(\$|#).*\n' # 1 line with $ or #
- '((?!\`\`\`)(.|\n))*' # 0 or characters without ```
- '\`\`\`' # stop ```