html tool

2012年11月25日星期日

Dive into Python 的我的翻译 XXVI------8.7


 [原文]P113
BaseHTMLProcessor consumes HTML (since it's descended from SGMLParser) and produces equivalent HTML, but the HTML output is not identical to the input. Tags and attribute names will end up in lowercase, even if they started in uppercase or mixed case, and attribute values will be enclosed in double quotes, even if they started in single quotes or with no quotes at all. It is this last side effect that you can take advantage of.
[pope改进译]BaseHTMLProcessor 消费 html (因为其继承了SGMLParser)且制作等价html,但其输出与输入并不等价。标签和属性名称将转化为小写,即使它们原是大写或是混合的,同时属性值将被双引号标识,即使它们原是单个引号或干脆没有引号。这是最后一点你可以享受此BaseHTMLProcessor 的好处。




[?]  BaseHTMLProcessor 消费 html 并且 制造对等的 html,但输出的html不等于输入的html。tags and 属性名称即使开始于大写,大小写混合字符但一定结束于小写字符,并且『[popexizhi]问题开始了』属性值使用double quotes 包住,
即使 他们开始与 single quotes 或是没有 quotes。
    [popexizhi]这个地方是在说输入的html中属性值可以是使用单引号标识,或是没有使用引号标识,但是输出内容中属性值一定使用双引号标识吗?求原文的翻译求证!

[net 译 来源:http://woodpecker.org.cn/diveintopython/html_processing/quoting_attribute_values.html]
BaseHTMLProcessor 消费 (consume) HTML (因为它是从 SGMLParser 派生来的) 并生成等价的 HTML。但是这个 HTML 输出与输入的并不一样。标记和属性名最终会转化为小写字母,即使它们可能以大写字母开始或是大小写的混合形式。属性值将被双引号引起来,即使它们原来可能是用单引号括起来的或根本没有括起来。这就是最后我们可以受益的边际效应。
[popexizhi:
【问题:这个地方是在说输入的html中属性值可以是使用单引号标识,或是没有使用引号标识,但是输出内容中属性值一定使用双引号标识吗?求原文的翻译求证!
回答:是的。:)】
will end up in lowercase,
[pope译]一定结束于小写字符
[net 译]最终会转化为小写字母
[popexizhi] end up 说的是BaseHTMLProcessor 做完后的结果,它will 完成的,这里“转化”的翻译确实很贴切:)
]    

没有评论:

发表评论