interagent / prmd

JSON Schema tools and doc generation for HTTP APIs
MIT License
2.1k stars 172 forks source link

Escape patterns (regexes) in markdown #345

Closed mathias closed 4 years ago

mathias commented 4 years ago

This fixes a bug observed with the Heroku Platform API schema markdown, which is that when it puts a "pattern" in a table like this, the pipe gets interpreted as part of the markdown table, even though it is inside a code block. The solution for this is to render the pattern part in a <pre></pre> tag with an htmlentity for the pipe.

Here's what the bug looks like:

| **deploy_target:id** | *string* | unique identifier of deploy target<br/> **pattern:** `(^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$|^[a-z]{2}$)` | `"us"` |
| **deploy_target:type** | *string* | type of deploy target<br/> **pattern:** `(^space$|^region$)` | `"region"` |

becomes:

image

mathias commented 4 years ago

cc @bernerdschaefer @ransombriggs as discussed. Thanks to both of you for help on this!

mathias commented 4 years ago

prmd tests are failing on Travis here because they're trying to run on some old Rubies like Ruby 2.0. What should we be supporting here?

mathias commented 4 years ago

cc @ransombriggs passing now.