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

Markdown block: support HTML in block #11854

Open
jeherve opened this issue Jan 16, 2019 · 11 comments
Open

Markdown block: support HTML in block #11854

jeherve opened this issue Jan 16, 2019 · 11 comments
Labels
Customer Report Issues or PRs that were reported via Happiness. aka "Happiness Request", or "User Report" [Feature] Markdown [Focus] Blocks Issues related to the block editor, aka Gutenberg, and its extensions developed in Jetpack [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it

Comments

@jeherve
Copy link
Member

jeherve commented Jan 16, 2019

This was originally reported in #11147

Ideally, the block would support inserting content in HTML as well as Markdown, as sometimes folks prefer to use HTML directly, for things that may be difficult or impossible to do with Markdown. In the example below, all links should be converted into links.

[a link](https://wordpress.com). And <a href="https://wordpress.com">a link</a>.

<a href="https://wordpress.com">a link</a>
@derek-shnosh
Copy link

Just throwing my support in for this feature; I am currently maintaining two blogs with the same content to determine a preferred platform and this is a major pain-point for me. I strongly prefer writing in MD but have two very common use cases for embedding HTML in the MD block;

  1. I am wrapping code blocks in <pre><code> instead of fences ``` for PrismJS syntax highlighting plugin support; e.g. line-highlighting, command-line.
  2. I use HTML5 <details> regularly to collapse long code blocks or quasi-relevant snippets.

I maintain my content as static .md files on a private Git server, which provides a few favorable benefits; e.g. backups, offline editing, simplicity of dev environment for theme editing against my content, etc.

@scruffian scruffian transferred this issue from Automattic/wp-calypso Apr 3, 2019
@scruffian scruffian added [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Focus] Blocks Issues related to the block editor, aka Gutenberg, and its extensions developed in Jetpack [Feature] Markdown labels Apr 3, 2019
@RCowles
Copy link
Contributor

RCowles commented May 9, 2019

Just noting that this was also reported/requested in 2019865-zen

@matticbot matticbot added the Customer Report Issues or PRs that were reported via Happiness. aka "Happiness Request", or "User Report" label May 9, 2019
@phillipjohnston
Copy link

Since the markdown block doesn't auto-generate header IDs (#3562) and the underlying library's extras field isn't available, HTML is needed to add anchor links for an internal table of contents.

@spncr
Copy link

spncr commented Jan 28, 2020

I spoke to a WordPress.com user and developer who is disappointed that we say we support the markdown-it parser but we don't support inline HTML.

Their thoughts:

So Jetpack Markdown is using the markdown-it parser. This parser has the ability to use inline HTML, however, the markdown-it parser feature is not enabled in Jetpack. Clearly markdown-it supports the feature.
How can Wordpress request Jetpack to enable this markdown-it parser feature as described on the Jetpack Markdown Doc Page?
Wordpress.com Developers are suffering because a documented feature does not work!

I hope y'all will consider making an update to support inline HTML within the Jetpack Markdown block.

@aletheia7
Copy link

Please enable inline HTML in Jetpack by changing html: false to html: true. See

@GioLogist
Copy link

@aletheia7 Did you confirm that this is the only change needed? Just tried making the changed locally (I edited the compiled editor.js, not the source file) with no luck.

Do you have instructions for the workaround?

@aletheia7
Copy link

No.

The above change is located in index.js, not editor.js.

Perhaps your change did not end-up in the browser? Perhaps wordpress is serving an unchanged cached copy? Verify in the browser that html: true and that you have html in the markdown.

@GioLogist
Copy link

@aletheia7 Ok so I made the edit you suggested and rebuilt, following the development environment instructions. Now, the only difference I see is an added "Edit as HTML" button

image

Upon clicking, it shows the HTML output of my markdown

image

So, I attempt to add some more HTML while in this view

image

Now, I get an error saying "This block contains unexpected or invalid content"

image

If I press "resolve" or "convert", it converts the block to a full html block (no more markdown).

image


So the above not working, I tried just entering HTML in the markdown block to see if that's supported now.

image

I get the same as before (escaped html)

image


So all-in-all, following those instructions only allows me to convert my block to HTML. Not embed HTML in my markdown block.

@GioLogist
Copy link

Following up on this, to see if any of the top contributors have any thoughts?

cc @jeherve @georgestephanis @dereksmart

@JohnRDOrazio
Copy link

Just a thought: could this perhaps depend on the wp_kses() filter? Maybe HTML elements need to be enabled when going through the filter, using wp_kses_allowed_html() ? Idk just a thought

public function wp_kses_allowed_html( $tags, $context ) {

@0xLun
Copy link

0xLun commented Jun 10, 2022

Any update about this issue ? I need to add html tag in my markdown but it's impossible. The workaround quoted above doesn't seem to work anymore since jetpack/extensions/blocks/markdown/index.js doesn't exist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Customer Report Issues or PRs that were reported via Happiness. aka "Happiness Request", or "User Report" [Feature] Markdown [Focus] Blocks Issues related to the block editor, aka Gutenberg, and its extensions developed in Jetpack [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it
Projects
None yet
Development

No branches or pull requests