WordPress.org

Making WordPress.org

Opened 2 years ago

Last modified 16 months ago

#2931 accepted defect

Plugin Directory: Incorrect parsing of code blocks

Reported by: SergeyBiryukov Owned by: dd32
Milestone: Priority: normal
Component: Plugin Directory Keywords: needs-patch
Cc:

Description

The description for Theme Check plugin appears to be parsed incorrectly (see the screenshot).

The first code sample lacks the code formatting. In the readme.txt both samples are formatted the same way:

Examples:
`define( 'TC_PRE', 'Theme Review:[[br]]
- Themes should be reviewed using "define(\'WP_DEBUG\', true);" in wp-config.php[[br]]
- Themes should be reviewed using the test data from the Theme Checklists (TC)
-----
' );`

`define( 'TC_POST', 'Feel free to make use of the contact details below if you have any questions,
comments, or feedback:[[br]]
[[br]]
* Leave a comment on this ticket[[br]]
* Send an email to the Theme Review email list[[br]]
* Use the #wordpress-themes IRC channel on Freenode.' );`

Attachments (4)

2931.PNG (51.7 KB) - added by SergeyBiryukov 2 years ago.
First Example.png (23.9 KB) - added by arunbasillal 2 years ago.
Second Example.png (25.0 KB) - added by arunbasillal 2 years ago.
2931.diff (4.1 KB) - added by dd32 16 months ago.
WIP - testing patch only

Download all attachments as: .zip

Change History (10)

@SergeyBiryukov
2 years ago

#1 @arunbasillal
2 years ago

Came across this. The first block is parsed incorrectly while the second variant with the CSS in reverse order just works. Weird.

This is parsed incorrectly:

`body, h1, p {
    color: #f1f1f1 !important;
}
#wpwrap {
    background-color: #5f5f5f !important;
}`


This works:

`#wpwrap {
    background-color: #5f5f5f !important;
}
body, h1, p {
    color: #f1f1f1 !important;
}`


#2 @tellyworth
2 years ago

  • Keywords 2nd-opinion needs-patch added

#3 @obenland
17 months ago

@dd32 Is this an issue with our Markdown parser?

#4 @dd32
17 months ago

@obenland This is most definitely an issue with the markdown parser, and as a result I don't expect this is easily fixable without side effects (unless the library we're using has been updated)

#5 @dd32
17 months ago

  • Keywords 2nd-opinion removed
  • Owner set to dd32
  • Status changed from new to accepted

Okay so after a lot of debugging, it looks like this is a combination of bugs both in our readme parser, but also in the markdown parser.

The markdown parser isn't correctly handling this example:

    #wpwrap {
        testing;
    }

It seems that any code block (A line starting with 4 spaces, which we convert `...` to) starting with # is being interpreted as a markdown header instead of a code block start.

I've tested version 1.8 of the library (We're using 1.6) and it doesn't seem to fix it, but it doesn't make it worse.
It looks like we can work around it on our end by not relying upon the libraries code block functionality, and instead rolling out own for `...`.

Got a fair bit more testing to do though.

@dd32
16 months ago

WIP - testing patch only

#6 @dd32
16 months ago

2931.diff is where I got up to a few days back, uploading here as a WIP patch for backup purposes..

  • Not splitting content into headers when within code blocks (Not entirely sure if this is still working correctly, as it hasn't been fully tested after the following changes)
  • Upgrading the Markdown parser from v 1.6 to 1.8
  • Converting ```....``` code blocks to <pre><code>...</pre></code> instead of indented blocks to workaround the previously mentioned markdown parser bug mentioned in Comment #5

These changes can be seen on https://wordpress.org/plugins/test-plugin-3/ which has FAQ entries which were previously parsing improperly and the code block from the original report.

Note: See TracTickets for help on using tickets.