问题标签 [pre]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
90 浏览

php - 的奇怪行为

试图在我的网页上打印这个:

只获得:

!!

同时,我可以在 Chrome Inspector Network 选项卡中看到它已正确传送到浏览器。

当我检查 PRE 元素时,我看到了这个:

谁注释掉了代码,为什么,主要问题是如何阻止它!?


替换<?php&lt;?php和替换$this->$this-&gt;,您将获得预期的结果。 小提琴

通常,HTML 中的文字尖括号和 & 符号应替换为实体以避免误解。在这种情况下,Chrome 假定接收文字 PHP 代码是一个错误,而不是故意的,并将其转换为注释。我找不到任何说明它这样做的文档,但很明显发生了什么。

0 投票
0 回答
429 浏览

html - Different HTML markup in Chrome, missing "<" of closing tag for one pre element only

This is an extremely peculiar problem that is breaking a website of ours. In Google Chrome, there is a single pre closing tag that incorrectly looks like this: /pre> instead of . You can see it at about line 288 of the source code.

The website has been up for a year now without any code changes and has recently been broken by unknown forces (aren't they always?) but only in Google Chrome browser. The website was thoroughly tested on the then current version of Chrome and performed swell, however the website is now broken not only in the current Google Chrome, but past Google Chrome versions as well (making a Chrome bug unlikely). The page is being parsed on the server by PHP v5.3.8 and the particular markup comes from a straight forward, logic-less bit of code:

If I echo $markup before it's returned and exit the script before returning $markup, in Chrome I'll see the that last line (same markup from line 288) having a malformed pre closing tag.

However, If I echo the lines as they go, the offending line prints as expected.

Website can be found here: http://www.oneglassproductions.com All ideas appreciated, I'll be tinkering with it on the production site because the same code base functions properly on other servers. PHP configuration?

EDIT: Thanks to Martin, Adding a space just before the pre closing tag made the closing tag print properly and even now that I've reverted the code to without a space, the closing tag is printing properly (even though the code is identical to when we saw the problem). Still would like to know what might be going on.

0 投票
5 回答
55502 浏览

html - HTML
标签值获得水平滚动条,如何格式化?

这张图片显示了我在代码中发生的事情 这是我的博客页面。有时我不得不在博客中使用 C#、PHP 和其他代码片段。因此,我使用 pre 标签使它看起来不错,并保持格式代码不变。pre标签宽度为 100%,并且有背景颜色。但是,文本离开了它,如上图所示,水平滚动条将出现。我该如何克服呢?我不想要底部滚动条。

0 投票
2 回答
408 浏览

html - 当 > 65535 个字符 Chrome、Safari 时,pre 元素中的文本不显示

我有一个 <pre> 元素,我正在填充大量文本(在本例中约为 72000 个字符)。在 chrome 和 safari 中,我注意到 <pre> 中的文本在 65535 字符标记处被分成两部分。我可以这样说,因为在检查器中,我可以选择两个文本块,类似于我选择元素的方式。

您会认为在这种情况下,您会看到前 65535 个字符,但实际上我看到的是第二个字符块,而前 65535 个字符是隐藏的。我认为这是因为元素内的文本包含转义的 XML。

<pre> 元素内的文本有没有办法绕过这个字符限制?

0 投票
1 回答
9221 浏览

html - 是否可以在 a 中使用标签
标签?

0 投票
3 回答
6993 浏览

html - 避免带有 HTML 标签的 XSS

我有一个简单的网页,它接受查询项并将它们制作到页面中。示例网址:

然后页面会在页面某处显示 URL:

我觉得这会使页面容易受到 XSS 的攻击,以防页面加载包含类似于以下内容的 URL

我发现,将 URL 呈现为<pre>标签并没有帮助。有没有一个简单的解决方案,比如一个 HTML 标签,它的内容真的没有被解释而只是打印出来?

注意:这个问题与这个问题有些相似,但更笼统。

0 投票
1 回答
569 浏览

jquery - IE 问题 - Ajax 在 PRE 标记中加载内容

我在使用 IE8 时遇到以下问题:我像这样进行简单的 ajax 调用

接收到的数据只是来自 MySQL 数据库的普通文本。文本加载到 pre 标记中,这引发了问题。PRE 标记不会按应有的方式处理新加载的文本。例如,如果文本中有新行 ('\r\n'),它们都会消失。

重新加载整个网页后,完全相同的文本在 pre 标记中看起来正确。另外我提供了 pre 标签的 css 代码

但我认为,我的 css 代码不是实际问题。

0 投票
4 回答
311 浏览

html - 在中使用符号
标签

通常要打印诸如 forall 符号之类的符号,您只需使用 &forall,但这似乎不适用于字面上打印出“&forall”的 pre 块。

这个问题的解决方法是什么?

0 投票
1 回答
860 浏览

rpmbuild - rpmbuild %pre 不起作用

“%pre – 这是在安装脚本运行之前运行代码的位置。”

本节不适用于我。我从“<a href="http://repo.andrewfarley.com/centos/specs/zabbix.spec" rel="nofollow">http://repo.andrewfarley.com/centos/specs/ 得到一个规范文件zabbix.spec”。一切正常,但rpm包无法创建“zabbix”用户。

任何答复表示赞赏。谢谢。

操作系统:CentOS 5.7

0 投票
2 回答
10663 浏览

javascript - 更改所有内容
使用 JavaScript 的标签

我想知道如何更改文档中的所有 pre 标签...

我正在使用这个:

但这只会改变 1 个 pre 标签的内容......带有 ID 'code' 的那个。

如果你能告诉我如何使用 JavaScript 更改所有 pre 标签,我很感激

这是所有代码:

PS:这是为了让一个普通的编译器看起来像在行 PPS 之前带有数字的普通编译器:每个 pre 标签都会有不同的内容,我希望使用相同的脚本来更改它(如果可能的话)。