{"id":7941,"date":"2026-06-06T13:50:25","date_gmt":"2026-06-06T10:50:25","guid":{"rendered":"https:\/\/mummila.net\/kommentit\/?p=7941"},"modified":"2026-06-06T14:51:20","modified_gmt":"2026-06-06T11:51:20","slug":"trailing-newline-rendered-as-a-br-tag-in-the-last-paragraph-due-to-inserted-span","status":"publish","type":"post","link":"https:\/\/mummila.net\/kommentit\/2026\/06\/06\/trailing-newline-rendered-as-a-br-tag-in-the-last-paragraph-due-to-inserted-span\/","title":{"rendered":"Trailing newline rendered as a &lt;br \/&gt; tag in the last paragraph due to inserted &lt;span&gt;"},"content":{"rendered":"<p>The trailing\u00a0<code>&lt;span class=\"__iawmlf-post-loop-links\"&gt;<\/code>\u00a0element introduced in PR\u00a0<a class=\"issue-link js-issue-link\" href=\"https:\/\/github.com\/a8cteam51\/internet-archive-wayback-machine-link-fixer\/pull\/338\" data-error-text=\"Failed to load title\" data-id=\"4399104112\" data-permission-text=\"Title is private\" data-url=\"https:\/\/github.com\/a8cteam51\/internet-archive-wayback-machine-link-fixer\/issues\/338\" data-hovercard-type=\"pull_request\" data-hovercard-url=\"\/a8cteam51\/internet-archive-wayback-machine-link-fixer\/pull\/338\/hovercard\">#338<\/a>\u00a0causes WordPress to render a trailing newline as a\u00a0<code>&lt;br \/&gt;<\/code>\u00a0tag in the last paragraph. This behavior differs from when Link Fixer is not active.<\/p>\n<p>I don&#8217;t know if the block editor is affected, since I don&#8217;t use it, but the issue is present when using the Classic Editor, and even there you have to use the Code view (because Visual view either converts the trailing newline into a line with an\u00a0<code>&amp;nbsp;<\/code>, or strips the trailing newline when switching to Code view).<\/p>\n<p>My guess is that this is\u00a0<a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/wpautop\/\" rel=\"nofollow\"><code>wpautop<\/code><\/a>\u00a0trying to be smart about the content, seeing the trailing\u00a0<code>&lt;span&gt;<\/code>\u00a0from Link Fixer, and thinking it&#8217;s visible content, so the trailing newline in the actual content (as entered in the editor) should be rendered as a visible\u00a0<code>&lt;br \/&gt;<\/code>\u00a0too.<\/p>\n<p>This is probably a very niche issue, and I&#8217;m sure I can figure out a way to work around it, but I wanted to document it anyway.<\/p>\n<h3>Steps to reproduce<\/h3>\n<ol start=\"0\">\n<li>deactivate Link Fixer<\/li>\n<li>use Classic Editor&#8217;s Code view to create a post<\/li>\n<li>end the final paragraph with a newline<\/li>\n<li><del>preview<\/del>\u00a0publish the post and inspect the last paragraph: there is no newline before the closing <code>&lt;\/p&gt;<\/code>\u00a0tag<\/li>\n<li>activate Link Fixer<\/li>\n<li>create another post with the same contents<\/li>\n<li><del>preview<\/del>\u00a0publish the post and inspect the last paragraph<\/li>\n<\/ol>\n<h3>What you expected to happen<\/h3>\n<p>the\u00a0<code>&lt;span&gt;<\/code>\u00a0to immediately follow the last word and immediately precede the closing\u00a0<code>&lt;\/p&gt;<\/code>\u00a0tag, with no newline before or after<\/p>\n<h3>What actually happened<\/h3>\n<p>the\u00a0<code>&lt;span&gt;<\/code>\u00a0is separated from the last word with a\u00a0<code>&lt;br \/&gt;<\/code>\u00a0tag followed by a plain newline<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;d expect the &lt;span&gt; to immediately follow the last word and immediately precede the closing &lt;\/p&gt; tag, with no newline before or after.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8860],"tags":[2965],"class_list":["post-7941","post","type-post","status-publish","format-standard","hentry","category-vianhallintajarjestelmat","tag-wordpress","sijainti-github"],"_links":{"self":[{"href":"https:\/\/mummila.net\/kommentit\/wp-json\/wp\/v2\/posts\/7941","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mummila.net\/kommentit\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mummila.net\/kommentit\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mummila.net\/kommentit\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mummila.net\/kommentit\/wp-json\/wp\/v2\/comments?post=7941"}],"version-history":[{"count":3,"href":"https:\/\/mummila.net\/kommentit\/wp-json\/wp\/v2\/posts\/7941\/revisions"}],"predecessor-version":[{"id":7946,"href":"https:\/\/mummila.net\/kommentit\/wp-json\/wp\/v2\/posts\/7941\/revisions\/7946"}],"wp:attachment":[{"href":"https:\/\/mummila.net\/kommentit\/wp-json\/wp\/v2\/media?parent=7941"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mummila.net\/kommentit\/wp-json\/wp\/v2\/categories?post=7941"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mummila.net\/kommentit\/wp-json\/wp\/v2\/tags?post=7941"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}