KevinBatdorf / code-block-pro

A Gutenberg code block with syntax highlighting powered by VS Code
https://code-block-pro.com
132 stars 10 forks source link

Dynamic Rendering with render_block #335

Open dcooney opened 3 months ago

dcooney commented 3 months ago

I'm curious if there is a way to render a code block dynamically with render_block()?

I have an ACF textarea field with a code snippet and I want to render this snippet with Code Block Pro in a lightbox.

<ul>
    <li>List Item #1</li>
    <li>List Item #2</li>
    <li>List Item #3</li>
</ul>

I've been inspecting how the plugin transforms the code into encoded string and span elements within the Code Editor and not sure if this is possible.

KevinBatdorf commented 3 months ago

Unfortunately it's not because it runs in the browsers webassembly runtime. I also don't know enough about ACF to know if it could hack something in the browser for it either.

dcooney commented 3 months ago

All good. I didn't think it was possible. ACF was just an example, basically, I was hoping to be able to use Code Block Pro for content outside of the Block Editor which you can do with render_block.