简体   繁体   English

如何在浏览器中将标签呈现为html

[英]How to render tags as html in browser

How can I render these tags as html in a browser say for eg chrome? 如何在浏览器中将这些标签呈现为html,例如chrome?

<testname=tar_tests.sh>
    <description>
        Test basic functionality of `tar` command.
    <\description>
    <test_location>
        ltp/testcases/commands/tar/tar_tests.sh
    <\test_location>
<\testname>

<testname=unzip>
    <description>
        Test basic functionality of `unzip` command.

    <\description>
    <test_location>
        ltp/testcases/commands/unzip
    <\test_location>
<\testname>

Output: 输出:

<testname=tar_tests.sh> <description> Test basic functionality of `tar` command. <\description> <test_location> ltp/testcases/commands/tar/tar_tests.sh <\test_location> <\testname> <testname=unzip> <description> Test basic functionality of `unzip` command. <\description> <test_location> ltp/testcases/commands/unzip <\test_location> <\testname>

You need to use HTML entities for the brackets. 您需要在括号中使用HTML实体。 Change < to &lt; <更改为&lt; and > to &gt; >&gt;

You need to escape the < and > characters as &lt; 您需要将<>字符转义为&lt; and &gt; &gt; respectively. 分别。

So, in your HTML, in order to show: 因此,在您的HTML中,为了显示:

<testname=tar_tests.sh>

You should write: 您应该写:

&lt;testname=tar_tests.sh&gt;

If you wrap the text in <pre> ... </pre> it will be formatted and you don't need to change all the tags into HTML entities. 如果将文本包装在<pre> ... </pre> ,它将被格式化,而无需将所有标签更改为HTML实体。 Whitespace and layout is preserved. 保留空白和布局。

<pre>
&lt;testname=tar_tests.sh>
...
</pre>

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

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