-
Notifications
You must be signed in to change notification settings - Fork 354
Closed
Description
The current pretty_codeblock function in html.ex generates invalid HTML code, this function leaves an end tag for the code element which is not open.
iex> bin = "<pre><code>Hello world</code></pre><pre><code class=\"\">Hello world</code></pre>"
"<pre><code>Hello world</code></pre><pre><code class=\"\">Hello world</code></pre>"
iex> Regex.replace(~r/<pre><code\s*(class=\"\")?>/, bin, "<pre class=\"codeblock\">")
"<pre class=\"codeblock\">Hello world</code></pre><pre class=\"codeblock\">Hello world</code></pre>"One way to solve this is updating the regex:
iex> Regex.replace(~r/<pre><code\s*(class=\"\")?>(.+?)<\/code><\/pre>/, bin, "<pre class=\"codeblock\">\\2</pre>")
"<pre class=\"codeblock\">Hello world</pre><pre class=\"codeblock\">Hello world</pre>"But, if we look further, right now there is no rule for the .codeblock CSS class. So, I suggest to delete this pretty_codeblock and try to control the look of the <pre> and <code> tags in the CSS files, because there is where the rules that are in control of the style of HTML blocks belongs.
But, I really want to know your opinion about this matter before I propose a Pull Request.
Metadata
Metadata
Assignees
Labels
No labels