如何在/ tag中逐字显示标签?[英]How to show tag literally in / tag? 本文翻译自  Loolooii  查看原文  2012-07-08  37298    blogger/

时间:2022-05-08 15:23:58

I'm using <code> tag inside of a <pre> tag to show code on my blogger blog. Unfortunately it doesn't work with HTML tags. Is there any way to show "<div>" inside of <pre> or <code> tag without actually interpreting it as HTML? This is what I do right now:

我使用标签内的

标签来显示我博客上的代码。不幸的是,它不能使用HTML标签。有没有办法在
 tag中显示"
    
    
    
"而不将其解释为HTML?这就是我现在所做的:

<pre>
 <code>
 .class {        
   color:red;
 }
 // I would like HTML code inside this
 </code>
</pre>

Which works ok for everything except HTML. Any idea how to achieve this? Thanks.

除了HTML,其他都可以。你知道怎么做吗?谢谢。

7 个解决方案

#1


60  

Unfortunately it doesn't work with HTML tags.

不幸的是,它不能使用HTML标记。

<code> means "This is code", <pre> means "White space in this markup is significant". Neither means "The content of this element should not be treated as HTML", so both work perfectly, even if they don't mean what you want them to mean.

表示“这是代码”,

表示“这个标记中的空格是重要的”。两者都不意味着“不应该将该元素的内容视为HTML”,因此两者都可以很好地工作,即使它们并不意味着您想要它们的意思。

Is there any way to show "<div>" inside of <pre> or <code> tag without actually interpreting it as HTML?

有没有办法在

 tag中显示"
   
   
"而不将其解释为HTML?

If you want to render a < character then use &lt;, with &gt; for > and &amp; for &.

如果你想渲染一个 <字符,然后使用<> ,,&。

You can't (in modern HTML) write markup and have it be interpreted as text.

您不能(在现代HTML中)编写标记并将其解释为文本。

#2


31  

It seems like a readonly textarea does pretty much what you want.

看起来readonly textarea几乎可以满足您的需求。

<textarea readonly> <!-- html code --> </textarea>

#3


12  

You can use the "xmp" element. The <xmp></xmp> has been in HTML since the beginning and is supported by all browsers. Even it should not be used, it is broadly supported.

您可以使用“xmp”元素。

从一开始就是HTML格式的,所有浏览器都支持。即使它不应该被使用,它也得到了广泛的支持。

Everything inside <xmp></xmp> is taken as it is (no markup lke tags or character references is recognized there) except, for apparent reason, the end tag of the element itself.

中的所有内容都保持原样(那里没有标记lke标记或字符引用被识别),除了明显的原因,元素本身的结束标记。

Otherwise "xmp" is rendered like "pre".

否则,“xmp”将呈现为“pre”。

#4


7  

Try:

试一试:

<xmp></xmp>

for exemple:

为例:

<pre>
     <xmp><!-- your html code --></xmp>
</pre>

bye

再见

#5


2  

Just escape the HTML tags. For example -

只是转义HTML标签。例如,

Replace < with &lt;

替换< & lt;

Replace > with &gt;

>替换为在

Complete lookup here

完成在这里查找

#6


0  

Try CodeMirror (https://codemirror.net/)

尝试CodeMirror(https://codemirror.net/)

It's a lightweight library that styles code in HTML. Here's a screenshot of what I'm referring to:

它是一个用HTML样式化代码的轻量级库。这是我所指的截屏:

如何在/ tag中逐字显示标签?[英]How to show  tag literally in / tag?
			      
			      
			      
			      
			      
			      
			         本文翻译自
			      
			      
			       Loolooii
			       查看原文
			      
			       2012-07-08
			       37298 
                  
                      
                     
                     
                     
                     blogger/
                                          
                     
                     
                     html                     
                     
                  
			        
			          
				        
				      
			      
			      
			          
						
						     (adsbygoogle = window.adsbygoogle || []).push({});
 						
                 
                        
                        
                            I'm using <code> tag inside of a <pre> tag to show code on my blogger blog. Unfortunately it doesn't work with HTML tags. Is there any way to show "<div>" inside of <pre> or <code> tag without actually interpreting it as HTML? This is what I do right now: 
我使用标签内的 
标签来显示我博客上的代码。不幸的是,它不能使用HTML标签。有没有办法在或 tag中显示"
    
    
    
      "而不将其解释为HTML?这就是我现在所做的: 
      
     
<pre>
 <code>
 .class {        
   color:red;
 }
 // I would like HTML code inside this
 </code>
</pre>
 
Which works ok for everything except HTML. Any idea how to achieve this? Thanks. 
除了HTML,其他都可以。你知道怎么做吗?谢谢。

     (adsbygoogle = window.adsbygoogle || []).push({});7 个解决方案
                           
                           
							  
							    #1
							    
							      60  
 
 Unfortunately it doesn't work with HTML tags. 
 不幸的是,它不能使用HTML标记。 
 
<code> means "This is code", <pre> means "White space in this markup is significant". Neither means "The content of this element should not be treated as HTML", so both work perfectly, even if they don't mean what you want them to mean. 
表示“这是代码”, 
表示“这个标记中的空格是重要的”。两者都不意味着“不应该将该元素的内容视为HTML”,因此两者都可以很好地工作,即使它们并不意味着您想要它们的意思。 
 
 Is there any way to show "<div>" inside of <pre> or <code> tag without actually interpreting it as HTML?  
 有没有办法在 
 或 tag中显示"
   
   
     "而不将其解释为HTML? 
     
    
 
If you want to render a < character then use &lt;, with &gt; for > and &amp; for &. 
如果你想渲染一个 <字符,然后使用<> ,,&。 
  
You can't (in modern HTML) write markup and have it be interpreted as text. 
您不能(在现代HTML中)编写标记并将其解释为文本。
							     
							                          
                           
							  
							    #2
							    
							      
31  
It seems like a readonly textarea does pretty much what you want. 
看起来readonly textarea几乎可以满足您的需求。 
<textarea readonly>  </textarea>

							     
							                          
                           
							  
							    #3
							    
							      
12  
You can use the "xmp" element. The <xmp></xmp> has been in HTML since the beginning and is supported by all browsers. Even it should not be used, it is broadly supported. 
您可以使用“xmp”元素。 
从一开始就是HTML格式的,所有浏览器都支持。即使它不应该被使用,它也得到了广泛的支持。 
 
Everything inside <xmp></xmp> is taken as it is (no markup lke tags or character references is recognized there) except, for apparent reason, the end tag of the element itself. 
 
中的所有内容都保持原样(那里没有标记lke标记或字符引用被识别),除了明显的原因,元素本身的结束标记。 
 
Otherwise "xmp" is rendered like "pre". 
否则,“xmp”将呈现为“pre”。
							     
							                          
                           
							  
							    #4
							    
							      
7  
Try: 
试一试: 
<xmp></xmp>
 
for exemple: 
为例: 
<pre>
     <xmp></xmp>
</pre>
 
bye 
再见
							     
							                          
                           
							  
							    #5
							    
							      
2  
Just escape the HTML tags. For example -  
只是转义HTML标签。例如, 
Replace < with &lt; 
替换< & lt; 
Replace > with &gt; 
>替换为在 
Complete lookup here 
完成在这里查找
							     
							                          
                           
							  
							    #6
							    
							      
0  
Try CodeMirror (https://codemirror.net/) 
尝试CodeMirror(https://codemirror.net/) 
It's a lightweight library that styles code in HTML. Here's a screenshot of what I'm referring to: 
它是一个用HTML样式化代码的轻量级库。这是我所指的截屏: 
 
Worked well for us! 
工作对我们好!
							     
							                          
                           
							  
							    #7
							    
							      
-3  
Yes, with an escape xml function. You'll need to have jQuery enabled for it to work though. 
是的,带有转义xml函数。但是,您需要启用jQuery才能工作。 
<pre>
  ${fn:escapeXml('
    
  ')};
</pre>

							     
							                          
                           
                        
                 
               
				
				     (adsbygoogle = window.adsbygoogle || []).push({});
				
			     
			     		     
			     
			         
		              ×
		              注意!
		              
		              本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2012/07/08/f5aa9102d888e966ad3174f8d2458948.html。
		              
		              
		            	
		            
			
		    
		          
		          
			          
				          
					      timeout_show();
					      			
			
			
			  
			   
			   
			   
			       
			           Wrapping a DIv in a Pre tag
			       
			       			       
			   
			       
			           How do I add a pre tag inside a code tag with jQuery?
			       
			       			       
			   
			       
			           how to load iframe only with div tag show
			       
			       			       
			   
			       
			           How to show error in Div tag in angularjs?
			       
			       			       
			   
			       
			           CSS code highlighter - margin in pre code tag
			       
			       			       
			   
			       
			           How to clear pre tag in html
			       
			       			       
			   
			       
			           Retrieve Code or PRE tag content on server side
			       
			       			       
			   
			       
			           How to show all nested DIVs inside a main DIV with title tag?
			       
			       			       
			   
			       
			           How can I expand an  tag into a  Tag?
			       
			       			       
			   
			       
			           how to convert this from table tag to div tag
			       
			       			       
			   
			   

			   
				
				
				
				  .itdaan_shufu { width:300px;height:600px }
				  @media (max-width: 600px) { .itdaan_shufu { display: none; } }
				
				
				     (adsbygoogle = window.adsbygoogle || []).push({});

Worked well for us!

工作对我们好!

#7


-3  

Yes, with an escape xml function. You'll need to have jQuery enabled for it to work though.

是的,带有转义xml函数。但是,您需要启用jQuery才能工作。

<pre>
  ${fn:escapeXml('
    <!-- all your code -->
  ')};
</pre>

#1


60  

Unfortunately it doesn't work with HTML tags.

不幸的是,它不能使用HTML标记。

<code> means "This is code", <pre> means "White space in this markup is significant". Neither means "The content of this element should not be treated as HTML", so both work perfectly, even if they don't mean what you want them to mean.

表示“这是代码”,

表示“这个标记中的空格是重要的”。两者都不意味着“不应该将该元素的内容视为HTML”,因此两者都可以很好地工作,即使它们并不意味着您想要它们的意思。

Is there any way to show "<div>" inside of <pre> or <code> tag without actually interpreting it as HTML?

有没有办法在

 tag中显示"
   
   
"而不将其解释为HTML?

If you want to render a < character then use &lt;, with &gt; for > and &amp; for &.

如果你想渲染一个 <字符,然后使用<> ,,&。

You can't (in modern HTML) write markup and have it be interpreted as text.

您不能(在现代HTML中)编写标记并将其解释为文本。

#2


31  

It seems like a readonly textarea does pretty much what you want.

看起来readonly textarea几乎可以满足您的需求。

<textarea readonly> <!-- html code --> </textarea>

#3


12  

You can use the "xmp" element. The <xmp></xmp> has been in HTML since the beginning and is supported by all browsers. Even it should not be used, it is broadly supported.

您可以使用“xmp”元素。

从一开始就是HTML格式的,所有浏览器都支持。即使它不应该被使用,它也得到了广泛的支持。

Everything inside <xmp></xmp> is taken as it is (no markup lke tags or character references is recognized there) except, for apparent reason, the end tag of the element itself.

中的所有内容都保持原样(那里没有标记lke标记或字符引用被识别),除了明显的原因,元素本身的结束标记。

Otherwise "xmp" is rendered like "pre".

否则,“xmp”将呈现为“pre”。

#4


7  

Try:

试一试:

<xmp></xmp>

for exemple:

为例:

<pre>
     <xmp><!-- your html code --></xmp>
</pre>

bye

再见

#5


2  

Just escape the HTML tags. For example -

只是转义HTML标签。例如,

Replace < with &lt;

替换< & lt;

Replace > with &gt;

>替换为在

Complete lookup here

完成在这里查找

#6


0  

Try CodeMirror (https://codemirror.net/)

尝试CodeMirror(https://codemirror.net/)

It's a lightweight library that styles code in HTML. Here's a screenshot of what I'm referring to:

它是一个用HTML样式化代码的轻量级库。这是我所指的截屏:

如何在/ tag中逐字显示标签?[英]How to show  tag literally in / tag?
			      
			      
			      
			      
			      
			      
			         本文翻译自
			      
			      
			       Loolooii
			       查看原文
			      
			       2012-07-08
			       37298 
                  
                      
                     
                     
                     
                     blogger/
                                          
                     
                     
                     html                     
                     
                  
			        
			          
				        
				      
			      
			      
			          
						
						     (adsbygoogle = window.adsbygoogle || []).push({});
 						
                 
                        
                        
                            I'm using <code> tag inside of a <pre> tag to show code on my blogger blog. Unfortunately it doesn't work with HTML tags. Is there any way to show "<div>" inside of <pre> or <code> tag without actually interpreting it as HTML? This is what I do right now: 
我使用标签内的 
标签来显示我博客上的代码。不幸的是,它不能使用HTML标签。有没有办法在或 tag中显示"
    
    
    
      "而不将其解释为HTML?这就是我现在所做的: 
      
     
<pre>
 <code>
 .class {        
   color:red;
 }
 // I would like HTML code inside this
 </code>
</pre>
 
Which works ok for everything except HTML. Any idea how to achieve this? Thanks. 
除了HTML,其他都可以。你知道怎么做吗?谢谢。

     (adsbygoogle = window.adsbygoogle || []).push({});7 个解决方案
                           
                           
							  
							    #1
							    
							      60  
 
 Unfortunately it doesn't work with HTML tags. 
 不幸的是,它不能使用HTML标记。 
 
<code> means "This is code", <pre> means "White space in this markup is significant". Neither means "The content of this element should not be treated as HTML", so both work perfectly, even if they don't mean what you want them to mean. 
表示“这是代码”, 
表示“这个标记中的空格是重要的”。两者都不意味着“不应该将该元素的内容视为HTML”,因此两者都可以很好地工作,即使它们并不意味着您想要它们的意思。 
 
 Is there any way to show "<div>" inside of <pre> or <code> tag without actually interpreting it as HTML?  
 有没有办法在 
 或 tag中显示"
   
   
     "而不将其解释为HTML? 
     
    
 
If you want to render a < character then use &lt;, with &gt; for > and &amp; for &. 
如果你想渲染一个 <字符,然后使用<> ,,&。 
  
You can't (in modern HTML) write markup and have it be interpreted as text. 
您不能(在现代HTML中)编写标记并将其解释为文本。
							     
							                          
                           
							  
							    #2
							    
							      
31  
It seems like a readonly textarea does pretty much what you want. 
看起来readonly textarea几乎可以满足您的需求。 
<textarea readonly>  </textarea>

							     
							                          
                           
							  
							    #3
							    
							      
12  
You can use the "xmp" element. The <xmp></xmp> has been in HTML since the beginning and is supported by all browsers. Even it should not be used, it is broadly supported. 
您可以使用“xmp”元素。 
从一开始就是HTML格式的,所有浏览器都支持。即使它不应该被使用,它也得到了广泛的支持。 
 
Everything inside <xmp></xmp> is taken as it is (no markup lke tags or character references is recognized there) except, for apparent reason, the end tag of the element itself. 
 
中的所有内容都保持原样(那里没有标记lke标记或字符引用被识别),除了明显的原因,元素本身的结束标记。 
 
Otherwise "xmp" is rendered like "pre". 
否则,“xmp”将呈现为“pre”。
							     
							                          
                           
							  
							    #4
							    
							      
7  
Try: 
试一试: 
<xmp></xmp>
 
for exemple: 
为例: 
<pre>
     <xmp></xmp>
</pre>
 
bye 
再见
							     
							                          
                           
							  
							    #5
							    
							      
2  
Just escape the HTML tags. For example -  
只是转义HTML标签。例如, 
Replace < with &lt; 
替换< & lt; 
Replace > with &gt; 
>替换为在 
Complete lookup here 
完成在这里查找
							     
							                          
                           
							  
							    #6
							    
							      
0  
Try CodeMirror (https://codemirror.net/) 
尝试CodeMirror(https://codemirror.net/) 
It's a lightweight library that styles code in HTML. Here's a screenshot of what I'm referring to: 
它是一个用HTML样式化代码的轻量级库。这是我所指的截屏: 
 
Worked well for us! 
工作对我们好!
							     
							                          
                           
							  
							    #7
							    
							      
-3  
Yes, with an escape xml function. You'll need to have jQuery enabled for it to work though. 
是的,带有转义xml函数。但是,您需要启用jQuery才能工作。 
<pre>
  ${fn:escapeXml('
    
  ')};
</pre>

							     
							                          
                           
                        
                 
               
				
				     (adsbygoogle = window.adsbygoogle || []).push({});
				
			     
			     		     
			     
			         
		              ×
		              注意!
		              
		              本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2012/07/08/f5aa9102d888e966ad3174f8d2458948.html。
		              
		              
		            	
		            
			
		    
		          
		          
			          
				          
					      timeout_show();
					      			
			
			
			  
			   
			   
			   
			       
			           Wrapping a DIv in a Pre tag
			       
			       			       
			   
			       
			           How do I add a pre tag inside a code tag with jQuery?
			       
			       			       
			   
			       
			           how to load iframe only with div tag show
			       
			       			       
			   
			       
			           How to show error in Div tag in angularjs?
			       
			       			       
			   
			       
			           CSS code highlighter - margin in pre code tag
			       
			       			       
			   
			       
			           How to clear pre tag in html
			       
			       			       
			   
			       
			           Retrieve Code or PRE tag content on server side
			       
			       			       
			   
			       
			           How to show all nested DIVs inside a main DIV with title tag?
			       
			       			       
			   
			       
			           How can I expand an  tag into a  Tag?
			       
			       			       
			   
			       
			           how to convert this from table tag to div tag
			       
			       			       
			   
			   

			   
				
				
				
				  .itdaan_shufu { width:300px;height:600px }
				  @media (max-width: 600px) { .itdaan_shufu { display: none; } }
				
				
				     (adsbygoogle = window.adsbygoogle || []).push({});

Worked well for us!

工作对我们好!

#7


-3  

Yes, with an escape xml function. You'll need to have jQuery enabled for it to work though.

是的,带有转义xml函数。但是,您需要启用jQuery才能工作。

<pre>
  ${fn:escapeXml('
    <!-- all your code -->
  ')};
</pre>