Path: blob/master/venv/Lib/site-packages/lxml/html/builder.py
811 views
# --------------------------------------------------------------------1# The ElementTree toolkit is2# Copyright (c) 1999-2004 by Fredrik Lundh3# --------------------------------------------------------------------45"""6A set of HTML generator tags for building HTML documents.78Usage::910>>> from lxml.html.builder import *11>>> html = HTML(12... HEAD( TITLE("Hello World") ),13... BODY( CLASS("main"),14... H1("Hello World !")15... )16... )1718>>> import lxml.etree19>>> print lxml.etree.tostring(html, pretty_print=True)20<html>21<head>22<title>Hello World</title>23</head>24<body class="main">25<h1>Hello World !</h1>26</body>27</html>2829"""3031from lxml.builder import ElementMaker32from lxml.html import html_parser3334E = ElementMaker(makeelement=html_parser.makeelement)3536# elements37A = E.a # anchor38ABBR = E.abbr # abbreviated form (e.g., WWW, HTTP, etc.)39ACRONYM = E.acronym #40ADDRESS = E.address # information on author41APPLET = E.applet # Java applet (DEPRECATED)42AREA = E.area # client-side image map area43B = E.b # bold text style44BASE = E.base # document base URI45BASEFONT = E.basefont # base font size (DEPRECATED)46BDO = E.bdo # I18N BiDi over-ride47BIG = E.big # large text style48BLOCKQUOTE = E.blockquote # long quotation49BODY = E.body # document body50BR = E.br # forced line break51BUTTON = E.button # push button52CAPTION = E.caption # table caption53CENTER = E.center # shorthand for DIV align=center (DEPRECATED)54CITE = E.cite # citation55CODE = E.code # computer code fragment56COL = E.col # table column57COLGROUP = E.colgroup # table column group58DD = E.dd # definition description59DEL = getattr(E, 'del') # deleted text60DFN = E.dfn # instance definition61DIR = E.dir # directory list (DEPRECATED)62DIV = E.div # generic language/style container63DL = E.dl # definition list64DT = E.dt # definition term65EM = E.em # emphasis66FIELDSET = E.fieldset # form control group67FONT = E.font # local change to font (DEPRECATED)68FORM = E.form # interactive form69FRAME = E.frame # subwindow70FRAMESET = E.frameset # window subdivision71H1 = E.h1 # heading72H2 = E.h2 # heading73H3 = E.h3 # heading74H4 = E.h4 # heading75H5 = E.h5 # heading76H6 = E.h6 # heading77HEAD = E.head # document head78HR = E.hr # horizontal rule79HTML = E.html # document root element80I = E.i # italic text style81IFRAME = E.iframe # inline subwindow82IMG = E.img # Embedded image83INPUT = E.input # form control84INS = E.ins # inserted text85ISINDEX = E.isindex # single line prompt (DEPRECATED)86KBD = E.kbd # text to be entered by the user87LABEL = E.label # form field label text88LEGEND = E.legend # fieldset legend89LI = E.li # list item90LINK = E.link # a media-independent link91MAP = E.map # client-side image map92MENU = E.menu # menu list (DEPRECATED)93META = E.meta # generic metainformation94NOFRAMES = E.noframes # alternate content container for non frame-based rendering95NOSCRIPT = E.noscript # alternate content container for non script-based rendering96OBJECT = E.object # generic embedded object97OL = E.ol # ordered list98OPTGROUP = E.optgroup # option group99OPTION = E.option # selectable choice100P = E.p # paragraph101PARAM = E.param # named property value102PRE = E.pre # preformatted text103Q = E.q # short inline quotation104S = E.s # strike-through text style (DEPRECATED)105SAMP = E.samp # sample program output, scripts, etc.106SCRIPT = E.script # script statements107SELECT = E.select # option selector108SMALL = E.small # small text style109SPAN = E.span # generic language/style container110STRIKE = E.strike # strike-through text (DEPRECATED)111STRONG = E.strong # strong emphasis112STYLE = E.style # style info113SUB = E.sub # subscript114SUP = E.sup # superscript115TABLE = E.table #116TBODY = E.tbody # table body117TD = E.td # table data cell118TEXTAREA = E.textarea # multi-line text field119TFOOT = E.tfoot # table footer120TH = E.th # table header cell121THEAD = E.thead # table header122TITLE = E.title # document title123TR = E.tr # table row124TT = E.tt # teletype or monospaced text style125U = E.u # underlined text style (DEPRECATED)126UL = E.ul # unordered list127VAR = E.var # instance of a variable or program argument128129# attributes (only reserved words are included here)130ATTR = dict131def CLASS(v): return {'class': v}132def FOR(v): return {'for': v}133134135