wporg-developer
wporg-developer copied to clipboard
Missing indentation on code block
Initially reported in slack #meta channel.
Description
On the current developer documentation, some code blocks are missing indentation when displaying multiple lines (see attached screenshot). Examples where this issue can be seen : WP_Query reference or register_post_type
Screenshot
Unfortunately the examples given above aren't in the content on the staging site, eg. the https://developer.wordpress.org/redesign-test/reference/functions/register_post_type/#flushing-rewrite-on-activation section doesn't exist.
@StevenDufresne do you know if/how we can get the staging content to be on par with prod please?
Running the cron jobs passing the--url=developer.wordpress.org/redesign-test
should work.
https://github.com/WordPress/wporg-developer/blob/1892b5001515d4521e34ca1de5161396d86f8dc0/env/setup.sh#L16
Docs: https://developer.wordpress.org/cli/commands/cron/event/run/
Looks like we fixed something in the parsers because https://developer.wordpress.org/redesign-test/reference/functions/register_post_type/#flushing-rewrite-on-activation is there now, and indentation does still look broken
Looks like we fixed something in the
How it was fixed was mentioned in this PR description Note I Section, if anyone is interested in it, please take a look.
Summary of the issue:
Root cause: This seems to be a longstanding issue. It arises from the lack of indentation when inputting in the editor. To fix it, we would need to add indentation to the PHP snippets in the editor's text view. Additionally, there's no need to add extra pre tags; if we do, we'll need to include additional classes and place it inside the [php] shortcode. Otherwise, the sticky header will break.
As shown in this link, geisthanen manually converted the original code, which lacked indentation, into content with Prism-style classes wrapped in <pre>
tags. However, it's unclear how this conversion was done; I suspect they might have run a script they wrote themselves. Perhaps someone among you knows about this part.
Regardless, to modify the indentation issue, it means filtering the user's content input in the editor. I've tried formatting $content
(via this function), but the possibilities are too numerous and it seems there are no existing tools or functions for formatting, it doesn't make sense to start from scratch. So, before I spend more time on this, I'd like to see if anyone has any thoughts off the top of your head on previous discussions or methods to handle this formatting issue. @adamwoodnz @StevenDufresne
Currently, I've manually fixed the indentation on the WP_Query and register_post_type pages, one of which had dozens of snippets... Other pages might also have this issue, and manually fixing them doesn't make good sense. Additionally, I've also fixed some issues with the sticky header breaking due to incorrectly added <pre>
tags.
register_post_type
WP_Query