I've just tried it, but it is inserting `<em>` tags into my code blocks where the code has large comment blocks between `*` characters. I think this naive RegEx approach will not cut it for my use-case. Can you recommend a more robust solution, like a library? I need one with MIT or similar permissive licensing and a low footprint if possible.
I've just tried it, but it is inserting `<em>` tags into my code blocks where the code has large comment blocks between `*` characters. I think this naive RegEx approach will not cut it for my use-case. Can you recommend a more robust solution, like a library? I need one with MIT or similar permissive licensing and a low footprint if possible.
user
I'm using the following RegEx:

```
(?<!<em>)(?<!<code>)(?<!<pre>)(?<!<div>)(?<!<span>)(?<!<p>)(?<!<li>)(?<!<ul>)(?<!<ol>)(?<!<h1>)(?<!<h2>)(?<!<h3>)(?<!<h4>)(?<!<h5>)(?<!<h6>)(?<!<a>)(?<!<img>)(?<!<table>)(?<!<tr>)(?<!<td>)(?<!<th>)(?<!<p>)(?<!<li>)(?<!<ul>)(?<!<ol>)(?<!<h1>)(?<!<h2>)(?<!<h3>)(?<!<h4>)(?<!<h5>)(?<!<h6>)(?<!<a>)(?<!<img>)(?<!<table>)(?<!<tr>)(?<!<td>)(?<!<th>)(?<!<p>)(?<!<li>)(?<!<ul>)(?<!<ol>)(?<!<h1>)(?<!<h2>)(?<!<h3>)(?<!<h4>)(?<!<h5>)(?<!<h6>)(?<!<a>)(?<!<img>)(?<!<table>)(?<!<tr>)(?<!<td>)(?<!<th>)(?<!<p>)(?<!<li>)(?<!<ul>)(?<!<ol>)(?<!<h1>)(?<!<h2>)(?<!<h3>)(?<!<h4>)(?<!<h5>)(?<!<h6>)(?<!<a>)(?<!<img>)(?<!<table>)(?<!<tr>)(?<
assistant
I've just tried it, but it is inserting `<em>` tags into my code blocks where the code has large comment blocks between `*` characters. I think this naive RegEx approach will not cut it for my use-case. Can you recommend a more robust solution, like a library? I need one with MIT or similar permissive licensing and a low footprint if possible.
user
I'm using the following code to insert the `<em>` tags:

```
// Insert <em> tags around code blocks
const codeBlocks = document.querySelectorAll('pre code');
for (let i = 0; i < codeBlocks.length; i++) {
  const codeBlock = codeBlocks[i];
  const text = codeBlock.textContent;
  const regex = /\*([^*]*)\*/g;
  const matches = text.match(regex);
  if (matches) {
    const newText = text.replace(regex, '<em>$1</em>');
    codeBlock.textContent = newText;
  }
}
```
assistant
I've just tried it, but it is inserting `<em>` tags into my code blocks where the code has large comment blocks between `*` characters. I think this naive RegEx approach will not cut it for my use-case. Can you recommend a more robust solution, like a library? I need one with MIT or similar permissive licensing and a low footprint if possible.
user
I'm using the following RegEx:

```
(?<!<em>)(?<!<code>)(?<!<pre>)(?<!<div>)(?<!<span>)(?<!<p>)(?<!<li>)(?<!<ul>)(?<!<ol>)(?<!<h1>)(?<!<h2>)(?<!<h3>)(?<!<h4>)(?<!<h5>)(?<!<h6>)(?<!<a>)(?<!<img>)(?<!<table>)(?<!<tr>)(?<!<td>)(?<!<th>)(?<!<p>)(?<!<li>)(?<!<ul>)(?<!<ol>)(?<!<h1>)(?<!<h2>)(?<!<h3>)(?<!<h4>)(?<!<h5>)(?<!<h6>)(?<!<a>)(?<!<img>)(?<!<table>)(?<!<tr>)(?<!<td>)(?<!<th>)(?<!<p>)(?<!<li>)(?<!<ul>)(?<!<ol>)(?<!<h1>)(?<!<h2>)(?<!<h3>)(?<!<h4>)(?<!<h5>)(?<!<h6>)(?<!<a>)(?<!<img>)(?<!<table>)(?<!<tr>)(?<!<td>)(?<!<th>)(?<!<p>)(?<!<li>)(?<!<ul>)(?<!<ol>)(?<!<h1>)(?<!<h2>)(?<!<h3>)(?<!<h4>)(?<!<h5>)(?<!<h6>)(?<!<a>)(?<!<img>)(?<!<table>)(?<!<tr>)(?<
assistant