Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #81119

Re: Working with HTML5 documents

From Stefan Behnel <stefan_ml@behnel.de>
Subject Re: Working with HTML5 documents
Date 2014-11-20 21:10 +0100
References (1 earlier) <ab8be359-503f-4e0b-b157-66815687923b@googlegroups.com> <m4l6te$vvt$1@dont-email.me> <69c8db11-5928-4978-a0ca-0cd042f0febb@googlegroups.com> <m4ldrg$s1l$1@ger.gmane.org> <CALwzidmFbykm9BPAB-o_4k31_=AKf7qPsVjfw5fCaiB9CR4fFQ@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.16050.1416514228.18130.python-list@python.org> (permalink)

Show all headers | View raw


Ian Kelly schrieb am 20.11.2014 um 20:44:
> On Thu, Nov 20, 2014 at 12:02 PM, Stefan Behnel wrote:
>> There's also the E-factory for creating (sub-)trees and a nicely objectish way:
>>
>> http://lxml.de/lxmlhtml.html#creating-html-with-the-e-factory
> 
> That looks ugly with all those caps and also hard to extend. Notably
> it seems to be missing any functions to build HTML5 elements, unless
> those have been added in lxml 3.4.

It's actually trivial to extend, and it's designed for it. The factory
simply uses "__getattr__()", so you can ask it for any tag name. The
predefined names in the builder.py module are mainly there to easily detect
typos on user side.

https://github.com/lxml/lxml/blob/master/src/lxml/html/builder.py

If you don't like capital names for constants, just copy the module and
change the tag names to lower case, or use the blank E-factory if you feel
like it.

Stefan

Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Working with HTML5 documents Denis McMahon <denismfmcmahon@gmail.com> - 2014-11-19 21:08 +0000
  Re: Working with HTML5 documents Novocastrian_Nomad <gregory.j.baker@gmail.com> - 2014-11-19 13:43 -0800
    Re: Working with HTML5 documents Denis McMahon <denismfmcmahon@gmail.com> - 2014-11-20 17:03 +0000
      Re: Working with HTML5 documents Tim <jtim.arnold@gmail.com> - 2014-11-20 09:31 -0800
        Re: Working with HTML5 documents Stefan Behnel <stefan_ml@behnel.de> - 2014-11-20 20:02 +0100
        Re: Working with HTML5 documents Ian Kelly <ian.g.kelly@gmail.com> - 2014-11-20 12:44 -0700
        Re: Working with HTML5 documents Stefan Behnel <stefan_ml@behnel.de> - 2014-11-20 21:10 +0100
        Re: Working with HTML5 documents Ian Kelly <ian.g.kelly@gmail.com> - 2014-11-20 14:15 -0700

csiph-web