Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing indentation on code block #300

Open
petitphp opened this issue Oct 6, 2023 · 6 comments
Open

Missing indentation on code block #300

petitphp opened this issue Oct 6, 2023 · 6 comments
Assignees
Labels

Comments

@petitphp
Copy link

petitphp commented Oct 6, 2023

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

missing_spacing

@adamwoodnz adamwoodnz added this to the MVP milestone Oct 8, 2023
@adamwoodnz adamwoodnz added [Type] Bug Something isn't working ui Redesign labels Oct 8, 2023
@adamwoodnz adamwoodnz self-assigned this Oct 26, 2023
@adamwoodnz
Copy link
Contributor

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?

@StevenDufresne
Copy link
Contributor

Running the cron jobs passing the--url=developer.wordpress.org/redesign-test should work.

@adamwoodnz
Copy link
Contributor

@adamwoodnz
Copy link
Contributor

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

Image

@renintw
Copy link
Contributor

renintw commented Nov 20, 2023

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.

@renintw
Copy link
Contributor

renintw commented Nov 20, 2023

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
image

WP_Query
image

@adamwoodnz adamwoodnz removed this from the MVP milestone Nov 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4 participants