mirror of
https://github.com/rmcrackan/Libation.git
synced 2026-05-08 23:54:10 -04:00
fixed matching of first property
This commit is contained in:
@@ -156,11 +156,14 @@ public partial class ConditionalTagCollection<TClass>(bool caseSensitive = true)
|
||||
^<(?<not>!)? # tags start with a '<'. Condtionals allow an optional ! captured in <not> to negate the condition
|
||||
{TagNameForRegex()} # next the tagname needs to be matched with space being made optional. Also escape all '#'
|
||||
\s+ # Separate the following with whitespace
|
||||
(?<property>(?: # capture the <property>
|
||||
(?<property> # capture the <property>
|
||||
'(?:[^']|'')*' # - allow 'string' to be included in the format, with '' being an escaped ' character
|
||||
| "(?:[^"]|"")*" # - allow "string" to be included in the format, with "" being an escaped " character
|
||||
| [^:\#!≡=≠~<>≤≥&∉∌∈∌⋂⊆⊇⊂⊃-] # - match any character with some exclusions that should only be used in operands
|
||||
) +? (?<!\s)) # - don't let <property> end with a whitepace. Otherwise "<tagname = tag2->" would be matchable.
|
||||
| (?: \[ (?: \\. # - properties may have optional formatting details enclosed in '[' and ']'. '\' escapes allways the next character
|
||||
| [^\\\]] # unescaped characters except ']' and '\' are allowed in the formatting details
|
||||
)* \] # closing the formatting details part
|
||||
| . )+? # - match any character to form the property name. Capture non greedy so it won't match the operator part.
|
||||
(?<!\s)) # - don't let <property> end with a whitepace. Otherwise "<tagname = tag2->" would be matchable.
|
||||
\s+ # Separate the following operand with whitespace
|
||||
(?<check_or_op> # capture operator in <op> and <num_op> with every char escapable
|
||||
[\#!≡=≠~<>≤≥&∉∌∈∌⋂⊆⊇⊂⊃-]+ # allow a wide range of operators, all non alphanumeric
|
||||
|
||||
@@ -639,7 +639,7 @@ namespace TemplatesTests
|
||||
[DataRow("<cmp author != 'Sherlock'->true<-cmp>", "true")]
|
||||
[DataRow("<!cmp author != 'Sherlock'->false<-cmp>", "")]
|
||||
[DataRow("<cmp tag = 'Tag1'->true<-cmp>", "true")]
|
||||
[DataRow("<cmp tag[separator(:)slice(-2..)] = 'Tag2:Tag3'->true<-cmp>", "true")]
|
||||
[DataRow("<cmp tag[separator( : )slice(-2..)] = 'Tag2 : Tag3'->true<-cmp>", "true")]
|
||||
[DataRow("<cmp audible subtitle[3] = 'an'->true<-cmp>", "")]
|
||||
[DataRow("<cmp audible subtitle[3] = 'an '->true<-cmp>", "true")]
|
||||
[DataRow("<cmp audible subtitle[3] = ' an'->true<-cmp>", "")]
|
||||
|
||||
Reference in New Issue
Block a user