简体   繁体   English

内联预格式化?

[英]Inline pre formatting?

This should be easy points as I forgot how and can't find it on Google. 这应该是简单的点,因为我忘记了如何在Google上找不到它。

How do I accomplish something like this: 我如何完成这样的事情:

Blah Blah Blah some code Blah Blah Blah Blah Blah some code Blah Blah

in wordpress? 在wordpress? pre doesn't work as it will give a line break. pre不起作用,因为它会给出一个换行符。

It may be better to use <code> than <pre> to display inline code, for two reasons: 使用<code>不是<pre>来显示内联代码可能更好,原因有两个:

  • it's treated as inline 它被视为内联
  • the semantics of <code> are a much better match than <pre> <code>的语义比<pre>更好

But definitely use CSS classes (as @Blender points out). 但绝对使用CSS类(如@Blender指出)。

There's a caveat: <code> doesn't escape <> brackets, so if you want to display HTML then you have to manually escape brackets as &lt; 有一点需要注意: <code>没有转义<>括号,因此如果要显示HTML,则必须手动转义括号为&lt; and &gt; &gt; . (which you should really do anyway; tags in HTML really should be clearly distinguished from data) (无论如何你应该真正做到这一点; HTML中的标签确实应该与数据明确区分)

<tt>text</tt> gives text <tt> text </ tt>给出了text

Wait... Wordpress? 等等...... Wordpress? What HTML tags does it support? 它支持哪些HTML标记?

You can have an inline <pre> by adding some custom CSS to your theme's stylesheet: 您可以通过向主题的样式表添加一些自定义CSS来获得内联<pre>

pre.inline {
   display: inline;
}

Now, when you write: 现在,当你写:

I am some <pre class="inline">code, see?</pre> Foo.

It shows up like this: 它显示如下:

I am some code, see? 我是一些code, see? Foo. 富。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM