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

Preformatted code HTML entity tag are changing real #42

Closed
thegulshankumar opened this issue May 18, 2020 · 5 comments
Closed

Preformatted code HTML entity tag are changing real #42

thegulshankumar opened this issue May 18, 2020 · 5 comments

Comments

@thegulshankumar
Copy link

thegulshankumar commented May 18, 2020

Sharing any code snippet would be possible once this is fixed.

How to repro?
Write a new post with below code
<meta name="robots" content="noindex">
Export static site as ZIP, you will see like this in source code.
image

This can lead to noindex web page. Once I faced this issue.

@leonstafford
Copy link
Contributor

@thegulshankumar thanks for reporting this. It took me a while to figure out why this might be an issue.

The answers/comments here give a good explanation of why we don't want to use any HTML tags as is within a <code> element: https://stackoverflow.com/q/11386586/1668057

So, a few options, none of them likely to be perfect for your workflow.

I'd suggest this: when you add a code snippet in a web application using markdown, there's usually an option to specify the code language, so that the syntax can be properly highlighted.

I haven't looked, but would assume that a widely-used code snippet inserter for WordPress would also offer specifying what language of code is in the snippet. If it's HTML/XML, then we'd hope they would encode HTML entities for us, ie

your

<meta name="robots" content="noindex">

would become

&#x3C;meta name=&#x22;robots&#x22; content=&#x22;noindex&#x22;&#x3E;

OK, I just tseted the Code Syntax Block, which does work as expected. Using this to render your HTML code snippets will properly escape them, make them prettier and optionally show line numbers:

syntaxplugin

So, I would suggest this is more an issue/limitation of WP's built-in options for displaying code. Their default Gutenberg block should have similar options to that plugin above, IMO. Perhaps they've already had a discussion on it and chosen not to or someone just needs to raise it to them (hint hint ;)

@leonstafford
Copy link
Contributor

Closing this here. Will still be searchable for anyone else, but not an issue needing to be fixed within the plugin(s)

@thegulshankumar
Copy link
Author

WordPress already uses HTML entity tags but after export it turns real.

Please refer to line 192 to see difference
https://www.diffchecker.com/jpiLMsd6

@leonstafford
Copy link
Contributor

leonstafford commented May 21, 2020

cross-referencing our discussion of the issue being valid here: #47

@leonstafford leonstafford reopened this May 21, 2020
@leonstafford
Copy link
Contributor

should be fixed now, covered by tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants