Skip to content

Commit 26fcb53

Browse files
committed
I think this will be 0.2 modulo some minor tweaking. Highlight with the
ide-xcode style is a great fit! I think I may have modified the Info.plist file with some new UTIs. The .m extension is overloaded for matlab and objc. I grep for a matlab-style comment in the first 10 lines and assign to objc if it doesn't match. I'm using a customized .style file so I can do a better job with ocaml and objc. In general there aren't enough keyword styles defined by default.
1 parent 23ea6d8 commit 26fcb53

File tree

7 files changed

+205
-10
lines changed

7 files changed

+205
-10
lines changed

Info.plist

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<string>public.xml</string>
1616
<string>com.apple.property-list</string>
1717
<string>org.tug.tex</string>
18+
<string>public.css</string> <!-- Not official, but expected -->
1819
</array>
1920
</dict>
2021
</array>
@@ -230,6 +231,77 @@
230231
</array>
231232
</dict>
232233
</dict>
234+
<dict>
235+
<key>UTTypeIdentifier</key>
236+
<string>org.n8gray.standard-ml-source</string>
237+
<key>UTTypeDescription</key>
238+
<string>Standard ML Source File</string>
239+
<key>UTTypeConformsTo</key>
240+
<array>
241+
<string>public.source-code</string>
242+
</array>
243+
<key>UTTypeTagSpecification</key>
244+
<dict>
245+
<key>public.filename-extension</key>
246+
<array>
247+
<string>sml</string>
248+
</array>
249+
</dict>
250+
</dict>
251+
<dict>
252+
<key>UTTypeIdentifier</key>
253+
<string>org.n8gray.structured-query-language-source</string>
254+
<key>UTTypeDescription</key>
255+
<string>SQL Source File</string>
256+
<key>UTTypeConformsTo</key>
257+
<array>
258+
<string>public.source-code</string>
259+
</array>
260+
<key>UTTypeTagSpecification</key>
261+
<dict>
262+
<key>public.filename-extension</key>
263+
<array>
264+
<string>sql</string>
265+
</array>
266+
</dict>
267+
</dict>
268+
<dict>
269+
<key>UTTypeIdentifier</key>
270+
<string>org.n8gray.diff-script</string>
271+
<key>UTTypeDescription</key>
272+
<string>Diff File</string>
273+
<key>UTTypeConformsTo</key>
274+
<array>
275+
<string>public.script</string>
276+
</array>
277+
<key>UTTypeTagSpecification</key>
278+
<dict>
279+
<key>public.filename-extension</key>
280+
<array>
281+
<string>diff</string>
282+
<string>patch</string>
283+
</array>
284+
</dict>
285+
</dict>
286+
<dict>
287+
<key>UTTypeIdentifier</key>
288+
<string>public.css</string>
289+
<key>UTTypeDescription</key>
290+
<string>CSS File</string>
291+
<key>UTTypeConformsTo</key>
292+
<array>
293+
<!-- On the advice of Julien Jalon at Apple -->
294+
<string>public.source-code</string>
295+
</array>
296+
<key>UTTypeTagSpecification</key>
297+
<dict>
298+
<key>public.filename-extension</key>
299+
<array>
300+
<string>css</string>
301+
</array>
302+
</dict>
303+
</dict>
304+
233305
</array>
234306
</dict>
235307
</plist>

QLColorCode.xcodeproj/project.pbxproj

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
0EB496B10D0FC70D00E86E0B /* ml.lang in Copy .lang Files */ = {isa = PBXBuildFile; fileRef = 0EB4960D0D0FC24000E86E0B /* ml.lang */; };
3232
0EC047970CFBDADF009C986E /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0EC047960CFBDADF009C986E /* Foundation.framework */; };
3333
0ECBBA6C0CFCA37500416538 /* QLColorCode.qlgenerator in Copy to Library */ = {isa = PBXBuildFile; fileRef = 8D576316048677EA00EA77CD /* QLColorCode.qlgenerator */; };
34+
0EF57D440D122791006084D5 /* ide-xcode.style in Copy .style Files */ = {isa = PBXBuildFile; fileRef = 0EF57D430D122791006084D5 /* ide-xcode.style */; };
35+
0EF57D6E0D122934006084D5 /* objc.lang in Copy .lang Files */ = {isa = PBXBuildFile; fileRef = 0EF57D6D0D122934006084D5 /* objc.lang */; };
3436
2C05A19C06CAA52B00D84F6F /* GeneratePreviewForURL.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C05A19B06CAA52B00D84F6F /* GeneratePreviewForURL.m */; };
3537
61E3BCFB0870B4F2002186A0 /* GenerateThumbnailForURL.m in Sources */ = {isa = PBXBuildFile; fileRef = 61E3BCFA0870B4F2002186A0 /* GenerateThumbnailForURL.m */; };
3638
8D576312048677EA00EA77CD /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = 08FB77B6FE84183AC02AAC07 /* main.c */; settings = {ATTRIBUTES = (); }; };
@@ -69,6 +71,7 @@
6971
dstPath = override/langDefs;
7072
dstSubfolderSpec = 7;
7173
files = (
74+
0EF57D6E0D122934006084D5 /* objc.lang in Copy .lang Files */,
7275
0EB496B10D0FC70D00E86E0B /* ml.lang in Copy .lang Files */,
7376
);
7477
name = "Copy .lang Files";
@@ -85,6 +88,17 @@
8588
name = "Copy to Library";
8689
runOnlyForDeploymentPostprocessing = 0;
8790
};
91+
0EF57D6C0D1228E3006084D5 /* Copy .style Files */ = {
92+
isa = PBXCopyFilesBuildPhase;
93+
buildActionMask = 2147483647;
94+
dstPath = override/themes;
95+
dstSubfolderSpec = 7;
96+
files = (
97+
0EF57D440D122791006084D5 /* ide-xcode.style in Copy .style Files */,
98+
);
99+
name = "Copy .style Files";
100+
runOnlyForDeploymentPostprocessing = 0;
101+
};
88102
/* End PBXCopyFilesBuildPhase section */
89103

90104
/* Begin PBXFileReference section */
@@ -102,6 +116,8 @@
102116
0EC047F20CFC000A009C986E /* Notes.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Notes.txt; sourceTree = "<group>"; };
103117
0ECBBB360CFCF98600416538 /* ReadMe.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ReadMe.txt; sourceTree = "<group>"; };
104118
0ECBBB5D0CFD447E00416538 /* colorize.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = colorize.sh; sourceTree = "<group>"; };
119+
0EF57D430D122791006084D5 /* ide-xcode.style */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "ide-xcode.style"; sourceTree = "<group>"; };
120+
0EF57D6D0D122934006084D5 /* objc.lang */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = objc.lang; sourceTree = "<group>"; };
105121
2C05A19B06CAA52B00D84F6F /* GeneratePreviewForURL.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratePreviewForURL.m; sourceTree = "<group>"; };
106122
61E3BCFA0870B4F2002186A0 /* GenerateThumbnailForURL.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = GenerateThumbnailForURL.m; sourceTree = "<group>"; };
107123
8D576316048677EA00EA77CD /* QLColorCode.qlgenerator */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = QLColorCode.qlgenerator; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -160,8 +176,10 @@
160176
089C167CFE841241C02AAC07 /* Resources */ = {
161177
isa = PBXGroup;
162178
children = (
163-
0E913A090D10B8060067BAD6 /* filetypes.conf */,
179+
0EF57D6D0D122934006084D5 /* objc.lang */,
164180
0EB4960D0D0FC24000E86E0B /* ml.lang */,
181+
0EF57D430D122791006084D5 /* ide-xcode.style */,
182+
0E913A090D10B8060067BAD6 /* filetypes.conf */,
165183
8D576317048677EA00EA77CD /* Info.plist */,
166184
8D5B49A704867FD3000E48DA /* InfoPlist.strings */,
167185
);
@@ -212,6 +230,7 @@
212230
8D576311048677EA00EA77CD /* Sources */,
213231
8D576313048677EA00EA77CD /* Frameworks */,
214232
0EB496B00D0FC68300E86E0B /* Copy .lang Files */,
233+
0EF57D6C0D1228E3006084D5 /* Copy .style Files */,
215234
0E913A110D10B84D0067BAD6 /* Copy .conf Files */,
216235
0E9139D70D10A8320067BAD6 /* Install highlight */,
217236
0ECBBA6F0CFCA39E00416538 /* Copy to Library */,

colorize.sh

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,35 @@
1414
#
1515
# Produces HTML on stdout with exit code 0 on success
1616

17+
# You can customize the appearance by changing these parameters:
18+
# Installed themes: acid, bipolar, blacknblue, bright, contrast, darkblue,
19+
# darkness, desert, easter, emacs, golden, greenlcd, ide-anjuta,
20+
# ide-codewarrior, ide-devcpp, ide-eclipse, ide-kdev, ide-msvcpp, ide-xcode,
21+
# kwrite, lucretia, matlab, moe, navy, nedit, neon, night, orion, pablo,
22+
# peachpuff, print, rand01, seashell, the, typical, vampire, vim-dark, vim,
23+
# whitengrey, zellner
24+
theme=ide-xcode
25+
font=Monaco
26+
fontSizePoints=9
27+
28+
###############################################################################
29+
1730
# Fail immediately on failure of sub-command
1831
setopt err_exit
1932

2033
rsrcDir=$1
2134
target=$2
2235
thumb=$3
2336

24-
thumblines=50
25-
font=Monaco
26-
2737
hlDir=$rsrcDir/highlight
2838
cmd=$hlDir/bin/highlight
2939
cmdOpts=(-I --font $font --quiet --add-data-dir $rsrcDir/override \
30-
--data-dir $rsrcDir/highlight/share/highlight)
40+
--data-dir $rsrcDir/highlight/share/highlight --style $theme \
41+
--font-size $fontSizePoints)
3142

3243
reader=(cat $target)
3344
if [ $thumb = "1" ]; then
34-
filter=(head -n $thumblines)
45+
filter=(head -n 50)
3546
else
3647
filter=cat
3748
fi
@@ -41,7 +52,25 @@ case $target in
4152
lang=xml
4253
reader=(/usr/bin/plutil -convert xml1 -o - $target)
4354
;;
44-
* ) lang=${target##*.}
55+
*.h )
56+
if grep -q "@interface" $target &> /dev/null; then
57+
lang=objc
58+
else
59+
lang=h
60+
fi
61+
;;
62+
*.m )
63+
# look for a matlab-style comment in the first 10 lines, otherwise
64+
# assume objective-c. If you never use matlab or never use objc,
65+
# you might want to hardwire this one way or the other
66+
if head -n 10 $target | grep -q "^ *%" &> /dev/null; then
67+
lang=m
68+
else
69+
lang=objc
70+
fi
71+
;;
72+
* )
73+
lang=${target##*.}
4574
;;
4675
esac
4776

filetypes.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ $ext(mib)=smi
4141
$ext(progress)=p i w
4242
$ext(bat)=cmd
4343
$ext(diff)=patch
44-
$ext(m)=mm
44+
$ext(objc)=mm
4545

4646
# Input file recognition
4747
# Highlight matches the first input line with the listed expressions.

ide-xcode.style

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# xcode.style
2+
# This File is part of highlight, a universal source code converter.
3+
# See README in the highlight directory for documentation.
4+
5+
$DEFAULTCOLOUR=00 00 00
6+
$BGCOLOUR=ff ff ff
7+
$FONTSIZE=11
8+
$KW-GROUP(kwa)=8f 00 55
9+
$KW-GROUP(kwb)=8f 00 55
10+
$KW-GROUP(kwc)=8f 00 55
11+
$KW-GROUP(kwd)=00 55 55
12+
$KW-GROUP(callr)=00 09 88
13+
$NUMBER=23 00 ff
14+
$STRING=c0 00 00
15+
$KW-GROUP(str)=c0 00 00
16+
$ESCAPECHAR=73 37 10
17+
$COMMENT=00 7f 1c
18+
$DIRECTIVE=73 37 10
19+
# for the string in: #include "foo"
20+
$STRING-DIRECTIVE=85 00 55
21+
$LINE=80 80 80
22+
$SYMBOL=00 00 00
23+
$MARK-LINE=ff ff bb

ml.lang

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ object of open or private rec sig struct then to true try type val virtual when
2222
while with
2323

2424
# Types and type variables
25-
$KW_LIST(kwb)=bool string int real word float unit option ref
25+
$KW_LIST(kwb)=int float string char bool list exn array option format fpclass in_channel out_channel open_flag ref unit
2626
$KW_RE(kwb)=regex('[a-zA-Z0-9_']+)
2727

2828
# Modules
29-
$KW_RE(kwc)=regex(\b[A-Z][a-zA-Z0-9_']*(?=\.))
29+
$KW_RE(callr)=regex(\b[A-Z][a-zA-Z0-9_']*(?=\.))
3030

3131
# Constructors
3232
$KW_RE(kwd)=regex(\b[A-Z][a-zA-Z0-9_']*)

objc.lang

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Objective C language definition file
2+
#
3+
# Author: Andr�Simon
4+
# Mail: andre.simon1@gmx.de
5+
# Date: 08.02.04
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)=goto break return continue asm case default if else switch while for do sizeof typeof
19+
typedef inline stdcall auto cdecl class const_cast delete dynamic_cast explicit
20+
extern friend goto inline mutable namespace new operator pascal register reinterpret_cast private
21+
protected public static_cast template this throw try catch typeid using virtual volatile true false
22+
id Class SEL IMP BOOL oneway in out inout bycopy byref self super nil NIL TRUE FALSE
23+
24+
$KW_LIST(kwb)=int long short char void signed unsigned float double size_t wchar_t ptrdiff_t
25+
sig_atomic_t fpos_t clock_t time_t va_list jmp_buf FILE DIR div_t ldiv_t static register auto
26+
volatile extern const bool struct union enum
27+
28+
#$KW_PREFIX(kwa)=@
29+
30+
$KW_RE(kwa)=regex(@\w+)
31+
32+
$KW_RE(kwd)=regex((\w+?)\s*\()
33+
34+
$KW_RE(callr)=regex((?<=\[)\w+)
35+
36+
$KW_RE(str)=regex(@(?="))
37+
38+
$STRINGDELIMITERS=" '
39+
40+
$SL_COMMENT=//
41+
42+
$ML_COMMENT=/* */
43+
44+
$ALLOWNESTEDCOMMENTS=false
45+
46+
$IGNORECASE=false
47+
48+
$DIRECTIVE=#
49+
50+
$ESCCHAR=\
51+
52+
$SYMBOLS= ( ) [ ] { } , ; : & | < > ! = / * % + -

0 commit comments

Comments
 (0)