admin管理员组文章数量:1431426
I'm writing a guide and putting code examples. If I use the visual editor the code indentation is lost. It will also take some code and strip it out. If I use the text editor I can't ever switch to the visual editor again or the formatting and markup is lost.
This doesn't happen in other editors like Discourse.
I'm using Geishi syntax highligher.
Is there anyway to prevent this?
I'm writing a guide and putting code examples. If I use the visual editor the code indentation is lost. It will also take some code and strip it out. If I use the text editor I can't ever switch to the visual editor again or the formatting and markup is lost.
This doesn't happen in other editors like Discourse.
I'm using Geishi syntax highligher.
Is there anyway to prevent this?
Share Improve this question edited May 25, 2019 at 12:21 fuxia♦ 107k39 gold badges255 silver badges459 bronze badges asked May 25, 2019 at 2:55 1.21 gigawatts1.21 gigawatts 1,0003 gold badges13 silver badges34 bronze badges 4- Is using Gutenberg an option for you? If yes you could use the Preformatted block to easily solve your problem. gogutenberg/blocks/preformatted – filipecsweb Commented May 25, 2019 at 3:00
- I don't know if I can switch to the gutenberg editor. – 1.21 gigawatts Commented May 25, 2019 at 3:16
- You said some code is being stripped... are you editing/saving the post as an administrator? And can you post your post content here? – filipecsweb Commented May 25, 2019 at 3:27
- The code is not meant to be interpreted or parsed. It's meant to be example code to be included visibly in the post. – 1.21 gigawatts Commented May 25, 2019 at 3:48
1 Answer
Reset to default 0If you look at the editing box, you'll see the curly braces as a choice. Highlight your code block, then use that curly braces icon. That will wrap the code in a 'code' block, so it will look like this:
<?php
// this is a code block
echo "this is a code block";
You can do the same in text mode (rather than visual) by using the HTML 'code' tag.
本文标签: visual editorHow do I prevent Wordpress from eating my code
版权声明:本文标题:visual editor - How do I prevent Wordpress from eating my code? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745465402a2659511.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论