I am implementing a Markdown to HTML converter and I found myself in a situation where I don't know if one regex will suffice.
It is implied in the Markdown guide that you can escape backticks in a code block by surrounding the block with two backticks.
For instance, the following Markdown text:
``Use `code` in your Markdown file.``
should be converted to the following HTML:
<code>Use `code` in your Markdown file.</code>
My first guess for implementing this is to
- Find all of the code blocks with double backticks
- Replace the double backticks with the
<code>
tag - Do the same with single backticks, except the ones already inside a
<code>
tag
Is there any way to create a pattern that matches text between two backticks but not inside <code>
tags ? Or am I overthinking it and there is a simpler solution ?