comparison MoinMoin/formatter/text_html.py @ 1364:12ddd8661ad6

basic structure for new AdvancedSearch macro, py2.4 fix for html formatter
author Franz Pletz <fpletz AT franz-pletz DOT org>
date Thu, 17 Aug 2006 08:34:22 +0200
parents 277b97ba0700
children c3fcddbf0c51
comparison
equal deleted inserted replaced
1362:1194f8f91158 1364:12ddd8661ad6
4 4
5 @copyright: 2000 - 2004 by Jürgen Hermann <jh@web.de> 5 @copyright: 2000 - 2004 by Jürgen Hermann <jh@web.de>
6 @license: GNU GPL, see COPYING for details. 6 @license: GNU GPL, see COPYING for details.
7 """ 7 """
8 import os.path, re 8 import os.path, re
9 from sets import Set # TODO: when we require Python 2.4+ use the builtin 'set' type 9
10 try:
11 set
12 except:
13 from sets import Set as set
14
10 from MoinMoin.formatter import FormatterBase 15 from MoinMoin.formatter import FormatterBase
11 from MoinMoin import wikiutil, i18n, config 16 from MoinMoin import wikiutil, i18n, config
12 from MoinMoin.Page import Page 17 from MoinMoin.Page import Page
13 from MoinMoin.action import AttachFile 18 from MoinMoin.action import AttachFile
14 19
15 line_anchors = True 20 line_anchors = True
16 prettyprint = False 21 prettyprint = False
17 22
18 # These are the HTML elements that we treat as block elements. 23 # These are the HTML elements that we treat as block elements.
19 _blocks = Set(['dd', 'div', 'dl', 'dt', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 24 _blocks = set(['dd', 'div', 'dl', 'dt', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6',
20 'hr', 'li', 'ol', 'p', 'pre', 'table', 'tbody', 'td', 'tfoot', 'th', 25 'hr', 'li', 'ol', 'p', 'pre', 'table', 'tbody', 'td', 'tfoot', 'th',
21 'thead', 'tr', 'ul', 'blockquote', ]) 26 'thead', 'tr', 'ul', 'blockquote', ])
22 27
23 # These are the HTML elements which are typically only used with 28 # These are the HTML elements which are typically only used with
24 # an opening tag without a separate closing tag. We do not 29 # an opening tag without a separate closing tag. We do not
25 # include 'script' or 'style' because sometimes they do have 30 # include 'script' or 'style' because sometimes they do have
26 # content, and also IE has a parsing bug with those two elements (only) 31 # content, and also IE has a parsing bug with those two elements (only)
27 # when they don't have a closing tag even if valid XHTML. 32 # when they don't have a closing tag even if valid XHTML.
28 33
29 _self_closing_tags = Set(['area', 'base', 'br', 'col', 'frame', 'hr', 'img', 'input', 34 _self_closing_tags = set(['area', 'base', 'br', 'col', 'frame', 'hr', 'img',
30 'isindex', 'link', 'meta', 'param']) 35 'input', 'isindex', 'link', 'meta', 'param'])
31 36
32 # We only open those tags and let the browser auto-close them: 37 # We only open those tags and let the browser auto-close them:
33 _auto_closing_tags = Set(['p']) 38 _auto_closing_tags = set(['p'])
34 39
35 # These are the elements which generally should cause an increase in the 40 # These are the elements which generally should cause an increase in the
36 # indention level in the html souce code. 41 # indention level in the html souce code.
37 _indenting_tags = Set(['ol', 'ul', 'dl', 'li', 'dt', 'dd', 'tr', 'td']) 42 _indenting_tags = set(['ol', 'ul', 'dl', 'li', 'dt', 'dd', 'tr', 'td'])
38 43
39 # These are the elements that discard any whitespace they contain as 44 # These are the elements that discard any whitespace they contain as
40 # immediate child nodes. 45 # immediate child nodes.
41 _space_eating_tags = Set(['colgroup', 'dl', 'frameset', 'head', 'map' 'menu', 46 _space_eating_tags = set(['colgroup', 'dl', 'frameset', 'head', 'map' 'menu',
42 'ol', 'optgroup', 'select', 'table', 'tbody', 'tfoot', 47 'ol', 'optgroup', 'select', 'table', 'tbody', 'tfoot',
43 'thead', 'tr', 'ul']) 48 'thead', 'tr', 'ul'])
44 49
45 # These are standard HTML attributes which are typically used without any 50 # These are standard HTML attributes which are typically used without any
46 # value; e.g., as boolean flags indicated by their presence. 51 # value; e.g., as boolean flags indicated by their presence.
47 _html_attribute_boolflags = Set(['compact', 'disabled', 'ismap', 'nohref', 52 _html_attribute_boolflags = set(['compact', 'disabled', 'ismap', 'nohref',
48 'noresize', 'noshade', 'nowrap', 'readonly', 53 'noresize', 'noshade', 'nowrap', 'readonly',
49 'selected', 'wrap']) 54 'selected', 'wrap'])
50 55
51 # These are all the standard HTML attributes that are allowed on any element. 56 # These are all the standard HTML attributes that are allowed on any element.
52 _common_attributes = Set(['accesskey', 'class', 'dir', 'disabled', 'id', 'lang', 57 _common_attributes = set(['accesskey', 'class', 'dir', 'disabled', 'id', 'lang',
53 'style', 'tabindex', 'title']) 58 'style', 'tabindex', 'title'])
54 59
55 60
56 def rewrite_attribute_name(name, default_namespace='html'): 61 def rewrite_attribute_name(name, default_namespace='html'):
57 """ 62 """