html tool

2012年8月29日星期三

Dive into python 的我的翻译 XX


8.8 Introducing dialect.py     

[原文]P114
Dialectizer is a simple (and silly) descendant of BaseHTMLProcessor. It runs blocks of text through a series of substitutions, but it makes sure that anything within a
...
block passes through unaltered. To handle the
 blocks, you define two methods in Dialectizer: 
      start_pre and end_pre.
    

[pope译](补)
Dialectizer 是个简陋(有点儿糊涂{silly})的BaseHTMLProcessor的扩展子方法。它运行时使一串的文本被替换,但它确保了
..
不被替换{unaltered}。
处理
块{blocks},你默认使用了Dialectizer的两个方法:start_pre 和end_pre.
    


[net 译 来源: http://woodpecker.org.cn/diveintopython/html_processing/dialect.html ]
Dialectizer 是 BaseHTMLProcessor 的简单 (和拙劣) 的派生类。它通过一系列的替换对文本块进行了处理,但是它确保在 

...
 块之间的任何东西不被修改地通过。
为了处理 

 块,我们在 Dialectizer 中定义了两个方法:start_pre 和 end_pre

[popexizhi:
 a simple(and silly) descendant of ..
[pope译]个简陋(有点儿糊涂{silly})的BaseHTMLProcessor的扩展子方法
[net 译]简单 (和拙劣) 的派生类
【popexizhi】silly 拙劣,嘻嘻,不错;说一下descendant 派生类,应该是固定用法了:)自己生熟的问题。
to handle the
 blocks
    

[net 译]为了处理 

 块
【popexizhi】 blocks 块 ,可以直接翻译。这个自己忘记翻译了:)
]
[pope改进译]Dialectizer,BaseHTMLProeccor之简单拙劣派生类。以替换文本串为己任,但
..
块中不处理。为不替
块之事,定义在Dialectizer中star_pre 
      与end_pre用之。
    




  • [go]
    标签

来源:http://www.w3school.com.cn/tags/tag_pre.asp

定义和用法

pre 元素可定义预格式化的文本。被包围在 pre 元素中的文本通常会保留空格和换行符。而文本也会呈现为等宽字体。
 标签的一个常见应用就是用来表示计算机的源代码。
    
[popexizhi:后记,很怪的事,此标记在google blog中不起作用,参见 http://popexizhi.blogspot.com/2012/08/montior-tomcat.html ,其中的 WEB-INF/web.xml  的标签都没有了]     



Example 8.17. Handling specific tags
    def start_pre(self, attrs):             
        self.verbatim += 1                  
        self.unknown_starttag("pre", attrs) 
    def end_pre(self):                      
        self.unknown_endtag("pre")          
        self.verbatim −= 1                  

     

 1
[原文]P114
start_pre is called every time SGMLParser finds a
 tag in the HTML 
      source. (In a minute, you'll see exactly how this happens.) The method 
      takes a single parameter, attrs, which contains the attributes of the 
      tag (if any). attrs is a list of key/value tuples, just like 
      unknown_starttag takes.
    


[popexizhi]SGMLParser每次在html 源码中找到
 时调用start_pre 
      .(一会儿就可以看到这个是如何发生的了。)此方法的简单参数attrs 包含着任何的标签属性。attrs是 key/value 的 tuples 
      ,仅在 unknown_strarttage 处理.
    


[net 译 来源: http://woodpecker.org.cn/diveintopython/html_processing/dialect.html ]
每当 SGMLParser  HTML 源代码中发现一个 

 时,都会调用 start_pre。(马上我们就会确切地看到它是如何发生的。) 这个方法使用单个参数:attrs,这个参数会包含标记的属性 (如果存在的话) 。attrs 是一个键/值 tuple 的 list,就像 unknown_starttag 中所使用的。

[popexizhi:
see exactly
[net 译] 确切的看到
【popexizhi】翻译时丢掉这个了,嘻嘻,以后精确一点儿。
just like unknown_starttag takes
[pope译]仅在 unknown_strarttage 处理.
[net 译]就像 unknown_starttag 中所使用的
【popexizhi】这里是类比unknown_starttag ,中的 list ,应该是翻译为  就像。
]
[pope改进译]SGMLParser 在HTML源码中每遇
 
      ,则调start_pre。(少顷,可详见此过程)此方法有一attrs参数,此参数包含全部tag中属性(如果存在属性)。 attrs 
      为key/value tuples,如  unknown_starttag所见。     


没有评论:

发表评论