EnlighterJS / Plugin.WordPress

:package: Official WordPress Plugin of EnlighterJS
http://wordpress.org/plugins/enlighter/
GNU General Public License v2.0
115 stars 17 forks source link

The language specifier is not handled collectedly with the fenced code block #270

Closed suikan4github closed 4 years ago

suikan4github commented 4 years ago

Description of problem

The language specifier of the fenced code block of the markdown is not handled correctly, when the markdown is pasted to the Gutenberg. The Enlighter block is always set as Generic Highlighting.

If I change the language of the Enlighter block manually, there is not a problem. Only the language specifier after the 3 backticks are ignored.

How to reproduce

Paste following code block to the Gutenberg editor. The result is always "Generic Highlighting" rather than PHP.

```php
// generate code fragment
$T->_codeFragments[] = array(
    // the language identifier
    'lang' => $lang,

    // code to highlight
    'code' => $match[1],

    // inline
    'inline' => true
);

Note that this code is copied from the example of the [WordPress Enlighter Markdown Tutorial](https://github.com/EnlighterJS/documentation/blob/master/editing/Markdown.md) page.

Please see the screenshot of the above operation here. This screenshot also demonstrates the manual language setting works OK : 

![Peek 2020-05-24 13-47](https://user-images.githubusercontent.com/26223147/82745966-49c53300-9dc5-11ea-88e2-0f195ba2dec8.gif)

# Additional information
The followings are the settings of my Enlightener.
![image](https://user-images.githubusercontent.com/26223147/82745910-affd8600-9dc4-11ea-8a24-6a8875b77d66.png)
AndiDittrich commented 4 years ago

Hi @suikan4github

sry but you're using the editing modes in the absolute wrong way...

  1. in your example above, the automatic block conversion mode of Gutenberg transforms your markdown code into an Enlighter codeblock - that's an internal utility of the Enlighter.Gutenberg plugin to convert legacy codeblocks to Gutenberg blocks - but it has never been intended to be used this way - this has nothing to do with the GFM settings of Enlighter

  2. if you want to use Gutenberg, please use the Enlighter Sourcecode block - it is impossible to use markdown in Gutenberg without a dedicated block because of the auto formatting functions (same for TinyMCE/Classic Editor)

suikan4github commented 4 years ago

Hi @AndiDittrich

Thank you very much for your explanation. I understand the usage.

Regards,