Skip to content

Code block: add language support to retain language information when pasting markdown  #10200

@davidbhayes

Description

@davidbhayes

Describe the bug
When I paste markdown, I like/expect that the language specified after the start of a backtick fence will be converted into a CSS class about the language specified. So if I start the block like ```php I expect to see a <code class="language-php"> in the block. This isn't happening.

Here's a CommonMark spec/test about the behavior that matches my expectations: https://spec.commonmark.org/0.28/#example-111

To Reproduce
Steps to reproduce the behavior:

  1. Open Gutenberg editor
  2. Paste code like
```php
<?php

$random = 'what';
```
  1. See that there is not a "language-php" class applied to that code block by default.

Expected behavior
That the language-php or similar is honored and applied as a class to either the internal code block (like the CommonMark spec) or even to the outer pre block.

Desktop (please complete the following information):

  • OS: macOS
  • Browser: Firefox
  • Version 62.0.2

Additional context

  • Noticed while using Gutenberg 3.9
  • I know there are lots of "dialects" of Markdown. And I'm confident that both the CommonMark standard and "GitHub Flavored Markdown" (link about that) specify the behavior described above.

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions