Development Discussion - noyainrain/util GitHub Wiki

checkre

Block level aware indentation check (XML/HTML example):

# NOTE: must be negated
^([ ]{4})* [ ]{4}\S (?= ((?!\n\1<w+)[\s\S])* \n\1</w+> )

Drawback: if block closer is wrongly indented, all lines of the block will be reported.

Block content indentation check (XML/HTML example):

# NOTE: must be negated
# if block opener
^([ ]*) <(\w+)[^>]*(?<!/)>\n
# block
(\1[ ]{4} ( \S.*\n | <(\w+)[^>]*(?<!/)> [\s\S]*\n \1[ ]{4} </\5>\n ) )*
# block closer
\1 </\2>

Drawbacks:

  • Only the block content as a whole can be reported.
  • Needs another rule to check the "root block".

Previous line based indentation check:

^(?=([ ]*)\S.*\n\1[ ]{1,3}\S)'

Drawback: reports wrong (= previous) line.

Pattern to ignore blocks where start and end marker match (e.g. Markdown's ```):

# X here is the marker
# block
((?!X)[\s\S]*) X
# tail after block
((?!X)[\s\S])*
# remainder of blocks until EOF
( X ((?!X)[\s\S])* X ((?!X)[\s\S])* )* \Z
⚠️ **GitHub.com Fallback** ⚠️