@@ -55,30 +55,59 @@ $ArgumentList
5555)
5656
5757begin {
58- # We start off by declaring a number of regular expressions:
59-
60- $startComment = ' (?>
61- # Match three ticks or tildas
62- (?>```|~~~|) |
63- # Or three ticks or tilda, as long as they were preceeded by a newline and followed by less than three spaces.
64- (?<=(?>[\r\n]+){1})
65- [\s-[\r\n]]{0,3}
66- (?>```|~~~)
67- ){1}(?>
68- # Then, match two characters in the set .<>
69- [\.\<\>]{2}
70- |
71- PipeScript # or match the literal word PipeScript
58+ # Note: Markdown is one of the more complicated templates.
59+
60+ # This is because Markdown isn't _just_ Markdown. Markdown allows inline HTML. Inline HTML, in turn, allows inline JavaScript and CSS.
61+ # Also, Markdown code blocks can be provided a few different ways, and thus PipeScript can be embedded a few different ways.
62+
63+ $StartConditions =
64+ ' # three ticks can start an inline code block
65+ (?>`{3})
66+ [\.\<\>]{2} # followed by at least 2 of .<>' ,
67+ ' # Or three ticks or tilda, followed by PipeScript.
68+ (?>`{3}|~{3})
69+ PipeScript' ,
70+ ' # Or a single tick, followed by a literal pipe
71+ `\|' ,
72+ '
73+ # Or an HTML comment start
74+ <\!--' ,
75+
76+ '
77+ # Or a JavaScript/CSS comment start
78+ /\*
79+ '
80+
81+ $endConditions = @ (
82+ ' # Or a literal pipe, followed by a single tick
83+ \|`' ,
84+ ' [\.\<\>]{2} # At least 2 of .<>
85+ `{3} # followed by 3 ticks ' ,
86+ ' # Or three ticks or tildas
87+ (?>`{3}|~{3})' ,
88+ ' # or HTML comment end
89+ -->' ,
90+ ' # or JavaScript/CSS comment end
91+ \*/
92+ '
93+ )
94+
95+
96+ $startComment = " (?>
97+ $ ( $StartConditions -join ([Environment ]::NewLine + ' |' + [Environment ]::NewLine))
7298 )\s{0,}
7399 # followed by a bracket and any opening whitespace.
74100 \{\s{0,}
75- '
76- $endComment = ' \}(?>[\.\<\>]{2}|PipeScript){0,1}(?>
77- \s{0,}(?>[\r\n]+){1}\s{0,3}(?>```|~~~)
78- |
79- (?>```|~~~)
101+ "
102+
103+ $endComment = "
104+ \}
105+ \s{0,}
106+ (?>
107+ $ ( $endConditions -join ([Environment ]::NewLine + ' |' + [Environment ]::NewLine))
80108 )
81- '
109+ "
110+
82111
83112 $startRegex = " (?<PSStart>${startComment} )"
84113 # * EndRegex ```$whitespace + '}' + $EndComment```
0 commit comments