-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathHyperText.py
More file actions
47 lines (40 loc) · 1.7 KB
/
HyperText.py
File metadata and controls
47 lines (40 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from __future__ import absolute_import
from . import HTMLGenerator
from . import Lexer
from .DispatchHandler import DispatchHandler
from . import Keywords
from ._SilverCity import find_lexer_module_by_id, PropertySet, WordList
from .ScintillaConstants import SCLEX_HTML
from . import LanguageInfo
import re
class HyperTextLexer(Lexer.Lexer):
def __init__(self, properties = PropertySet()):
self._properties = properties
self._lexer = find_lexer_module_by_id(SCLEX_HTML)
self._keyword_lists = [
WordList(Keywords.hypertext_keywords),
WordList(Keywords.js_keywords),
WordList(Keywords.vb_keywords),
WordList(Keywords.python_keywords),
WordList(Keywords.php_keywords),
WordList(Keywords.sgml_keywords)
]
class HyperTextHandler(DispatchHandler):
def __init__(self):
DispatchHandler.__init__(self, 'SCE_H')
class HyperTextHTMLGenerator(HTMLGenerator.SimpleHTMLGenerator, HyperTextHandler):
name = 'html'
description = 'HTML and PHP [with embedded: JavaScript, VBScript, Python]'
def __init__(self):
HyperTextHandler.__init__(self)
HTMLGenerator.SimpleHTMLGenerator.__init__(self, 'SCE_H')
def generate_html(self, file, buffer, lexer = HyperTextLexer()):
self._file = file
lexer.tokenize_by_style(buffer, self.event_handler)
html_language_info = LanguageInfo.LanguageInfo(
'html',
['html', 'htm', 'xhtml', re.compile('^php(\d)?$', re.IGNORECASE), 'inc'],
['.*?\<!DOCTYPE\s+html'],
[HyperTextHTMLGenerator]
)
LanguageInfo.register_language(html_language_info)