urvanov-ru / crayon-syntax-highlighter

Syntax Highlighter supporting multiple languages, themes, fonts, highlighting from a URL, local file or post text.
https://wordpress.org/plugins/urvanov-syntax-highlighter/
GNU General Public License v3.0
60 stars 11 forks source link

how to keep wp:preformatted default? #38

Open wkingnet opened 2 years ago

wkingnet commented 2 years ago

I noticed that Crayon changed the pre-formatted styles in wordpress.

Viewed using a code editor, the wp:preformatted block format is

<!-- wp:preformatted -->
<pre class="wp-block-preformatted">204.79.197.213 api.onedrive.com
23.76.75.24 api.onedrive.live.com
131.253.33.217 onedrive.live.com
131.253.33.217 webedgegeo.skyprod.akadns.net
131.253.14.230 skyapi.onedrive.live.com
134.170.104.157 skyweb.skyprod.akadns.net</pre>
<!-- /wp:preformatted -->

and Crayon code block format is

<!-- wp:urvanov-syntax-highlighter/code-block -->
<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="lang:python decode:true ">
bs = BeautifulSoup(file_obj, 'lxml')
start = time.time()
for i in range(1000):
    bs.find_all(['a', 'img', 'link', 'script'])
print(f"time:{time.time() - start}")
# time:137.75350737571716</pre></div>
<!-- /wp:urvanov-syntax-highlighter/code-block -->

I think the problem is that both have the pre tag, but how to keep wp:preformatted default?

urvanov-ru commented 2 years ago

Yes, we have this problem now. You are right. It is because we use the same pre tag as it was in Crayon even before Gutenberg. I don't know how to fix it right now. I should somehow difference between pre for preformatted and pre form crayon in Gutenberg and use old logic for Classic Editor. As workaround you can try to use <pre class="crayon:false" for preformatted blocks

urvanov-ru commented 2 years ago

But I will fix this problem later. I suffer from it too.