hyperlinks inside code tags
-
I’ve noticed an interesting discrepancy between Prismatic vs vanilla WordPress behavior: if I add a new page, Option (kebab menu) > Code editor and paste the following raw HTML:
I use?<code><a >perl -ne</a></code> one-liners every day.
and view the page with Prismatic deactivated, it renders as a hyperlink with monospaced link text, like this:
I use?
perl -ne
one-liners every day.However, when I activate Prismatic (even with Settings > Prismatic > General : Library = None) and view the same page again, it instead renders the HTML markup for the hyperlink, like this:
I use?
<a >perl -ne</a>
one-liners every day.(which is not what I want — if I did want that, I would paste my markup into the Visual editor, which would take care of HTML-escaping it with e.g.
<
behind the scenes so it’s syntactically just text content for the code element)The test case above implicitly involves a Classic block, and one might argue that when dealing with Classic blocks it’s my responsibility to invert those tags (placing
code
inside ofa
instead of outside) and then everything would be fine. However, it’s also pretty easy to fall into this same trap writing new content using the WP block editor: if I typeI use perl -ne one-liners every day.
into a paragraph block, then put backticks around the
perl -ne
bit to make it inline code, then select just that bit with my mouse and click the Link button (and supply a URL) to make it a hyperlink, I end up with the same constellation of underlying tags —a
inside ofcode
— which looks fine in the block editor but not when viewing the page with Prismatic activated. The raw HTML in this case ends up as:<!-- wp:paragraph --> <p>I use <code><a data-type="link" data-id="https://perldoc.perl.org/perlrun">perl -ne</a></code> one-liners every day.</p> <!-- /wp:paragraph -->
As a sort of cherry on top, I note that the WP block editor is also perfectly happy to let me select and hyperlink only part of the contents of the code tag (e.g. just the
rl
) in which case there’s no question of being able to solve it by inverting the tags.Thanks in advance for considering what I suspect may be a rather thorny issue…
- The topic ‘hyperlinks inside code tags’ is closed to new replies.