HTML/XML 中是否存在标签未完全包含的有效案例?
Are there valid cases in HTML/XML where tags would not be fully contained?
我认为在 XML 和 HTML 中不允许使用跨范围的标签。也许 SGML 允许它。但是,在 XML/HTML 中,是否存在可能发生这种情况的有效且允许的情况?
类似于:
<p>This is <i>some <b>example</i> text</b> right here!</p>
这可能会生成如下输出:"This is some example text right here!"
(旁注:SO markdown 解析器显然可以处理它,谁知道呢?)
"This is *some **example* text** right here!"
I think in XML and HTML that having cross-scoped tags is not allowed.
正确
Maybe SGML allows it.
没有。
In XML/HTML though, are there any valid and allowed cases where this can occur?
没有。该标记仅描述了一个 DOM,它是一个节点树。一个节点只能有一个父节点。
"This is some example text right here!"
呈现为:
<p>"This is <em>some <strong>example</strong></em><strong> text</strong> right here!"</p>
像这样的重叠标签只有在文本中只有标签时才有可能。一旦文本被解析为元素(HTML 或 XML),就不可能表示这样的结构。
元素的概念是它是一个单一的实体,它不是文本中的起点和终点。
正如您的 SO markdown 示例所示,可以使用这样的标签,只要它只是文本中的标签。正如 Quentin 所展示的,SO 文本解析器必须将其转换为非重叠结构才能为其创建有效的 HTML 代码。
HTML 或 XML 中不允许。对于处理非分层标记的方法的调查,维基百科文章是一个很好的起点:
我认为在 XML 和 HTML 中不允许使用跨范围的标签。也许 SGML 允许它。但是,在 XML/HTML 中,是否存在可能发生这种情况的有效且允许的情况?
类似于:
<p>This is <i>some <b>example</i> text</b> right here!</p>
这可能会生成如下输出:"This is some example text right here!"
(旁注:SO markdown 解析器显然可以处理它,谁知道呢?)
"This is *some **example* text** right here!"
I think in XML and HTML that having cross-scoped tags is not allowed.
正确
Maybe SGML allows it.
没有。
In XML/HTML though, are there any valid and allowed cases where this can occur?
没有。该标记仅描述了一个 DOM,它是一个节点树。一个节点只能有一个父节点。
"This is some example text right here!"
呈现为:
<p>"This is <em>some <strong>example</strong></em><strong> text</strong> right here!"</p>
像这样的重叠标签只有在文本中只有标签时才有可能。一旦文本被解析为元素(HTML 或 XML),就不可能表示这样的结构。
元素的概念是它是一个单一的实体,它不是文本中的起点和终点。
正如您的 SO markdown 示例所示,可以使用这样的标签,只要它只是文本中的标签。正如 Quentin 所展示的,SO 文本解析器必须将其转换为非重叠结构才能为其创建有效的 HTML 代码。
HTML 或 XML 中不允许。对于处理非分层标记的方法的调查,维基百科文章是一个很好的起点: