Skip to content

Unexpected line number positioning in WordPress 5.6 #246

@westonruter

Description

@westonruter

As reported in a support topic:

This issue is now happening with XML Unexpected line number appearing on same line #193

I had a page with XML in a code block. I updated to 1.3. Then looked at this page. It now has the “unexpected line number” problem in the code block with XML in it. It didn’t have this problem in the previous version (1.2.3). To doublecheck, I reinstalled the previous version and verified that the problem wasn’t there.

I have this XML on the page:

<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
      autoReload="true">
</nlog>

Due to #245, you have to manually type in the XML. Here is the simplest way to repro this:

  1. Create a new page
  2. Add a code block
  3. Manually type in this XML:
<?xml version="1.0" encoding="utf-8" ?>
               <tag a="t"
                        b="t">
                 </tag>
  1. Use the following settings:
  • Language = HTML, XML
  • Show Line Numbers = true
  • Wrap Lines = true

Here's some sample post_content:

<!-- wp:code {"language":"xml","showLineNumbers":true,"wrapLines":true} -->
<pre class="wp-block-code"><code>&lt;?xml version="1.0" encoding="utf-8" ?>
               &lt;tag a="t"
                        b="t">
                 &lt;/tag></code></pre>
<!-- /wp:code -->

<!-- wp:code {"showLineNumbers":true,"wrapLines":true} -->
<pre class="wp-block-code"><code>&lt;?xml version="1.0" encoding="utf-8" ?>
&lt;nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
      autoReload="true">
&lt;/nlog></code></pre>
<!-- /wp:code -->

I can reproduce the issue:

image

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions