Skip to content

Commit 4e0c5bf

Browse files
committed
update site-libs
1 parent 45ed81b commit 4e0c5bf

5 files changed

Lines changed: 51 additions & 3 deletions

File tree

libs/HTMLTreeParser.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,9 +359,10 @@ def finish_endtag(self, tag, loc):
359359
def handle_data(self, data):
360360
self._builder.data(data)
361361

362-
def handle_special(self, data, token_type):
362+
def handle_special(self, data, token_type=None):
363363
# here's where we figure out if we've got a doctype
364-
if token_type == 0x105: # from sgmlop.c
364+
if (token_type == 0x105 or # from sgmlop.c
365+
data and data.startswith("DOCTYPE")):
365366
# we get everything inside <!...>
366367
self.parse_doctype("<!%s>" % data)
367368

libs/langinfo.py

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,17 @@ class TextLangInfo(LangInfo):
235235
filename_patterns = ["README", "COPYING", "LICENSE", "MANIFEST"]
236236

237237

238+
def _generateFallbackKoLangInfo(langinfo_db, koLangInst):
239+
"""Generate a LangInfo instance from the koILanguage instance."""
240+
class FallbackKoLangInfo(LangInfo):
241+
conforms_to_bases = ["Text"]
242+
default_encoding = "utf-8"
243+
def __init__(self, db, koLang):
244+
LangInfo.__init__(self, db)
245+
self.name = koLang.name
246+
if koLang.defaultExtension:
247+
self.exts = [koLang.defaultExtension]
248+
return FallbackKoLangInfo(langinfo_db, koLangInst)
238249

239250
#---- the Database
240251

@@ -269,7 +280,7 @@ def langinfo_from_lang(self, lang):
269280
raise LangInfoError("no info on %r lang" % lang)
270281
return self._langinfo_from_norm_lang[norm_lang]
271282

272-
def langinfo_from_komodo_lang(self, komodo_lang):
283+
def langinfo_from_komodo_lang(self, komodo_lang, tryFallback=True):
273284
"""Return a langinfo for the given Komodo language name.
274285
275286
There are some minor differences in Komodo language names and
@@ -283,6 +294,28 @@ def langinfo_from_komodo_lang(self, komodo_lang):
283294
return self._li_from_norm_komodo_lang[norm_komodo_lang]
284295
elif norm_komodo_lang in self._langinfo_from_norm_lang:
285296
return self._langinfo_from_norm_lang[norm_komodo_lang]
297+
elif tryFallback:
298+
# If a koILanguage exists for this lang, then create a fallback
299+
# langinfo for it - this occurs when a user has defined an add-on or
300+
# language, but they haven't made a langinfo.py for it.
301+
try:
302+
from xpcom import components
303+
except ImportError:
304+
pass # no xpcom
305+
else:
306+
langSvc = components.classes["@activestate.com/koLanguageRegistryService;1"] \
307+
.getService(components.interfaces.koILanguageRegistryService)
308+
# Note: When the language does not exist, we get a fallback of
309+
# koILang.Text
310+
koLang = langSvc.getLanguage(komodo_lang)
311+
if koLang is not None and koLang.name in (komodo_lang, norm_komodo_lang):
312+
# Someone's defined a koILanguage for this lang - create
313+
# dummy langinfo for it.
314+
log.warn("no LangInfo class found for %r, creating a fallback for it",
315+
komodo_lang)
316+
self._langinfo_from_norm_lang[norm_komodo_lang] = _generateFallbackKoLangInfo(self, koLang)
317+
self._build_tables()
318+
return self.langinfo_from_komodo_lang(komodo_lang, tryFallback=False)
286319
raise LangInfoError("no info on %r komodo lang" % komodo_lang)
287320

288321
def langinfo_from_emacs_mode(self, emacs_mode):

libs/langinfo_other.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ class APDLLangInfo(LangInfo):
112112
conforms_to_bases = ["Text"]
113113
exts = [".mac"]
114114

115+
class IniLangInfo(LangInfo):
116+
name = "Ini"
117+
conforms_to_bases = ["Text"]
118+
exts = [".ini"]
119+
115120
class POVRayLangInfo(LangInfo):
116121
"""The "Persistence of Vision Raytracer"
117122
http://www.povray.org

libs/langinfo_prog.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ class PHPLangInfo(LangInfo):
102102
# and the XML prolog encoding check.
103103

104104
keywords = set([
105+
# new to php 5.4
106+
"insteadof", "trait",
107+
# new to php 5.3
108+
"e_deprecated", "e_user_deprecated", "php_maxpathlen",
105109
# existed in php4
106110
"bool", "boolean", "catch", "define", "double", "false", "float",
107111
"int", "integer", "null", "object", "parent", "real",

libs/langinfo_template.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class EJSLangInfo(LangInfo):
5555
class DjangoTemplateLangInfo(LangInfo):
5656
name = "Django Template"
5757
conforms_to_bases = ["Text"]
58+
exts = [".django.html"]
5859
section_regexes = [
5960
("import", re.compile(r'\{\%[ \t]+(load\b.*?)\%\}')),
6061
("class", re.compile(r'\{\%[ \t]+(block\b.*?)\%\}')),
@@ -70,6 +71,10 @@ class DjangoHTMLTemplateLangInfo(DjangoTemplateLangInfo):
7071
],
7172
}
7273

74+
class TwigTemplateLangInfo(DjangoTemplateLangInfo):
75+
name = "Twig"
76+
exts = [".twig"]
77+
7378
class DjangoXHTMLTemplateLangInfo(DjangoTemplateLangInfo):
7479
name = "Django XHTML Template"
7580
specialization_hints_from_lang = {

0 commit comments

Comments
 (0)