makohtml2html parser method issue

Asked by joeshen

在 makohtml2html.py文件中,

    def format_body(self, html):
        body = html.findall('body')
        body_list = []
        footer = self.format_footer(body[-1].getchildren())
        for b in body[:-1]:
            body_list.append(etree.tostring(b).replace('\t', '').replace('\n',''))

【Description above in English 】
Here, because for a html file, it should be only have 1 body tag, so in for loop statement, body[:-1] will return a null list.

I think, this way of parsing mako template parser is wrong. and it needs a better parsing method.

【for chinese Sr. dev】
这里, 在 body = html.findall('body')时,当只有html中只有1个body标签时, body[:-1] 得到的是 1 个 空的 list。 之后计算 Html_body 时,会导致Error。

我觉得这里有个问题,就是对一个mako模板来说, 或者 对一个html文件标签来说, body 最好只有1个, 所以 body[:-1]这样的用法,几乎会导致绝对的错误。

这个需要更好的解析方法。

Question information

Language:
English Edit question
Status:
Open
For:
Odoo Server (MOVED TO GITHUB) Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:

Can you help with this problem?

Provide an answer of your own, or ask joeshen for more information if necessary.

To post a message you must log in.