1# -------------------------------------------------------------------- 2# The ElementTree toolkit is 3# Copyright (c) 1999-2004 by Fredrik Lundh 4# -------------------------------------------------------------------- 5 6""" 7A set of HTML generator tags for building HTML documents. 8 9Usage:: 10 11 >>> from lxml.html.builder import * 12 >>> html = HTML( 13 ... HEAD( TITLE("Hello World") ), 14 ... BODY( CLASS("main"), 15 ... H1("Hello World !") 16 ... ) 17 ... ) 18 19 >>> import lxml.etree 20 >>> print lxml.etree.tostring(html, pretty_print=True) 21 <html> 22 <head> 23 <title>Hello World</title> 24 </head> 25 <body class="main"> 26 <h1>Hello World !</h1> 27 </body> 28 </html> 29 30""" 31 32fromlxml.builderimportElementMaker 33fromlxml.htmlimporthtml_parser 34 35E=ElementMaker(makeelement=html_parser.makeelement) 36 37# elements 38A=E.a# anchor 39ABBR=E.abbr# abbreviated form (e.g., WWW, HTTP, etc.) 40ACRONYM=E.acronym# 41ADDRESS=E.address# information on author 42APPLET=E.applet# Java applet (DEPRECATED) 43AREA=E.area# client-side image map area 44B=E.b# bold text style 45BASE=E.base# document base URI 46BASEFONT=E.basefont# base font size (DEPRECATED) 47BDO=E.bdo# I18N BiDi over-ride 48BIG=E.big# large text style 49BLOCKQUOTE=E.blockquote# long quotation 50BODY=E.body# document body 51BR=E.br# forced line break 52BUTTON=E.button# push button 53CAPTION=E.caption# table caption 54CENTER=E.center# shorthand for DIV align=center (DEPRECATED) 55CITE=E.cite# citation 56CODE=E.code# computer code fragment 57COL=E.col# table column 58COLGROUP=E.colgroup# table column group 59DD=E.dd# definition description 60DEL=getattr(E,'del')# deleted text 61DFN=E.dfn# instance definition 62DIR=E.dir# directory list (DEPRECATED) 63DIV=E.div# generic language/style container 64DL=E.dl# definition list 65DT=E.dt# definition term 66EM=E.em# emphasis 67FIELDSET=E.fieldset# form control group 68FONT=E.font# local change to font (DEPRECATED) 69FORM=E.form# interactive form 70FRAME=E.frame# subwindow 71FRAMESET=E.frameset# window subdivision 72H1=E.h1# heading 73H2=E.h2# heading 74H3=E.h3# heading 75H4=E.h4# heading 76H5=E.h5# heading 77H6=E.h6# heading 78HEAD=E.head# document head 79HR=E.hr# horizontal rule 80HTML=E.html# document root element 81I=E.i# italic text style 82IFRAME=E.iframe# inline subwindow 83IMG=E.img# Embedded image 84INPUT=E.input# form control 85INS=E.ins# inserted text 86ISINDEX=E.isindex# single line prompt (DEPRECATED) 87KBD=E.kbd# text to be entered by the user 88LABEL=E.label# form field label text 89LEGEND=E.legend# fieldset legend 90LI=E.li# list item 91LINK=E.link# a media-independent link 92MAP=E.map# client-side image map 93MENU=E.menu# menu list (DEPRECATED) 94META=E.meta# generic metainformation 95NOFRAMES=E.noframes# alternate content container for non frame-based rendering 96NOSCRIPT=E.noscript# alternate content container for non script-based rendering 97OBJECT=E.object# generic embedded object 98OL=E.ol# ordered list 99OPTGROUP=E.optgroup# option group100OPTION=E.option# selectable choice101P=E.p# paragraph102PARAM=E.param# named property value103PRE=E.pre# preformatted text104Q=E.q# short inline quotation105S=E.s# strike-through text style (DEPRECATED)106SAMP=E.samp# sample program output, scripts, etc.107SCRIPT=E.script# script statements108SELECT=E.select# option selector109SMALL=E.small# small text style110SPAN=E.span# generic language/style container111STRIKE=E.strike# strike-through text (DEPRECATED)112STRONG=E.strong# strong emphasis113STYLE=E.style# style info114SUB=E.sub# subscript115SUP=E.sup# superscript116TABLE=E.table# 117TBODY=E.tbody# table body118TD=E.td# table data cell119TEXTAREA=E.textarea# multi-line text field120TFOOT=E.tfoot# table footer121TH=E.th# table header cell122THEAD=E.thead# table header123TITLE=E.title# document title124TR=E.tr# table row125TT=E.tt# teletype or monospaced text style126U=E.u# underlined text style (DEPRECATED)127UL=E.ul# unordered list128VAR=E.var# instance of a variable or program argument129130# attributes (only reserved words are included here)131ATTR=dict