Skip to content

Instantly share code, notes, and snippets.

@derek-knox
Created December 30, 2017 00:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save derek-knox/23b42fd43c7f56f0a1686933ff26125c to your computer and use it in GitHub Desktop.
Save derek-knox/23b42fd43c7f56f0a1686933ff26125c to your computer and use it in GitHub Desktop.
.md to .html highlight syntax for inline code vs code blocks using regex
var pattern = /<code>(markup|css|javascript) ?(.+)<\/code>/gm;
/*
The goal is to turn this markdown (highlight syntax inline vs code block):
...for HTML (`markup .html`)...
to this HTML:
...for HTML (<code class="language-markup">.html</code>`)...
My current problem is due to the latter part of my pattern:
(.+)<\/code>
How do I ensure the capture ends exactly at the "</code>" character sequence?
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment