File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed
lib/prmd/templates/schemata Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change 137137 end
138138
139139 if value['pattern']
140- # Prevent the pipe regex pattern characters from being interpreted as markdown table:
141- pattern = value['pattern'].gsub(/\|/, '|')
140+ # Prevent the pipe regex pattern characters from being interpreted
141+ # as markdown table.
142+ # Prevent instances of []() in regexes from being rendered as
143+ # markdown links.
144+ # Prevent patterns with * being rendered as having emphasis
145+ # or being an unordered list.
146+ pattern = value['pattern']
147+ .gsub(/\|/, '|')
148+ .gsub(/\[/, '[')
149+ .gsub(/\*/, '*')
142150
143151 description += "<br/> **pattern:** <pre>#{pattern}</pre>"
144152 end
Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ def test_render_for_example_as_an_array
5151 end
5252
5353 def test_render_for_regex_patterns_with_pipes
54- expression = /<pre>\( \^ first \$ | \^ second \$ \) < \/ pre> \| \` "second" \` \| \n /
54+ expression = /<pre>\^ [a-z \] \( \? :[a|b \] \) \& ast;[a-z]* \$ /
5555 markdown = render
5656 assert_match expression , markdown
5757 end
@@ -123,7 +123,7 @@ def data
123123 'description' => 'A string with a regex pattern applied to it.' ,
124124 'type' => 'string' ,
125125 'example' => 'second' ,
126- 'pattern' => '(^first$|^second$) '
126+ 'pattern' => '^[a-z](?:[a|b])*[a-z]*$ '
127127 } ,
128128 'option1' => {
129129 'properties' => {
You can’t perform that action at this time.
0 commit comments