shortcode - Wordpress keeps automatically inserts <br>

admin2025-06-06  28

I'm using the 'SyntaxHighlighter Evolved' plugin on Wordpress and when I create a code block, it keeps inserting a <br/>. If I put everything on one line, of course, it would not insert them. I want to be able to have a code block with multiple lines without the <br/>.

Here is what I'm typing:

Here is what the preview displays:

How do I remove the <br /> while keeping the new lines?

I'm using the 'SyntaxHighlighter Evolved' plugin on Wordpress and when I create a code block, it keeps inserting a <br/>. If I put everything on one line, of course, it would not insert them. I want to be able to have a code block with multiple lines without the <br/>.

Here is what I'm typing:

Here is what the preview displays:

How do I remove the <br /> while keeping the new lines?

Share Improve this question asked Nov 23, 2018 at 3:43 Rob Avery IVRob Avery IV 1011 bronze badge 3
  • If you mean the Shortcode block in Gutenberg, then it's perfectly normal for the <br /> to be automatically added because the block's render callback applies wpautop() on the shortcode (or block content). It's easy to override the block, but why not use the Code block for multi-line shortcodes? – Sally CJ Commented Nov 23, 2018 at 7:46
  • What do you mean by "Code block for multi-line shortcodes"? How do I do that? (Sorry...I'm new to wordpress) – Rob Avery IV Commented Nov 23, 2018 at 13:30
  • 1 Click on the + ("Add Block") button and choose the "Code" block, then just put your shortcode into the block content. (And you can use the short version of the shortcode - [python]code here[/python]) – Sally CJ Commented Nov 23, 2018 at 15:42
Add a comment  | 

1 Answer 1

Reset to default 0

Try putting the 2nd line (the first code line) just after the shortcode, as in

[sourcecode language = python]a+b=c
f = 1 + 3
c = 12 + 13

(not actually code, but you see what I did.) You put a blank line after the shortcode, which was interpreted as a

Just guessing here; you might want to ask the plugin support forum.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749157845a316856.html

最新回复(0)