Skip to content

Commit 567b016

Browse files
committed
Added some language overrides.
Make sure to compile highlight as a UB.
1 parent aeea723 commit 567b016

File tree

13 files changed

+243
-15
lines changed

13 files changed

+243
-15
lines changed

ChangeLog.txt

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1+
0.3: (In progress)
2+
* Ensure highlight is compiled as a universal binary
3+
* Added .command as an alternate extension for shell scripts
4+
* Added .mll and .mly extensions for OCaml
5+
* Include customized .css and .c language definition files
6+
* Created a slateGreen theme that matches my editor colors. :-)
7+
*
8+
19
0.2:
2-
- Switched from Pygments to Highlight
3-
- Added thumbnailing support
4-
- Changed .tex UTI to agree with TeXShop's.
5-
- (Try to) let the system pick a different plugin if ours fails
6-
- Added UTIs for .css, .sql, .erl, and .sml
10+
* Switched from Pygments to Highlight. This should increase speed *and* language coverage.
11+
* Added thumbnailing support
12+
* Changed .tex UTI to agree with TeXShop's.
13+
* (Try to) let the system pick a different plugin if ours fails
14+
* Added UTIs for .css, .sql, .erl, and .sml
715

816
0.1: Initial release

GenerateThumbnailForURL.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
This function's job is to create thumbnail for designated file as fast as possible
1313
----------------------------------------------------------------------------- */
1414

15-
OSStatus GenerateThumbnailForURL(void *thisInterface,
15+
OSStatus
16+
GenerateThumbnailForURL(void *thisInterface,
1617
QLThumbnailRequestRef thumbnail,
1718
CFURLRef url,
1819
CFStringRef contentTypeUTI,

Info.plist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@
9393
<key>public.filename-extension</key>
9494
<array>
9595
<string>ml</string>
96+
<string>mll</string>
97+
<string>mly</string>
9698
</array>
9799
</dict>
98100
</dict>

QLColorCode.xcodeproj/project.pbxproj

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
0ECBBA6C0CFCA37500416538 /* QLColorCode.qlgenerator in Copy to Library */ = {isa = PBXBuildFile; fileRef = 8D576316048677EA00EA77CD /* QLColorCode.qlgenerator */; };
3434
0EF57D440D122791006084D5 /* ide-xcode.style in Copy .style Files */ = {isa = PBXBuildFile; fileRef = 0EF57D430D122791006084D5 /* ide-xcode.style */; };
3535
0EF57D6E0D122934006084D5 /* objc.lang in Copy .lang Files */ = {isa = PBXBuildFile; fileRef = 0EF57D6D0D122934006084D5 /* objc.lang */; };
36+
0EF57E6A0D125AB2006084D5 /* slateGreen.style in Copy .style Files */ = {isa = PBXBuildFile; fileRef = 0EF57E690D125AB2006084D5 /* slateGreen.style */; };
37+
0EF57F2F0D128219006084D5 /* c.lang in Copy .lang Files */ = {isa = PBXBuildFile; fileRef = 0EF57F2E0D128219006084D5 /* c.lang */; };
38+
0EF57F960D133EF7006084D5 /* css.lang in Copy .lang Files */ = {isa = PBXBuildFile; fileRef = 0EF57F7D0D133C0F006084D5 /* css.lang */; };
3639
2C05A19C06CAA52B00D84F6F /* GeneratePreviewForURL.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C05A19B06CAA52B00D84F6F /* GeneratePreviewForURL.m */; };
3740
61E3BCFB0870B4F2002186A0 /* GenerateThumbnailForURL.m in Sources */ = {isa = PBXBuildFile; fileRef = 61E3BCFA0870B4F2002186A0 /* GenerateThumbnailForURL.m */; };
3841
8D576312048677EA00EA77CD /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = 08FB77B6FE84183AC02AAC07 /* main.c */; settings = {ATTRIBUTES = (); }; };
@@ -71,6 +74,8 @@
7174
dstPath = override/langDefs;
7275
dstSubfolderSpec = 7;
7376
files = (
77+
0EF57F960D133EF7006084D5 /* css.lang in Copy .lang Files */,
78+
0EF57F2F0D128219006084D5 /* c.lang in Copy .lang Files */,
7479
0EF57D6E0D122934006084D5 /* objc.lang in Copy .lang Files */,
7580
0EB496B10D0FC70D00E86E0B /* ml.lang in Copy .lang Files */,
7681
);
@@ -94,6 +99,7 @@
9499
dstPath = override/themes;
95100
dstSubfolderSpec = 7;
96101
files = (
102+
0EF57E6A0D125AB2006084D5 /* slateGreen.style in Copy .style Files */,
97103
0EF57D440D122791006084D5 /* ide-xcode.style in Copy .style Files */,
98104
);
99105
name = "Copy .style Files";
@@ -118,6 +124,10 @@
118124
0ECBBB5D0CFD447E00416538 /* colorize.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = colorize.sh; sourceTree = "<group>"; };
119125
0EF57D430D122791006084D5 /* ide-xcode.style */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "ide-xcode.style"; sourceTree = "<group>"; };
120126
0EF57D6D0D122934006084D5 /* objc.lang */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = objc.lang; sourceTree = "<group>"; };
127+
0EF57E4D0D123DD0006084D5 /* LICENSE.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE.txt; sourceTree = "<group>"; };
128+
0EF57E690D125AB2006084D5 /* slateGreen.style */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = slateGreen.style; sourceTree = "<group>"; };
129+
0EF57F2E0D128219006084D5 /* c.lang */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = c.lang; sourceTree = "<group>"; };
130+
0EF57F7D0D133C0F006084D5 /* css.lang */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = css.lang; sourceTree = "<group>"; };
121131
2C05A19B06CAA52B00D84F6F /* GeneratePreviewForURL.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratePreviewForURL.m; sourceTree = "<group>"; };
122132
61E3BCFA0870B4F2002186A0 /* GenerateThumbnailForURL.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = GenerateThumbnailForURL.m; sourceTree = "<group>"; };
123133
8D576316048677EA00EA77CD /* QLColorCode.qlgenerator */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = QLColorCode.qlgenerator; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -151,6 +161,7 @@
151161
0EC047F20CFC000A009C986E /* Notes.txt */,
152162
0ECBBB360CFCF98600416538 /* ReadMe.txt */,
153163
0E51C65F0D04E492007853CB /* ChangeLog.txt */,
164+
0EF57E4D0D123DD0006084D5 /* LICENSE.txt */,
154165
08FB77AFFE84173DC02AAC07 /* Source */,
155166
089C167CFE841241C02AAC07 /* Resources */,
156167
089C1671FE841209C02AAC07 /* External Frameworks and Libraries */,
@@ -176,9 +187,12 @@
176187
089C167CFE841241C02AAC07 /* Resources */ = {
177188
isa = PBXGroup;
178189
children = (
190+
0EF57F2E0D128219006084D5 /* c.lang */,
191+
0EF57F7D0D133C0F006084D5 /* css.lang */,
179192
0EF57D6D0D122934006084D5 /* objc.lang */,
180193
0EB4960D0D0FC24000E86E0B /* ml.lang */,
181194
0EF57D430D122791006084D5 /* ide-xcode.style */,
195+
0EF57E690D125AB2006084D5 /* slateGreen.style */,
182196
0E913A090D10B8060067BAD6 /* filetypes.conf */,
183197
8D576317048677EA00EA77CD /* Info.plist */,
184198
8D5B49A704867FD3000E48DA /* InfoPlist.strings */,
@@ -287,7 +301,7 @@
287301
);
288302
runOnlyForDeploymentPostprocessing = 0;
289303
shellPath = "/bin/zsh -x";
290-
shellScript = "# shell script goes here\nif [ $BUILD_STYLE != \"Release\" ]; then\n echo \"Error: Must use Release build style\"\n exit 1\nfi\n\ncd $PROJECT_DIR\nmkdir -vp release\ncd release\npkgDir=QLColorCode-$CURRENT_PROJECT_VERSION\nrm -rf $pkgDir\nmkdir $pkgDir\ncp -rp $TARGET_BUILD_DIR/*.qlgenerator $pkgDir\ncp ../ReadMe.txt $pkgDir\ncp ../LICENSE.txt $pkgDir\ntar cvzf $pkgDir.tgz $pkgDir";
304+
shellScript = "# shell script goes here\nif [ $BUILD_STYLE != \"Release\" ]; then\n echo \"Error: Must use Release build style\"\n exit 1\nfi\n\ncd $PROJECT_DIR\nmkdir -vp release\ncd release\npkgDir=QLColorCode-$CURRENT_PROJECT_VERSION\nrm -rf $pkgDir\nmkdir $pkgDir\ncp -rp $TARGET_BUILD_DIR/*.qlgenerator $pkgDir\ncp ../ReadMe.txt $pkgDir\ncp ../LICENSE.txt $pkgDir\ncp ../ChangeLog.txt $pkgDir\ntar cvzf $pkgDir.tgz $pkgDir";
291305
};
292306
0E9139D70D10A8320067BAD6 /* Install highlight */ = {
293307
isa = PBXShellScriptBuildPhase;
@@ -300,8 +314,8 @@
300314
outputPaths = (
301315
);
302316
runOnlyForDeploymentPostprocessing = 0;
303-
shellPath = /bin/zsh;
304-
shellScript = "set err_exit\ncd $PROJECT_DIR/highlight\nmake\nmake \\\n\tDESTDIR=$BUILT_PRODUCTS_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH \\\n\tPREFIX=/highlight/ \\\n\tinstall";
317+
shellPath = "/bin/zsh -x";
318+
shellScript = "set err_exit\ncd $PROJECT_DIR/highlight\nexport CFLAGS='-arch i386 -arch ppc'\nexport LDFLAGS=$CFLAGS\nmake\n# Make sure it was built universal\nlipo -info src/highlight | grep -q ppc || exit 1\nlipo -info src/highlight | grep -q i386 || exit 1\nmake \\\n\tDESTDIR=$BUILT_PRODUCTS_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH \\\n\tPREFIX=/highlight/ \\\n\tinstall\n\n";
305319
showEnvVarsInLog = 0;
306320
};
307321
/* End PBXShellScriptBuildPhase section */

c.lang

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# C and C++ language definition file
2+
#
3+
# Author: Andre Simon
4+
# Mail: andre.simon1@gmx.de
5+
# Date: 24.7.2002
6+
# updated 12.1.04 to add more types (ansi c, iso 99)
7+
# ------------------------------------------
8+
# This file is a part of highlight, a free source code converter released under the GPL.
9+
#
10+
# The file is used to describe keywords and special symbols of programming languages.
11+
# See README in the highlight directory for details.
12+
#
13+
# New definition files for future releases of highlight are always appreciated ;)
14+
#
15+
# ----------
16+
# andre.simon1@gmx.de
17+
# http:/www.andre-simon.de/
18+
19+
$DESCRIPTION=C and C++
20+
21+
$KW_LIST(kwa)=goto break return continue asm case default if else switch while for do sizeof
22+
typeof stdcall cdecl const_cast delete dynamic_cast goto namespace new pascal
23+
reinterpret_cast static_cast this throw try catch using true false bitand and bitor or xor
24+
compl and_eq or_eq xor_eq not not_eq
25+
26+
$KW_LIST(kwb)=int long short char void signed unsigned float double size_t wchar_t
27+
ptrdiff_t sig_atomic_t fpos_t clock_t time_t va_list jmp_buf FILE DIR div_t ldiv_t static
28+
const bool struct union enum size_t wchar_t ptrdiff_t sig_atomic_t fpos_t clock_t time_t
29+
va_list jmp_buf FILE DIR div_t ldiv_t mbstate_t wctrans_t wint_t wctype_t bool complex
30+
int8_t int16_t int32_t int64_t uint8_t uint16_t uint32_t uint64_t int_least8_t int_least16_t
31+
int_least32_t int_least64_t uint_least8_t uint_least16_t uint_least32_t uint_least64_t
32+
int_fast8_t int_fast16_t int_fast32_t int_fast64_t uint_fast8_t uint_fast16_t uint_fast32_t
33+
uint_fast64_t intptr_t uintptr_t intmax_t uintmax_t
34+
35+
$KW_LIST(kwc)=typedef inline auto class explicit extern friend inline mutable operator
36+
register template private protected public typeid virtual volatile
37+
38+
$KW_RE(kwd)=regex((\w+?)\s*\()
39+
40+
$KW_RE(fndef)=regex(^(?!typedef)[_a-zA-Z][*\w\t ]*(?:\n|[ \t])?[ \t]*[_a-zA-Z]\w*[ \t]*(?=\((?!\s*\*)))
41+
42+
$STRINGDELIMITERS=" '
43+
44+
$SL_COMMENT=//
45+
46+
$ML_COMMENT=/* */
47+
48+
$ALLOWNESTEDCOMMENTS=false
49+
50+
$IGNORECASE=false
51+
52+
$DIRECTIVE=#
53+
54+
$ESCCHAR=\
55+
56+
$SYMBOLS= ( ) [ ] { } , ; . : & | < > ! = / * % + - ~
57+
58+
$CONTINUATIONSYMBOL=\
59+
60+
$REFORMATTING=true

colorize.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
theme=ide-xcode
2525
font=Monaco
2626
fontSizePoints=9
27+
#theme=slateGreen
28+
#font=fixed
29+
# For some reason 10 points gives me Fixed at 13 points.
30+
#fontSizePoints=10
2731

2832
###############################################################################
2933

@@ -42,7 +46,7 @@ cmdOpts=(-I --font $font --quiet --add-data-dir $rsrcDir/override \
4246

4347
reader=(cat $target)
4448
if [ $thumb = "1" ]; then
45-
filter=(head -n 50)
49+
filter=(head -n 100)
4650
else
4751
filter=cat
4852
fi

css.lang

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
## CSS language definition file
2+
#
3+
# Author: Andre Simon
4+
# Mail: andre.simon1@gmx.de
5+
# Date: 04.03.2003
6+
# ------------------------------------------
7+
# This file is a part of highlight, a free source code converter released under the GPL.
8+
#
9+
# The file is used to describe keywords and special symbols of programming languages.
10+
# See README in the highlight directory for details.
11+
#
12+
# New definition files for future releases of highlight are always appreciated ;)
13+
#
14+
# ----------
15+
# andre.simon1@gmx.de
16+
# http:/www.andre-simon.de/
17+
18+
$KW_LIST(kwa)=background background-attachment background-color background-image
19+
background-position background-repeat border border-bottom border-bottom-width
20+
border-color border-left border-left-width border-right border-right-width
21+
border-style border-top border-top-width border-width clear color display float
22+
font font-family font-size font-style font-variant font-weight height
23+
letter-spacing line-height list-style list-style-image list-style-position
24+
list-style-type margin margin-bottom margin-left margin-right margin-top padding
25+
padding-bottom padding-left padding-right padding-top text-align text-decoration
26+
text-indent text-transform vertical-align white-space width word-spacing aqua auto
27+
baseline black blink block blue bold bolder both bottom capitalize center circle
28+
cursive dashed decimal disc dotted double fantasy fixed fuchsia gray green groove
29+
inline inset inside italic justify large larger left lighter lime line-through
30+
list-item lower-alpha lower-roman lowercase maroon medium middle monospace navy
31+
no-repeat none normal nowrap oblique olive outset outside overline purple red
32+
repeat repeat-x repeat-y rgb ridge right sans-serif scroll serif silver small
33+
small-caps smaller solid square sub super teal text-bottom text-top thick thin top
34+
transparent underline upper-alpha upper-roman uppercase url white x-large x-small
35+
xx-large xx-small yellow
36+
37+
$KW_LIST(kwb)= a abbr acronym address applet area b base
38+
basefont bdo big blockquote body br button caption
39+
center cite code col colgroup dd del dfn
40+
dir div dl dt em fieldset font form
41+
frame frameset h1 h2 h3 h4 h5 h6 head hr html i iframe
42+
img input ins isindex kbd label legend li
43+
link map menu meta noframes noscript object ol
44+
optgroup option p param pre q s samp
45+
script select small span strike strong style sub
46+
sup table tbody td textarea tfoot th thead
47+
title tr tt u ul var
48+
49+
$KW_RE(kwc)=regex(\.[a-zA-Z_]\w*)
50+
51+
# Try to match class identifiers like "#foo" but not colors like "#fff". This
52+
# is quite problematic and unreliable, since we have to be context independent.
53+
$KW_RE(kwd)=regex(#(?![a-fA-F](?:[0-9a-fA-F]{2}|[0-9a-fA-F]{5})[^0-9a-fA-F])[a-zA-Z_]\w*)
54+
55+
$DIGIT=regex(#[0-9a-fA-F]{3}|#[0-9a-fA-F]{6}|\d*[\.]?\d+(?:[eE][\-\+]\d+)?)
56+
57+
$STRINGDELIMITERS="
58+
59+
$ML_COMMENT=/* */
60+
61+
$IGNORECASE=true
62+
63+
$IDENTIFIER=regex([a-zA-Z_][\w\-]*)
64+
65+
$SYMBOLS= ( ) [ ] { } , ; : & | < > ! = / * % + -

filetypes.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ $ext(vb)=bas basic bi vbs
1919
$ext(pl)=perl cgi pm plx plex
2020
$ext(rb)=ruby
2121
$ext(cob)=cobol
22-
$ext(sh)=bash
22+
$ext(sh)=bash command
2323
$ext(f77)=f F for ftn
2424
$ext(f90)=f95
2525
$ext(xml)=html htm xhtml sgm sgml nrm ent hdr hub dtd wml vxml wml tld svg xsl

ml.lang

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
# andre.simon1@gmx.de
1616
# http:/www.andre-simon.de/
1717

18+
# Character literals
19+
$KW_RE(str)=regex('(?:[^\\]|\\.|\\[a-fA-F0-9]{2,3})')
20+
1821
$KW_LIST(kwa)=and as assert asr begin class constraint do done downto else
1922
end exception external false for fun function functor if in include inherit
2023
initializer land lazy let lor lsl lsr lxor match method mod module mutable new
@@ -23,13 +26,13 @@ while with
2326

2427
# Types and type variables
2528
$KW_LIST(kwb)=int float string char bool list exn array option format fpclass in_channel out_channel open_flag ref unit
26-
$KW_RE(kwb)=regex('[a-zA-Z0-9_']+)
29+
$KW_RE(kwb)=regex('[a-zA-Z_]+|\b[A-Z][a-zA-Z0-9_']*)
2730

2831
# Modules
2932
$KW_RE(callr)=regex(\b[A-Z][a-zA-Z0-9_']*(?=\.))
3033

31-
# Constructors
32-
$KW_RE(kwd)=regex(\b[A-Z][a-zA-Z0-9_']*)
34+
# Function defs
35+
$KW_RE(fndef)=regex(let([ \t]+rec)?[ \t]+([a-z][\w']*)[ \t]+[^=:,])
3336

3437
$STRINGDELIMITERS="
3538

objc.lang

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# andre.simon1@gmx.de
1616
# http:/www.andre-simon.de/
1717

18+
#### REMEMBER: \s includes \n!
19+
1820
$KW_LIST(kwa)=goto break return continue asm case default if else switch while for do sizeof typeof
1921
typedef inline stdcall auto cdecl class const_cast delete dynamic_cast explicit
2022
extern friend goto inline mutable namespace new operator pascal register reinterpret_cast private
@@ -29,9 +31,13 @@ volatile extern const bool struct union enum
2931

3032
$KW_RE(kwa)=regex(@\w+)
3133

34+
$KW_RE(fndef)=regex(^(?!typedef)[_a-zA-Z][*\w\t ]*(?:\n|[ \t])?[ \t]*[_a-zA-Z]\w*[ \t]*(?=\((?!\s*\*)))
35+
3236
$KW_RE(kwd)=regex((\w+?)\s*\()
3337

34-
$KW_RE(callr)=regex((?<=\[)\w+)
38+
# A method call target is any identifier inside an open bracket followed by
39+
# another identifier
40+
$KW_RE(callr)=regex((?<=\[)\s*\w+(?=\s+[_a-zA-Z]))
3541

3642
$KW_RE(str)=regex(@(?="))
3743

0 commit comments

Comments
 (0)