diff --git a/code_examples/Makefile b/code_examples/Makefile index f0dcf38..b27d24e 100644 --- a/code_examples/Makefile +++ b/code_examples/Makefile @@ -25,7 +25,7 @@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd INSTALL = /usr/bin/install -c install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c +7Binstall_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : diff --git a/code_examples/kernel.htm b/code_examples/kernel.htm new file mode 100644 index 0000000..4f6c62c --- /dev/null +++ b/code_examples/kernel.htm @@ -0,0 +1,468 @@ + + + + + + + The Linux Kernel Archives + + + + + + +

The Linux Kernel Archives

+ +

+ Welcome to the Linux Kernel Archives. This is the primary site + for the Linux kernel source, but it has much more than just + Linux kernels. Frequently Asked Questions

+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ + US + EU + +
ProtocolLocation
HTTPhttp://www.kernel.org/pub/
FTPftp://ftp.kernel.org/pub/
RSYNCrsync://rsync.kernel.org/pub/
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
The latest stable version of the Linux kernel is: 2.6.29.12009-04-02 20:57 UTCFV CChangelog
The latest prepatch for the stable Linux kernel tree is: 2.6.30-rc12009-04-07 22:45 UTCBV CChangelog
The latest 2.4 version of the Linux kernel is: 2.4.372008-12-02 08:13 UTCFVVICChangelog
The latest 2.2 version of the Linux kernel is: 2.2.262004-02-25 00:28 UTCFV  Changelog
The latest prepatch for the 2.2 Linux kernel tree is: 2.2.27-rc22005-01-12 23:55 UTCBVVI Changelog
The latest -mm patch to the stable Linux kernels is: 2.6.28-rc2-mm12008-10-29 06:29 UTC V   
+ +

+ F = full source, B = patch baseline, V = view patch, + VI = view incremental, C = current changesets
+ Changelogs are provided by the kernel authors directly. Please + don't write the webmaster about them.
+ Customize the patch viewer +

+
+ +

Site News

+ + +

The Linux Kernel Archives Mirror System

+

To improve access for everyone, a number of + sites around the world have provided mirrors of this site, which + may be faster to use than the master archive itself. Please see + http://www.kernel.org/mirrors/ for + information about how to connect to a participating mirror site.

+ +

To guard against Trojan mirror sites, all files originating at + the Linux Kernel Archives are cryptographically signed. If you are + getting a message that the verification key has expired, please + see this link.

+ +

What is Linux?

+

Linux is a clone of the operating system Unix, + written from scratch by Linus Torvalds with assistance from a + loosely-knit team of hackers across the Net. It aims towards + POSIX and Single UNIX + Specification compliance.

+ +

It has all the features you would expect in a modern + fully-fledged Unix, including true multitasking, virtual memory, + shared libraries, demand loading, shared copy-on-write executables, + proper memory management, and multistack networking including IPv4 + and IPv6.

+ +

Although originally developed first for 32-bit x86-based PCs (386 or + higher), today Linux also runs on (at least) the + Alpha AXP, + Sun SPARC, + Motorola 68000, + PowerPC, + ARM, + Hitachi SuperH, + IBM S/390, + MIPS, + HP PA-RISC, + Intel IA-64, + AMD x86-64, + AXIS CRIS, + Renesas M32R, + Atmel AVR32, + Renesas H8/300, + NEC V850, + Tensilica Xtensa, + and Analog Devices Blackfin + architectures; for many of these architectures in both 32- and + 64-bit variants.

+ +

Linux is easily portable to most general-purpose 32- or 64-bit + architectures as long as they have a paged memory management unit + (PMMU) and a port of the GNU C compiler (gcc) (part of The GNU Compiler Collection, GCC). Linux + has also been ported to a number of architectures without a PMMU, + although functionality is then obviously somewhat limited. See the + µClinux project for more + info.

+ +

New to Linux?

+ +

If you're new to Linux, you don't want to download the kernel, + which is just a component in a working Linux system. Instead, you + want what is called a distribution of Linux, which is a + complete Linux system. There are numerous distributions available + for download on the Internet as well as for purchase from various + vendors; some are general-purpose, and some are optimized for + specific uses. We currently have mirrors of several distributions + available at mirrors.kernel.org, + as well as a small collection of special-purpose distributions at + http://www.kernel.org/pub/dist/.

+ +

Note, however, that most distributions are very large (several + gigabytes), so unless you have a fast Internet + link you may want to save yourself some hassle and purchase a + CD-ROM with a distribution; such CD-ROMs are available from a number + of vendors.

+ +

The + Linux Installation HOWTO has more information how to set up + your first Linux system.

+ +

More Information

+

There is much information about Linux on the web.

+ +

Reporting Linux Kernel bugs

+

Please see http://www.kernel.org/pub/linux/docs/lkml/reporting-bugs.html + if you want to report a Linux kernel bug. Bug reports sent to + the kernel.org administrators will be ignored.

+ +

There is now a bugzilla setup at bugzilla.kernel.org. + Currently this is for reporting kernel version 2.6 bugs only.

+ +

Mailing list

+

The Linux kernel is discussed on the + linux-kernel mailing list at vger.kernel.org. The FAQ + is available at http://www.kernel.org/pub/linux/docs/lkml/, + please read the FAQ before subscribing.

+ +

Although there is no official archive site, unofficial + archives of the list can be found at:

+ + + +

Development trees

+

The Linux kernel, as well as several other pieces of software, + are maintained using the git + source code control system. For a more user-friendly wrapper around + git, see Cogito.

+ +

See http://git.kernel.org/ for a list of + git repositories on kernel.org.

+ +

Cryptographic Software

+

Due to U.S. Exports Regulations, all + cryptographic software on this site is subject to the following + legal notice:

+ +
+ This site includes publicly available + encryption source code which, together with object code + resulting from the compiling of publicly available source code, + may be exported from the United States under License Exception + "TSU" pursuant to 15 C.F.R. Section 740.13(e). +
+ +

This legal notice applies to cryptographic software + only. Please see the Bureau of Industry and Security for + more information about current U.S. regulations.

+ +

Our servers are located in Corvallis, Oregon, USA; Palo Alto and San + Francisco, California, USA; Amsterdam, Netherlands; and Umeå, Sweden. + Use in violation of any applicable laws is prohibited.

+ +

Comments

+

Before emailing kernel.org, please take a look at our + kernel.org FAQ.

+ +

For comments about the web pages, please send mail + to webmaster@kernel.org.

+ +

For comments about the file archive, please send mail + to ftpadmin@kernel.org.

+ +

Please do not send general Linux questions or bug + reports to these addresses. We do not have the resources to reply + to them. If your message does not relate to the operation of the + Linux Kernel Archives, it will be deleted without action. Because + of the volume of unsolicited email we receive, please add [KORG] + to the subject to avoid accidental deletion. Additionally, any + Content-Type other than text/plain will most likely be deleted + without action.

+ +
+ +

+ This site is operated by the Linux Kernel Organization, + Inc., a 501(c)3 nonprofit corporation, with + support from the following sponsors. +

+
+ +

+ Internet Systems Consortium +   + Umeå Universitet +   + HP +   + The Linux Foundation +   + Open Source Lab +   + Powered by Linux +   + Valid XHTML 1.0! +
+

+ +

+ Linux is a Registered Trademark of Linus Torvalds.
+ (Legal Notice) +

+ + + diff --git a/code_examples/tbb.htm b/code_examples/tbb.htm new file mode 100644 index 0000000..df96471 --- /dev/null +++ b/code_examples/tbb.htm @@ -0,0 +1,112 @@ + + + + + + + The Benefit Bank + + + + + + + + + + + + + +
+
+ +
+
+ + + + + + +
+ + + +

Login to The Benefit Bank!

+ + +
+ +
+
+ +
+
+ +
+
+
Login Name:
+
+
+ +
+
+
Password:
+
+ +
+
+ +
+
+ Reset Password / Log in Help +
+ +
+
+
+
+ + +
+ + + + +
+ + +
+ + + diff --git a/code_examples/yahoo.htm b/code_examples/yahoo.htm new file mode 100644 index 0000000..832c2ed --- /dev/null +++ b/code_examples/yahoo.htm @@ -0,0 +1,3957 @@ + + + + + + + + + + + + +Yahoo! + + + + + + + +
+
+
+
+
+
+ +
+
+ +Yahoo! Personals: because love is magical +
+
+ + + + + + + +

+
+ + +
+ + +
+
+
+
+
+
+
+ + +
+
+ + +
+
+
+
+
+
+
+
+

Featured Navigation

+ +
+
+
+
+  + +
+Carrie Underwwod (Ethan Miller/Getty Images) + +

Carrie's embarrassing joke

+

Carrie Underwood cracks a racy joke at Matthew McConaughey onstage, then really regrets it. » What she said

+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+
+ +
+
+

News Navigation

+ +
+
+ +

In the News

+ +
+
+
+
+
+
+
+
+
+ + + + + + +
+
+ +
+ +
+
 Why online college is rocking:
1) Some employers pay tuition 2) Convenient 3) Higher salary with higher degree 4) Top schools online.

A bad credit score is 600 or below. Click here to instantly see your score in 2 easy steps for $0. By Experian®
Hugh Downs reports on little-known heart attack symptom many people sadly ignore in Bottom Line Book
Avon: Lowest Prices Ever $10 Off Anew Clinical Anti-Aging Skincare and Free Shipping. + +
+
+ +
+
+ +
+
+ +
+ + + + + + + + + + + + + + diff --git a/code_examples/youtube.htm b/code_examples/youtube.htm new file mode 100644 index 0000000..643c9d6 --- /dev/null +++ b/code_examples/youtube.htm @@ -0,0 +1,1817 @@ + + + + + + + + + + YouTube - Broadcast Yourself. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + + + +
+ Home + Videos + + Channels + Community + +
+ + +
+ + + Search +
+ + + Upload + +
+
+ +
+
+ + + + + + + + + +
+
+
+ +
+ +
+
+Featured Videos + +
+
+ + +
+ + + + + +
+ + + + +
Mega64: Metal Gear Solid 4 (HD)
+ +
+ + +
+
+ [TRANSLATED] + Mega64: Metal Gear Solid 4 (HD) +
+
+ [TRANSLATED] + Mega64: Metal Gear Solid 4 (HD) + +
+
+ +
+ A skit that went great until someone made it all awesome. + +http://mega64.com +
+ + +
+ + + + 385,906 views + + RoccoB64 + + + +
+ +
+
+ + + +
+
+ + + +
+ + + + + +
+ + + + +
Gamers Of Fast & Furious
+ +
+ + +
+
+ [TRANSLATED] + Gamers Of Fast & Furious +
+
+ [TRANSLATED] + Gamers Of Fast & Furious +
+
+ +
+ The cast of Fast & Furious discuss their favorite current videogames, as well as s... +
+ + +
+ + + + 196,309 views + + IGNentertainment + + + +
+ +
+
+ + + +
+
+ + + +
+ + + + + +
+ + + + +
Glam Prom Makeup - Pt. 2
+ +
+ + +
+
+ [TRANSLATED] + Glam Prom Makeup - Pt. 2 +
+
+ [TRANSLATED] + Glam Prom Makeup - Pt. 2 +
+
+ +
+ Sorry about the volume you guys, I know it's kind of low. I'll figure it out for t... +
+ + +
+ + + + 133,494 views + + fafinettex3 + + + +
+ +
+
+ + + +
+
+ + + +
+ + + + + +
+ + + + +
FAIL Toy ELMO LOVES BALLS and EPIC Wiggles Singing Guitar review by Mike Mozart of JeepersMedia
+ +
+ + + + +
+ Fail Toy Elmo Loves Balls Fail Toy Product Review By Mike Mozart of JeepersMedia o... +
+ + +
+ + + + 123,476 views + + JeepersMedia + + + +
+ +
+
+ + + +
+
+ +
+
+
+ + + + + + + + + +
+ + + +
+ + + + + +
+ + + + +
One Million Subscribers
0:47
+
+ +
+ + +
+
+ [TRANSLATED] + One Million Subscribers +
+
+ [TRANSLATED] + One Million Subscribers +
+
+ +
+ Fred and Lucas thank you! +
+ + +
+ + + + +
+ + + + + + +
+ + +
+ + + 308 views + + Fred + + + + +
+ + + + + + +
+ + +
+ + +
+ +
+
+ + + +
+
+ + + + +
+ + + + + +
+ + + + +
Way of the Guard
3:08
+
+ +
+ + +
+
+ [TRANSLATED] + Way of the Guard +
+
+ [TRANSLATED] + Way of the Guard + +
+
+ +
+ A strict security guard gets a temp job at a martial arts supply store. + +John Ge... +
+ + +
+ + + + +
+ + + + + + +
+ + +
+ + + 88,147 views + + waverlyflams + + + + +
+ + + + + + +
+ + +
+ + +
+ +
+
+ + + +
+
+ + + + +
+ + + + + +
+ + + + +
The Final Inch Documentary  (HBO)
38:36
+
+ +
+ + +
+ + +
+ +
+ Nearly 50 years after a vaccine for polio was developed in the United States, the ... +
+ + +
+ + + + +
+ + + + + + +
+ + +
+ + + 70,106 views + + HBO + + + + +
+ + + + + + +
+ + +
+ + +
+ +
+
+ + + +
+
+ + + + +
+ + + + + +
+ + + + +
YouTube Time Capsule!
2:57
+
+ +
+ + +
+
+ [TRANSLATED] + YouTube Time Capsule! +
+
+ [TRANSLATED] + YouTube Time Capsule! +
+
+ +
+ subscribe4funtimes! thx for all the support guys! URAWK!!! + +My BlogTV Show!!! ... +
+ + +
+ + + + +
+ + + + + + +
+ + +
+ + + 307,940 views + + lacigreen + + + + +
+ + + + + + +
+ + +
+ + +
+ +
+
+ + + +
+
+ + + + +
+ + + + + +
+ + + + +
Flutter: The New Twitter
3:44
+
+ +
+ + +
+
+ [TRANSLATED] + Flutter: The New Twitter +
+
+ [TRANSLATED] + Flutter: The New Twitter + +
+
+ +
+ As Twitter-mania reaches new levels, Slate V presents a mockumentary about a compa... +
+ + +
+ + + + +
+ + + + + + +
+ + +
+ + + 264,898 views + + slatester + + + + +
+ + + + + + +
+ + +
+ + +
+ +
+
+ + + +
+
+ + + + +
+ + + + + +
+ + + + +
Fiume Nights, Nikaido Kazumi, Osaka, february2009
6:05
+
+ +
+ + + + +
+ a short walk in Osaka's night with the young Nikaido Kazumi, that we met that same... +
+ + +
+ + + + +
+ + + + + + +
+ + +
+ + + 43,477 views + + vincentmoon + + + + +
+ + + + + + +
+ + +
+ + +
+ +
+
+ + + +
+
+ + + + +
+ + + + + +
+ + + + +
Cat does taxes
1:40
+
+ +
+ + +
+
+ [TRANSLATED] + Cat does taxes +
+
+ [TRANSLATED] + Cat does taxes + +
+
+ +
+ A man tries to help his cat with her taxes, with hilarious results! +MORE SOON! +W... +
+ + +
+ + + + +
+ + + + + + +
+ + +
+ + + 559,448 views + + daneboe + + + + +
+ + + + + + +
+ + +
+ + +
+ +
+
+ + + +
+
+ + + + +
+ + + + + +
+ + + + +
A Very Different Breakdance
4:02
+
+ +
+ + +
+
+ [TRANSLATED] + A Very Different Breakdance +
+
+ [TRANSLATED] + A Very Different Breakdance +
+
+ +
+ Gavin dancing to Szamár madár" by Venetian Snares. +Thankyou so much for the spotl... +
+ + +
+ + + + +
+ + + + + + +
+ + +
+ + + 155,038 views + + eleven12thirteen + + + + +
+ + + + + + +
+ + +
+ + +
+ +
+
+ + + +
+
+ + + + +
+ + + + + +
+ + + + +
N.A.S.A. "Gifted" (feat. Kanye West, Santogold, & Lykke Li)
3:40
+
+ +
+ + + + +
+ © 2009 Spectrophonic Sound under license to Anti- Records + +N.A.S.A. +"Gifted" (F... +
+ + +
+ + + + +
+ + + + + + +
+ + +
+ + + 241,979 views + + officialNASA + + + + +
+ + + + + + +
+ + +
+ + +
+ +
+
+ + + +
+
+ + + + +
+ + + + + +
+ + + + +
Frontcourt Battle: 'Nova vs. UNC
6:21
+
+ +
+ + +
+ + +
+ +
+ Jason Horowitz is joined by Tim Brando and Steve Lappas as they discuss Tyler Hans... +
+ + +
+ + + + +
+ + + + + + +
+ + +
+ + + 53,292 views + + CBSNCAATourney + + + + +
+ + + + + + +
+ + +
+ + +
+ +
+
+ + + +
+
+ + + + +
+ + + + + +
+ + + + +
Backcourt Battle: MSU vs. UConn
5:21
+
+ +
+ + +
+
+ [TRANSLATED] + Backcourt Battle: MSU vs. UConn +
+
+ [TRANSLATED] + Backcourt Battle: MSU vs. UConn +
+
+ +
+ Can Kalin Lucas and his teammates win the battle of the backcourt against A.J. Pri... +
+ + +
+ + + + +
+ + + + + + +
+ + +
+ + + 31,302 views + + CBSNCAATourney + + + + +
+ + + + + + +
+ + +
+ + +
+ +
+
+ + + +
+
+ + + + +
+ + + + + +
+ + + + +
London 10 Quirky Places
9:31
+
+ +
+ + +
+
+ [TRANSLATED] + London 10 Quirky Places +
+
+ [TRANSLATED] + London 10 Quirky Places + +
+
+ +
+ An alternative sightseeing trip round London, taking a look at some of it's quirki... +
+ + +
+ + + + +
+ + + + + + +
+ + +
+ + + 295,161 views + + ChrisCLondon + + + + +
+ + + + + + +
+ + +
+ + +
+ +
+
+ + + +
+
+ +
+ +
+ + + +
+ + +
+ + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + +
+
+
+ Want to customize this homepage? +
+ + Sign In or Sign Up now! + + + +
+ +
+ + + + + + +
+ + + + + + + + +
+ + + + + + + + +
+ + + + + + + + +
+ + + + +
+
+
+ +
+
+
+
What's New
+
+
+
+ Create, Collaborate, Annotate
Try Collaborative Annotations +
+
+
+
+
+ YouTube in High Definition
+Watch your favorite videos in HD! +
+
+ + + + + + +
+ Fred Hits 1m Subscribers
+ Congratulations to YouTube's most hyperactive star, the helium-voiced Fred Figglehorn, on the occasion of his Fred channel recording its millionth subscriber, the first YouTube channel to do so. + +

+
+ +
 
+
+
+ +
+
+ +
+ +
+ + + + + + +
+ + + + + + + + +
+ + + + +
+ +
+ + + +
+ + + + + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/method/__init__.py b/method/__init__.py index 54ebf79..62c8db6 100644 --- a/method/__init__.py +++ b/method/__init__.py @@ -1128,6 +1128,7 @@ class SetTokenColors(Method): colors = tuple([x.strip() for x in vargs['colors'].split(',')]) a = w.application if '*' in name: + a.cached_colors = {} nstr = name.replace('.', '\\.').replace('*', '.*') r = re.compile(nstr) count = 0 diff --git a/mode/cheetah.py b/mode/cheetah.py index 58317ed..0ac0ed6 100644 --- a/mode/cheetah.py +++ b/mode/cheetah.py @@ -3,8 +3,8 @@ from lex import Grammar, PatternRule, RegionRule class StringGrammar(Grammar): rules = [ - PatternRule('cheetah_placeholder', r'\${[a-zA-Z0-9_.\[\]]+}'), - PatternRule('cheetah_placeholder', r'\$[a-zA-Z0-9_.\[\]]+'), + PatternRule('cheetah.placeholder', r'\${[a-zA-Z0-9_.\[\]]+}'), + PatternRule('cheetah.placeholder', r'\$[a-zA-Z0-9_.\[\]]+'), PatternRule('octal', r'\\[0-7]{3}'), PatternRule('escaped', r'\\.'), PatternRule('data', r'[^\$\\]+'), @@ -12,8 +12,8 @@ class StringGrammar(Grammar): class TagGrammar(Grammar): rules = [ - PatternRule('cheetah_placeholder', r'\${[a-zA-Z0-9_.\[\]]+}'), - PatternRule('cheetah_placeholder', r'\$[a-zA-Z0-9_.\[\]]+'), + PatternRule('cheetah.placeholder', r'\${[a-zA-Z0-9_.\[\]]+}'), + PatternRule('cheetah.placeholder', r'\$[a-zA-Z0-9_.\[\]]+'), RegionRule('string', '"', StringGrammar, '"'), RegionRule('string', "'", StringGrammar, "'"), PatternRule('namespace', '[a-zA-Z_]+:'), @@ -25,10 +25,10 @@ class TemplateGrammar(Grammar): rules = [ RegionRule('comment', r'#\*', Grammar, r'\*#'), PatternRule('comment', r'##.*\n'), - PatternRule('cheetah_placeholder', r'\${[a-zA-Z0-9_.\[\]]+}'), - PatternRule('cheetah_placeholder', r'\$[a-zA-Z0-9_.\[\]]+'), - PatternRule('cheetah_directive', r'#.*?[#\n]'), - RegionRule('cheetah_tag', ''), + PatternRule('cheetah.placeholder', r'\${[a-zA-Z0-9_.\[\]]+}'), + PatternRule('cheetah.placeholder', r'\$[a-zA-Z0-9_.\[\]]+'), + PatternRule('cheetah.directive', r'#.*?[#\n]'), + RegionRule('cheetah.tag', ''), ] class Template(Fundamental): @@ -37,16 +37,13 @@ class Template(Fundamental): grammar = TemplateGrammar commentc = '##' colors = { - 'cheetah_directive': ('magenta', 'default', 'bold'), - 'cheetah_placeholder': ('magenta', 'default', 'bold'), - 'cheetah_tag.start': ('default', 'default', 'bold'), - 'cheetah_tag.namespace': ('magenta', 'default', 'bold'), - 'cheetah_tag.name': ('blue', 'default', 'bold'), - 'cheetah_tag.attrname': ('cyan', 'default', 'bold'), - 'cheetah_tag.string.start': ('green', 'default', 'bold'), - 'cheetah_tag.string.null': ('green', 'default', 'bold'), - 'cheetah_tag.string.end': ('green', 'default', 'bold'), - 'cheetah_tag.end': ('default', 'default', 'bold'), + 'cheetah.directive': ('magenta', 'default', 'bold'), + 'cheetah.placeholder': ('magenta', 'default', 'bold'), + 'cheetah.tag.start': ('default', 'default', 'bold'), + 'cheetah.tag.namespace': ('magenta', 'default', 'bold'), + 'cheetah.tag.name': ('blue', 'default', 'bold'), + 'cheetah.tag.attrname': ('cyan', 'default', 'bold'), + 'cheetah.tag.end': ('default', 'default', 'bold'), } _bindings = { 'close-paren': (')',), diff --git a/mode/css.py b/mode/css.py index 0cb76e1..6406662 100644 --- a/mode/css.py +++ b/mode/css.py @@ -21,24 +21,24 @@ class CSSGrammar(Grammar): rules = [ RegionRule(r'comment', '/\*', CommentGrammar1, '\*/'), RegionRule(r'comment', ''), - NocasePatternRule(r'css_dimension', r'[+-]?(?:\d+|\d*\.\d+)[-a-z_][-a-z0-9_]*'), - NocasePatternRule(r'css_percentage', r'[+-]?(?:\d+|\d*\.\d+)%%'), - NocasePatternRule(r'css_length', r'[+-]?(?:\d+|\d*\.\d+)(?:em|ex|px|in|cm|mm|pt|pc)'), - NocasePatternRule(r'css_hash', r'#' + chr2 + '+'), - NocasePatternRule(r'css_real', r'[+-]?\d*\.\d+'), - NocasePatternRule(r'css_int', r'[+-]?\d+'), - NocasePatternRule(r'css_rule', r'@(?:page|media|import)'), - NocasePatternRule(r'css_color', r'(?:aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow|#\d{6}|#\d{3})(?!' + chr2 + ')'), + NocasePatternRule(r'css.dimension', r'[+-]?(?:\d+|\d*\.\d+)[-a-z_][-a-z0-9_]*'), + NocasePatternRule(r'css.percentage', r'[+-]?(?:\d+|\d*\.\d+)%%'), + NocasePatternRule(r'css.length', r'[+-]?(?:\d+|\d*\.\d+)(?:em|ex|px|in|cm|mm|pt|pc)'), + NocasePatternRule(r'css.hash', r'#' + chr2 + '+'), + NocasePatternRule(r'css.real', r'[+-]?\d*\.\d+'), + NocasePatternRule(r'css.int', r'[+-]?\d+'), + NocasePatternRule(r'css.rule', r'@(?:page|media|import)'), + NocasePatternRule(r'css.color', r'(?:aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow|#\d{6}|#\d{3})(?!' + chr2 + ')'), - NocasePatternRule(r'css_keyword', r'(?:url|rgb|counter)'), - NocaseRegionRule(r'css_keyword', '(?:(?<=url)|(?<=rgb)|(?<=counter))\(', KeywordGrammar, '\)'), + NocasePatternRule(r'css.keyword', r'(?:url|rgb|counter)'), + NocaseRegionRule(r'css.keyword', '(?:(?<=url)|(?<=rgb)|(?<=counter))\(', KeywordGrammar, '\)'), - NocasePatternRule(r'css_label', r"\.?" + chr2 + "+(?= *{)"), - NocasePatternRule(r'css_ident', r"-?[a-z_]" + chr2 + "*"), - NocasePatternRule(r'css_name', chr2 + "+"), + NocasePatternRule(r'css.label', r"\.?" + chr2 + "+(?= *{)"), + NocasePatternRule(r'css.ident', r"-?[a-z_]" + chr2 + "*"), + NocasePatternRule(r'css.name', chr2 + "+"), NocasePatternRule(r'delimiter', r'[:;,{}()\[\]]|~=|\|=|='), - RegionRule(r'string', "'", StringGrammar1, r"'"), - RegionRule(r'string', '"', StringGrammar2, r'"'), + RegionRule(r'css.string', "'", StringGrammar1, r"'"), + RegionRule(r'css.string', '"', StringGrammar2, r'"'), ] class CSS(Fundamental): @@ -50,24 +50,24 @@ class CSS(Fundamental): closetokens = ('delimiter',) closetags = {')': '(', ']': '[', '}': '{'} colors = { - 'css_dimension': ('magenta', 'default', 'bold'), - 'css_percentage': ('magenta', 'default', 'bold'), - 'css_length': ('magenta', 'default', 'bold'), - 'css_real': ('magenta', 'default', 'bold'), - 'css_int': ('magenta', 'default', 'bold'), - 'css_color': ('magenta', 'default', 'bold'), - 'css_hash': ('cyan', 'default', 'bold'), - 'css_rule': ('cyan', 'default', 'bold'), - 'css_label': ('cyan', 'default', 'bold'), - 'css_keyword': ('cyan', 'default', 'bold'), - 'css_ident': ('default', 'default'), - 'css_name': ('default', 'default'), - 'css_keyword': ('cyan', 'default', 'bold'), - 'css_keyword.start': ('default', 'default', 'bold'), - 'css_keyword.null': ('cyan', 'default', 'bold'), - 'css_keyword.octal': ('magenta', 'default', 'bold'), - 'css_keyword.escaped': ('magenta', 'default', 'bold'), - 'css_keyword.end': ('default', 'default', 'bold'), + 'css.dimension': ('magenta', 'default', 'bold'), + 'css.percentage': ('magenta', 'default', 'bold'), + 'css.length': ('magenta', 'default', 'bold'), + 'css.real': ('magenta', 'default', 'bold'), + 'css.int': ('magenta', 'default', 'bold'), + 'css.color': ('magenta', 'default', 'bold'), + 'css.hash': ('cyan', 'default', 'bold'), + 'css.rule': ('cyan', 'default', 'bold'), + 'css.label': ('cyan', 'default', 'bold'), + 'css.keyword': ('cyan', 'default', 'bold'), + 'css.ident': ('default', 'default'), + 'css.name': ('default', 'default'), + 'css.keyword': ('cyan', 'default', 'bold'), + 'css.keyword.start': ('default', 'default', 'bold'), + 'css.keyword.null': ('cyan', 'default', 'bold'), + 'css.keyword.octal': ('magenta', 'default', 'bold'), + 'css.keyword.escaped': ('magenta', 'default', 'bold'), + 'css.keyword.end': ('default', 'default', 'bold'), } _bindings = { 'close-paren': (')',), diff --git a/mode/html.py b/mode/html.py index d355b8c..82880a0 100644 --- a/mode/html.py +++ b/mode/html.py @@ -4,24 +4,29 @@ import default import method from mode import Fundamental from lex import Grammar, PatternRule, RegionRule -from mode.xml import TagGrammar +from mode.xml import TagGrammar, CommentGrammar, MetadataGrammar, CDataGrammar from mode.javascript import JavascriptGrammar from mode.css import CSSGrammar -class CommentGrammar(Grammar): - rules = [PatternRule(r'data', r'(?:[^-]|-(?!-)|--(?!>))+')] +class DoctypeGrammar(Grammar): + rules = [PatternRule('data', '[^>]+')] class HTMLGrammar(Grammar): rules = [ - # TODO: how does cdata work again? - RegionRule(r'comment', r''), + PatternRule(r'html.data', r'[^&<]+'), # BUG: not all scripts are javascript and not all styles are CSS but # dynamically choosing a grammar based on the 'type' attribute (which # may be on a different line) is impractical. - RegionRule(r'script', r'<(?=script[^a-zA-Z0-9_])', TagGrammar, r'>', JavascriptGrammar, r')', TagGrammar, r'>'), - RegionRule(r'style', r'<(?=style[^a-zA-Z0-9_])', TagGrammar, r'>', CSSGrammar, r')', TagGrammar, r'>'), - RegionRule(r'tag', r''), - PatternRule(r'entity', r'&.*?;'), + RegionRule('html.tag', '<(?=script[^a-zA-Z0-9_])', TagGrammar, '>', + JavascriptGrammar, ')', TagGrammar, '>'), + RegionRule('html.tag', '<(?=style[^a-zA-Z0-9_])', TagGrammar, '>', + CSSGrammar, ')', TagGrammar, '>'), + RegionRule(r'comment', r''), + RegionRule(r'html.tag', r'<(?![\?!])', TagGrammar, r'/?>'), + RegionRule(r'html.metadata', r'<\?', MetadataGrammar, r'\?>'), + RegionRule(r'html.doctype', r''), + PatternRule(r'html.entity', r'&[a-z]+;'), + RegionRule(r'html.cdata', r''), ] class HtmlViewPage(method.Method): @@ -77,35 +82,31 @@ class HtmlCheckSpelling(method.Method): class HTML(Fundamental): name = 'HTML' - extensions = ['.html', '.htm', '.shtml', '.shtm', '.xhtml'] + extensions = ['.html', '.htm', '.shtml', '.shtm', '.xhtml', '.xhtm'] grammar = HTMLGrammar colors = { - 'entity': ('magenta', 'default', 'bold'), + 'html.entity': ('magenta', 'default', 'bold'), + 'html.metadata.start': ('magenta', 'default', 'bold'), + 'html.metadata.data': ('magenta', 'default', 'bold'), + 'html.metadata.end': ('magenta', 'default', 'bold'), + 'html.doctype.start': ('magenta', 'default', 'bold'), + 'html.doctype.data': ('magenta', 'default', 'bold'), + 'html.doctype.end': ('magenta', 'default', 'bold'), + 'html.tag.start': ('default', 'default', 'bold'), + 'html.tag.namespace': ('magenta', 'default', 'bold'), + 'html.tag.name': ('blue', 'default', 'bold'), + 'html.tag.attrname': ('cyan', 'default', 'bold'), + 'html.tag.end': ('default', 'default', 'bold'), } config = { 'html.viewcmd': 'firefox&', #'html.viewcmd': 'links', } - - _colorbase = { - 'start': ('default', 'default', 'bold'), - 'namespace': ('magenta', 'default', 'bold'), - 'name': ('blue', 'default', 'bold'), - 'attrname': ('cyan', 'default', 'bold'), - 'string.start': ('green', 'default', 'bold'), - 'string.null': ('green', 'default', 'bold'), - 'string.end': ('green', 'default', 'bold'), - 'end': ('default', 'default', 'bold'), - } - for _name in _colorbase: - colors['script.%s' % _name] = _colorbase[_name] - colors['style.%s' % _name] = _colorbase[_name] - colors['tag.%s' % _name] = _colorbase[_name] actions = [HtmlViewPage, HtmlValidatePage, HtmlCheckSpelling] _bindings = { - 'close-paren': (')',), - 'close-brace': ('}',), - 'close-bracket': (']',), + 'close-paren': (')',), + 'close-brace': ('}',), + 'close-bracket': (']',), 'xml-create-tag': ('M-t',), } url = None diff --git a/mode/javascript.py b/mode/javascript.py index 6db58c1..248c3e5 100644 --- a/mode/javascript.py +++ b/mode/javascript.py @@ -8,24 +8,24 @@ from point import Point class StringGrammar1(Grammar): rules = [ - PatternRule(r'octal', r'\\[0-7]{3}'), - PatternRule(r'hex', r'\\x[0-9a-fA-F]{2}'), - PatternRule(r'escaped', r'\\.'), - PatternRule(r'data', r'[^\\\']+'), + PatternRule('octal', r'\\[0-7]{3}'), + PatternRule('hex', r'\\x[0-9a-fA-F]{2}'), + PatternRule('escaped', r'\\.'), + PatternRule('data', r'[^\\\']+'), ] class StringGrammar2(Grammar): rules = [ - PatternRule(r'octal', r'\\[0-7]{3}'), - PatternRule(r'hex', r'\\x[0-9a-fA-F]{2}'), - PatternRule(r'escaped', r'\\.'), - PatternRule(r'data', r'[^\\\"]+'), + PatternRule('octal', r'\\[0-7]{3}'), + PatternRule('hex', r'\\x[0-9a-fA-F]{2}'), + PatternRule('escaped', r'\\.'), + PatternRule('data', r'[^\\\"]+'), ] class RegexGrammar(Grammar): rules = [ - PatternRule(r'octal', r'\\[0-7]{3}'), - PatternRule(r'hex', r'\\x[0-9a-fA-F]{2}'), - PatternRule(r'escaped', r'\\.'), - PatternRule(r'data', r'[^/\\]+'), + PatternRule('octal', r'\\[0-7]{3}'), + PatternRule('hex', r'\\x[0-9a-fA-F]{2}'), + PatternRule('escaped', r'\\.'), + PatternRule('data', r'[^/\\]+'), ] chr1 = '[a-zA-Z_]' @@ -34,29 +34,31 @@ word = chr1 + chr2 + '*' class JavascriptGrammar(Grammar): rules = [ - PatternRule(r'comment', r'//.*$'), - RegionRule(r'comment', '/\*', Grammar, '\*/'), - PatternRule(r'continuation', r'\\(?= *$)'), + PatternRule('comment', '//.*$'), + RegionRule('comment', '/\*', Grammar, '\*/'), + PatternRule('continuation', r'\\(?= *$)'), - PatternMatchRule(r'x', r'(function)( +)('+word+')', 'js_reserved', r'spaces', r'js_function'), - PatternMatchRule(r'x', r'(class|new)( +)('+word+')', 'js_reserved', r'spaces', r'js_class'), + PatternMatchRule('x', '(function)( +)(' + word + ')', + 'js.reserved', 'spaces', 'js.function'), + PatternMatchRule('x', '(class|new)( +)(' + word + ')', + 'js.reserved', 'spaces', 'js.class'), - PatternRule(r'js_reserved', r'(?:abstract|as|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|function|get|goto|if|import|implements|include|instanceof|interface|in|is|namespace|native|new|null|package|private|protected|public|return|set|super|switch|synchronized|this|throws|throw|transient|true|try|typeof|use|var|void|volatile|while|with)(?!'+chr2+')'), + PatternRule('js.reserved', '(?:abstract|as|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|function|get|goto|if|import|implements|include|instanceof|interface|in|is|namespace|native|new|null|package|private|protected|public|return|set|super|switch|synchronized|this|throws|throw|transient|true|try|typeof|use|var|void|volatile|while|with)(?!' + chr2 + ')'), - PatternRule(r'identifier', word), - PatternRule(r'integer', r"(?:0|[1-9][0-9]*|0[0-7]+|0[xX][0-9a-fA-F]+)[lL]?"), - PatternRule(r'float', r"[0-9]+\.[0-9]*|\.[0-9]+|(?:[0-9]|[0-9]+\.[0-9]*|\.[0-9]+)[eE][\+-]?[0-9]+"), + PatternRule('js.identifier', word), + PatternRule('js.integer', "(?:0|[1-9][0-9]*|0[0-7]+|0[xX][0-9a-fA-F]+)[lL]?"), + PatternRule('js.float', r"[0-9]+\.[0-9]*|\.[0-9]+|(?:[0-9]|[0-9]+\.[0-9]*|\.[0-9]+)[eE][\+-]?[0-9]+"), - PatternRule(r'eol', r'\n'), - PatternRule(r'spaces', r' +'), - PatternRule(r'delimiter', r'%=|&&=|&=|\(|\)|\*=|\+=|,|-=|\.{3}|\.|/=(?= |$)|::|:|;|<<=|>>=|>>>=|\?|\[|\]|^=|^^=|\{|\}|\|=|\|\|='), + PatternRule('eol', r'\n'), + PatternRule('spaces', ' +'), + PatternRule('delimiter', r'%=|&&=|&=|\(|\)|\*=|\+=|,|-=|\.{3}|\.|/=(?= |$)|::|:|;|<<=|>>=|>>>=|\?|\[|\]|^=|^^=|\{|\}|\|=|\|\|='), # fucking javascript! # their lexer grammar requires one-token look-behind in order to know # whether a "/" starts a literal regex, or is part of a mathematical # expression/assignment. - RegionRule('js_regex', "(?<=[\(=:,]) */", RegexGrammar, "/[a-z]*"), - PatternRule(r'operator', r'!==|!=|!|%|&&|&|\*|\+\+|\+|--|-|/|<<=|<<|<=|<|===|==|=|>>>=|>>>|>>=|>>|>=|>|\\|\|\|'), + RegionRule('js.regex', r"(?<=[\(=:,]) */", RegexGrammar, "/[a-z]*"), + PatternRule('js.operator', r'!==|!=|!|%|&&|&|\*|\+\+|\+|--|-|/|<<=|<<|<=|<|===|==|=|>>>=|>>>|>>=|>>|>=|>|\\|\|\|'), RegionRule('string', "'", StringGrammar1, "'"), RegionRule('string', '"', StringGrammar2, '"'), @@ -65,7 +67,8 @@ class JavascriptGrammar(Grammar): class JavascriptTabber2(tab.StackTabber2): open_tokens = {'delimiter': {'{': '}', '(': ')', '[': ']'}} close_tokens = {'delimiter': {'}': '{', ')': '(', ']': '['}} - control_tokens = {'keyword': {'if': 1, 'else': 1, 'while': 1, 'do': 1, 'for': 1}} + control_tokens = {'js.keyword': {'if': 1, 'else': 1, 'while': 1, + 'do': 1, 'for': 1}} end_at_eof = False end_at_tokens = {'delimiter': {';': 1}} nocontinue_tokens = {'delimiter': {';': 1, ',': 1}, @@ -80,7 +83,7 @@ class JavascriptTabber2(tab.StackTabber2): highlighter = self.mode.window.buffer.highlights[self.mode.name] if not highlighter.tokens[y]: return False t = highlighter.tokens[y][0] - return t.name == 'js_reserved' and t.string == 'function' + return t.name == 'js.reserved' and t.string == 'function' def _is_indent(self, t): return t.name == 'spaces' def _is_ignored(self, t): @@ -117,15 +120,15 @@ class Javascript(Fundamental): closetokens = ('delimiter',) closetags = {')': '(', ']': '[', '}': '{'} colors = { - 'js_function': ('blue', 'default', 'bold'), - 'js_class': ('magenta', 'default', 'bold'), - 'js_reserved': ('cyan', 'default', 'bold'), - 'js_regex.start': ('cyan', 'default', 'bold'), - 'js_regex.data': ('cyan', 'default', 'bold'), - 'js_regex.null': ('cyan', 'default', 'bold'), - 'js_regex.octal': ('magenta', 'default', 'bold'), - 'js_regex.escaped': ('magenta', 'default', 'bold'), - 'js_regex.end': ('cyan', 'default', 'bold'), + 'js.function': ('blue', 'default', 'bold'), + 'js.class': ('magenta', 'default', 'bold'), + 'js.reserved': ('cyan', 'default', 'bold'), + 'js.regex.start': ('cyan', 'default', 'bold'), + 'js.regex.data': ('cyan', 'default', 'bold'), + 'js.regex.null': ('cyan', 'default', 'bold'), + 'js.regex.octal': ('magenta', 'default', 'bold'), + 'js.regex.escaped': ('magenta', 'default', 'bold'), + 'js.regex.end': ('cyan', 'default', 'bold'), } config = {'rhino.cmd': 'rhino'} actions = [RhinoStart, RhinoLoadFile] diff --git a/mode/latex.py b/mode/latex.py index bdd44e7..5ccf792 100644 --- a/mode/latex.py +++ b/mode/latex.py @@ -5,9 +5,9 @@ from method import Method from lex import Grammar, PatternRule, RegionRule from mode.text import TextInsertSpace -class ArgumentGrammar(Grammar): rules = [PatternRule(r'data', r'[^}]+')] -class StringGrammar1(Grammar): rules = [PatternRule(r'data', r"[^']+")] -class StringGrammar2(Grammar): rules = [PatternRule(r'data', r"(?:[^']|'(?!'))+")] +class ArgumentGrammar(Grammar): rules = [PatternRule('data', '[^}]+')] +class StringGrammar1(Grammar): rules = [PatternRule('data', "[^']+")] +class StringGrammar2(Grammar): rules = [PatternRule('data', "(?:[^']|'(?!'))+")] class FalseGrammar(Grammar): rules = [ @@ -17,16 +17,16 @@ class FalseGrammar(Grammar): class LatexGrammar(Grammar): rules = [ - PatternRule(r'comment', r'\%.*$'), + PatternRule('comment', r'\%.*$'), RegionRule('comment', r'\\iffalse', FalseGrammar, r'\\fi'), - PatternRule(r'latex_wrapper', r'\\(?:begin|end)'), - PatternRule(r'latex_control', r'\\[a-zA-Z]+'), - RegionRule(r'latex_argument', r'{', ArgumentGrammar, r'}'), - RegionRule(r'latex_string', r"``", StringGrammar2, r"''"), - RegionRule(r'latex_string', r"`", StringGrammar1, r"'"), - PatternRule(r'latex_escaped', r'\\.'), - PatternRule(r'latex_special', r'[{}$^_%~#&]'), - PatternRule(r'data', r'[^{}$^_%~#&%\\`]+'), + PatternRule('latex.wrapper', r'\\(?:begin|end)'), + PatternRule('latex.control', r'\\[a-zA-Z]+'), + RegionRule('latex.argument', r'{', ArgumentGrammar, r'}'), + RegionRule('latex.string', r"``", StringGrammar2, r"''"), + RegionRule('latex.string', r"`", StringGrammar1, r"'"), + PatternRule('latex.escaped', r'\\.'), + PatternRule('latex.special', r'[{}$^_%~#&]'), + PatternRule('latex.data', r'[^{}$^_%~#&%\\`]+'), ] class LatexBuild(Method): @@ -120,15 +120,10 @@ class Latex(Fundamental): commentc = '%' grammar = LatexGrammar colors = { - 'latex_wrapper': ('magenta', 'default', 'bold'), - 'latex_control': ('blue', 'default', 'bold'), - 'latex_argument.null': ('cyan', 'default', 'bold'), - 'latex_argument.data': ('cyan', 'default', 'bold'), - 'latex_string.start': ('green', 'default', 'bold'), - 'latex_string.null': ('green', 'default', 'bold'), - 'latex_string.data': ('green', 'default', 'bold'), - 'latex_string.end': ('green', 'default', 'bold'), - 'latex_escaped': ('magenta', 'default', 'bold'), + 'latex.wrapper': ('magenta', 'default', 'bold'), + 'latex.control': ('blue', 'default', 'bold'), + 'latex.argument.null': ('cyan', 'default', 'bold'), + 'latex.argument.data': ('cyan', 'default', 'bold'), } config = { 'latex.buildcmd': 'latex', diff --git a/mode/make.py b/mode/make.py index 5b381d0..3041f71 100644 --- a/mode/make.py +++ b/mode/make.py @@ -1,35 +1,33 @@ import color, mode -from lex import Grammar, PatternRule, RegionRule -from mode.sh import ShGrammar, Sh +from lex import Grammar, PatternRule, RegionRule, PatternMatchRule +from mode.sh import ShGrammar, Sh, StringGrammar1, StringGrammar2 -class StringGrammar1(Grammar): - rules = [ - PatternRule(r'escaped', r'\\.'), - PatternRule(r'escaped', r'\$\$'), - PatternRule(r'variable', r"\$\([a-zA-Z0-9_]+\)"), - PatternRule(r'data', r"[^\\']+"), - ] -class StringGrammar2(Grammar): - rules = [ - PatternRule(r'escaped', r'\\.'), - PatternRule(r'escaped', r'\$\$'), - PatternRule(r'variable', r"\$\([a-zA-Z0-9_]+\)"), - PatternRule(r'data', r'[^\\"]+'), - ] +class StanzaGrammar(Grammar): pass +StanzaGrammar.rules = [ + PatternMatchRule('x', r'^( +)([\-@]*)', 'spaces', 'modifier'), + PatternRule('spaces', r' +'), + PatternRule('continuation', r'\\\n$'), + PatternRule('make.extvariable', r'\$\$\{.+?\}'), + PatternRule('make.extvariable', r'\$\$[a-zA-Z0-9_]+'), + PatternRule('escaped', r'\$\$'), + RegionRule('eval', '`', StanzaGrammar, '`'), + PatternRule('make.variable', r'\$[?@]'), + PatternRule('make.variable', r'\$[a-zA-Z0-9_]+'), + PatternRule('make.variable', r'\$\(.+?\)'), + PatternRule('make.variable', r'\$\{.+?\}'), + PatternRule('escaped', r'\\.'), + PatternRule('word', r'[a-zA-Z0-9_]+'), +] class MakeGrammar(Grammar): rules = [ - PatternRule(r'comment', r'#.*\n$'), - PatternRule(r'spaces', r' +$'), - PatternRule(r'continuation', r'\\\n$'), - PatternRule(r'targets', r'^[^:= ]+(?= *:)'), - RegionRule(r'assignment', r'^[^:= ]+ *=', ShGrammar, r'\n'), - RegionRule(r'actions', r'^ ', ShGrammar, r'\n'), - PatternRule(r'make_variable', r'\$\([a-zA-Z0-9_]+\)'), - PatternRule(r'make_variable', r'\${[a-zA-Z0-9_]+}'), - RegionRule(r'make_string', r'"', StringGrammar2, r'"'), - RegionRule(r'make_string', r"'", StringGrammar1, r"'"), - PatternRule(r'eol', r'\n$'), + PatternRule('spaces', ' +'), + PatternRule('eol', r'\n'), + PatternRule('make.macro', '[^ :=]+(?= *=)'), + PatternRule('make.target', '[^ :=]+(?= *:)'), + PatternRule('comment', r'#.*\n$'), + RegionRule('make.macro', '=', StanzaGrammar, '^(?=[^ ])'), + RegionRule('make.target', ':', StanzaGrammar, '^(?=[^ ])'), ] class Make(mode.Fundamental): @@ -39,14 +37,27 @@ class Make(mode.Fundamental): commentc = '#' savetabs = True colors = { - 'targets.start': ('cyan', 'default', 'bold'), - 'assignment.start': ('yellow', 'default', 'bold'), - 'make_variable': ('yellow', 'default', 'bold'), - 'make_string.start': ('green', 'default', 'bold'), - 'make_string.variable': ('yellow', 'default', 'bold'), - 'make_string.escaped': ('magenta', 'default', 'bold'), - 'make_string.null': ('green', 'default', 'bold'), - 'make_string.end': ('green', 'default', 'bold'), + 'make.macro': ('yellow', 'default', 'bold'), + 'make.macro.start': ('default', 'default'), + 'make.macro.word': ('default', 'default'), + 'make.macro.null': ('default', 'default'), + + 'make.macro.eval.start': ('cyan', 'default', 'bold'), + 'make.macro.eval.word': ('cyan', 'default', 'bold'), + 'make.macro.eval.null': ('cyan', 'default', 'bold'), + 'make.macro.eval.end': ('cyan', 'default', 'bold'), + + 'make.target': ('magenta', 'default', 'bold'), + 'make.target.modifier': ('green', 'default', 'bold'), + 'make.target.data': ('green', 'default', 'bold'), + + 'make.target.eval.start': ('cyan', 'default', 'bold'), + 'make.target.eval.word': ('cyan', 'default', 'bold'), + 'make.target.eval.null': ('cyan', 'default', 'bold'), + 'make.target.eval.end': ('cyan', 'default', 'bold'), + + 'make.extvariable': ('blue', 'default', 'bold'), + 'make.variable': ('yellow', 'default', 'bold'), } install = Make.install diff --git a/mode/tt.py b/mode/tt.py index d709da0..56a8d1b 100644 --- a/mode/tt.py +++ b/mode/tt.py @@ -1,11 +1,13 @@ import color, mode from lex import Grammar, PatternRule, RegionRule -from mode.perl import StringGrammar +from mode.perl import StringGrammar, PerlGrammar + +class PerlDirectiveGrammar(Grammar): + rules = [PatternRule(r'tt.perl', r'(?:PERL|RAWPERL|END)(?![A-Z_])')] class DirectiveGrammar(Grammar): rules = [ - PatternRule(r'comment', r'#(?:[^%]|%(?!\]))*'), - PatternRule(r'keyword', r'(?:BLOCK|CALL|CASE|CATCH|CLEAR|DEBUG|DEFAULT|FINAL|FILTER|FOREACH|ELSIF|ELSE|END|GET|IF|INCLUDE|INSERT|IN|LAST|MACRO|META|NEXT|PERL|PROCESS|RAWPERL|RETURN|SET|STOP|SWITCH|TAGS|THROW|TRY|UNLESS|USE|WHILE|WRAPPER)(?![A-Z_])'), + PatternRule(r'tt.keyword', r'(?:BLOCK|CALL|CASE|CATCH|CLEAR|DEBUG|DEFAULT|FINAL|FILTER|FOREACH|ELSIF|ELSE|END|GET|IF|INCLUDE|INSERT|IN|LAST|MACRO|META|NEXT|PERL|PROCESS|RAWPERL|RETURN|SET|STOP|SWITCH|TAGS|THROW|TRY|UNLESS|USE|WHILE|WRAPPER)(?![A-Z_])'), PatternRule(r'attribute', r'[a-zA-Z_][a-zA-Z0-9_]*(?= *=)'), RegionRule(r'string', r'"', StringGrammar, r'"'), RegionRule(r'string', r"'", StringGrammar, r"'"), @@ -13,7 +15,7 @@ class DirectiveGrammar(Grammar): class TagGrammar(Grammar): rules = [ - RegionRule(r'directive', r'\[\%', DirectiveGrammar, r'%%\]'), + RegionRule(r'tt.directive', r'\[\%', DirectiveGrammar, r'%%\]'), RegionRule(r'string', r'"', Grammar, r'"'), RegionRule(r'string', r"'", Grammar, r"'"), PatternRule(r'namespace', r'[a-zA-Z_]+:'), @@ -25,8 +27,12 @@ class TemplateGrammar(Grammar): rules = [ PatternRule(r'escaped', r'&[^;]+;'), RegionRule(r'comment', r''), - RegionRule(r'directive', r'\[\%', DirectiveGrammar, r'%%\]'), - RegionRule(r'tt_tag', r''), + RegionRule(r'comment', r'\[\%#', Grammar, r'%%\]'), + PatternRule(r'tt.data', r'[^\[<&]+'), + RegionRule(r'tt.directive', r'\[\%(?= *PERL)', PerlDirectiveGrammar, + r'%%\]', PerlGrammar, r'\[%%', PerlDirectiveGrammar, '%%\]'), + RegionRule(r'tt.directive', r'\[\%', DirectiveGrammar, r'%%\]'), + RegionRule(r'tt.tag', r''), ] class Template(mode.Fundamental): @@ -34,26 +40,28 @@ class Template(mode.Fundamental): extensions = ['.tt'] grammar = TemplateGrammar colors = { - 'directive.start': ('magenta', 'default', 'bold'), - 'directive.comment': ('red', 'default', 'bold'), - 'directive.keyword': ('yellow', 'default', 'bold'), - 'directive.attribute': ('magenta', 'default', 'bold'), - 'directive.string.start': ('green', 'default', 'bold'), - 'directive.string.escaped': ('magenta', 'default', 'bold'), - 'directive.string.octal': ('magenta', 'default', 'bold'), - 'directive.string.null': ('green', 'default', 'bold'), - 'directive.string.end': ('green', 'default', 'bold'), - 'directive.null': ('magenta', 'default', 'bold'), - 'directive.end': ('magenta', 'default', 'bold'), - - 'tt_tag.start': ('default', 'default', 'bold'), - 'tt_tag.namespace': ('magenta', 'default', 'bold'), - 'tt_tag.name': ('blue', 'default', 'bold'), - 'tt_tag.attrname': ('cyan', 'default', 'bold'), - 'tt_tag.string.start': ('green', 'default', 'bold'), - 'tt_tag.string.null': ('green', 'default', 'bold'), - 'tt_tag.string.end': ('green', 'default', 'bold'), - 'tt_tag.end': ('default', 'default', 'bold'), + 'tt.directive.start': ('magenta', 'default', 'bold'), + 'tt.directive.comment': ('red', 'default', 'bold'), + 'tt.directive.keyword': ('yellow', 'default', 'bold'), + 'tt.directive.attribute': ('magenta', 'default', 'bold'), + 'tt.directive.string.start': ('green', 'default', 'bold'), + 'tt.directive.string.escaped': ('magenta', 'default', 'bold'), + 'tt.directive.string.octal': ('magenta', 'default', 'bold'), + 'tt.directive.string.null': ('green', 'default', 'bold'), + 'tt.directive.string.end': ('green', 'default', 'bold'), + 'tt.directive.null': ('magenta', 'default', 'bold'), + 'tt.directive.middle0': ('magenta', 'default', 'bold'), + 'tt.directive.middle1': ('magenta', 'default', 'bold'), + 'tt.directive.end': ('magenta', 'default', 'bold'), + 'tt.tag.start': ('default', 'default', 'bold'), + 'tt.tag.namespace': ('magenta', 'default', 'bold'), + 'tt.tag.name': ('blue', 'default', 'bold'), + 'tt.tag.attrname': ('cyan', 'default', 'bold'), + 'tt.tag.string.start': ('green', 'default', 'bold'), + 'tt.tag.string.null': ('green', 'default', 'bold'), + 'tt.tag.string.end': ('green', 'default', 'bold'), + 'tt.tag.end': ('default', 'default', 'bold'), + 'tt.perl': ('red', 'default', 'bold'), } _bindings = { 'close-paren': (')',), diff --git a/mode/xml.py b/mode/xml.py index 3b5799d..b0e3738 100644 --- a/mode/xml.py +++ b/mode/xml.py @@ -36,10 +36,13 @@ class XMLGrammar(Grammar): # TODO: how does cdata work again? PatternRule(r'data', r'[^<& \n]+'), PatternRule(r'spaces', r' +'), - RegionRule(r'xml.tag', r'<(?![?!])', TagGrammar, r'/?>'), - RegionRule(r'comment', r''), PatternRule(r'xml.entity', r'&[a-z]+;'), PatternRule(r'eol', r'\n'), + PatternMatchRule('x', r'(<)(/)([a-zA-Z_][a-zA-Z0-9_]*)(>)', + 'xml.tag.start', 'xml.tag.delimiter', 'xml.tag.name', + 'xml.tag.end'), + RegionRule(r'xml.tag', r'<(?![\?!])', TagGrammar, r'/?>'), + RegionRule(r'comment', r''), RegionRule(r'xml.metadata', r'<\?', MetadataGrammar, r'\?>'), RegionRule(r'xml.cdata', r''), ]