├── SourcePreview
├── installer
│ ├── scripts
│ │ └── postinstall
│ ├── compiled
│ │ └── SourcePreview-1.0.1.pkg
│ ├── files
│ │ └── SourcePreview.qlgenerator
│ │ │ └── Contents
│ │ │ ├── MacOS
│ │ │ └── SourcePreview
│ │ │ ├── Resources
│ │ │ ├── swift_logo.png
│ │ │ ├── prism.css
│ │ │ ├── page.html
│ │ │ └── prism.js
│ │ │ ├── Info.plist
│ │ │ └── _CodeSignature
│ │ │ └── CodeResources
│ └── build.sh
├── bin
│ └── qlmanage
├── assets
│ ├── swift_logo.png
│ └── page.html
├── screenshots
│ ├── preview.png
│ └── thumbnail.png
├── Regurgitator.h
├── GeneratePreviewForURL.m
├── Info.plist
├── GenerateThumbnailForURL.m
├── prism
│ ├── styles
│ │ └── prism.css
│ └── prism.js
├── Regurgitator.m
└── main.c
├── SourcePreview.xcodeproj
├── project.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcshareddata
│ │ └── IDEWorkspaceChecks.plist
├── xcshareddata
│ └── xcschemes
│ │ └── ql-swift.xcscheme
└── project.pbxproj
├── .travis.yml
├── .gitignore
├── LICENSE
└── README.md
/SourcePreview/installer/scripts/postinstall:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | /usr/bin/qlmanage -r
4 |
--------------------------------------------------------------------------------
/SourcePreview/bin/qlmanage:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tsif/SourcePreview/HEAD/SourcePreview/bin/qlmanage
--------------------------------------------------------------------------------
/SourcePreview/assets/swift_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tsif/SourcePreview/HEAD/SourcePreview/assets/swift_logo.png
--------------------------------------------------------------------------------
/SourcePreview/screenshots/preview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tsif/SourcePreview/HEAD/SourcePreview/screenshots/preview.png
--------------------------------------------------------------------------------
/SourcePreview/screenshots/thumbnail.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tsif/SourcePreview/HEAD/SourcePreview/screenshots/thumbnail.png
--------------------------------------------------------------------------------
/SourcePreview/installer/compiled/SourcePreview-1.0.1.pkg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tsif/SourcePreview/HEAD/SourcePreview/installer/compiled/SourcePreview-1.0.1.pkg
--------------------------------------------------------------------------------
/SourcePreview/installer/files/SourcePreview.qlgenerator/Contents/MacOS/SourcePreview:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tsif/SourcePreview/HEAD/SourcePreview/installer/files/SourcePreview.qlgenerator/Contents/MacOS/SourcePreview
--------------------------------------------------------------------------------
/SourcePreview/installer/files/SourcePreview.qlgenerator/Contents/Resources/swift_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tsif/SourcePreview/HEAD/SourcePreview/installer/files/SourcePreview.qlgenerator/Contents/Resources/swift_logo.png
--------------------------------------------------------------------------------
/SourcePreview.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | os: osx
2 | osx_image: xcode9.3
3 | xcode_scheme: SwiftPreview
4 | xcode_project: SourcePreview
5 | language: objective-c
6 | branches:
7 | only:
8 | - master
9 | notifications:
10 | on_success: never
11 | script:
12 | - xcodebuild -quiet clean -project SourcePreview.xcodeproj -scheme SourcePreview build
--------------------------------------------------------------------------------
/SourcePreview.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/SourcePreview/Regurgitator.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Regurgitator.h
3 | */
4 |
5 | #ifndef Regurgitator_h
6 | #define Regurgitator_h
7 |
8 | #import
9 | #import
10 |
11 | NSImage *imageTintedWithColor(NSImage *original, NSColor *tint);
12 | NSString *imageToNSString(NSImage *image);
13 | NSString *regurgitateHTML(NSURL* url);
14 | NSData *regurgitateHTMLData(NSURL* url);
15 |
16 | #endif /* Regurgitator_h */
17 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Xcode
2 | #
3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
4 |
5 | ## Build generated
6 | build/
7 | DerivedData/
8 |
9 | ## Various settings
10 | *.pbxuser
11 | !default.pbxuser
12 | *.mode1v3
13 | !default.mode1v3
14 | *.mode2v3
15 | !default.mode2v3
16 | *.perspectivev3
17 | !default.perspectivev3
18 | xcuserdata/
19 |
20 | ## Other
21 | *.moved-aside
22 | *.xccheckout
23 | *.xcscmblueprint
24 |
--------------------------------------------------------------------------------
/SourcePreview/installer/build.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Name of the package
4 | NAME="SourcePreview"
5 |
6 | # Once installed the identifier is used as the filename for a receipt files in /var/db/receipts/
7 | IDENTIFIER="tsif.$NAME"
8 |
9 | # Package version number
10 | VERSION="1.0.1"
11 |
12 | # The location to copy the contents of files
13 | INSTALL_LOCATION="$HOME/Library/QuickLook/"
14 |
15 | FILES_DIR="./files"
16 | SCRIPTS_DIR="./scripts"
17 | COMPILED_DIR="./compiled"
18 |
19 | # Remove any unwanted .DS_Store files
20 | find "$FILES_DIR/" -name '*.DS_Store' -type f -delete
21 |
22 | # Set full read, write, execute permissions for owner and just read and execute permissions for group and other
23 | /bin/chmod -R 755 "$FILES_DIR/"
24 |
25 | # Remove any extended attributes (ACEs)
26 | /usr/bin/xattr -rc "$FILES_DIR/"
27 |
28 | # Build package
29 | /usr/bin/pkgbuild \
30 | --root "$FILES_DIR/" \
31 | --install-location "$INSTALL_LOCATION" \
32 | --scripts "$SCRIPTS_DIR/" \
33 | --identifier "$IDENTIFIER" \
34 | --version "$VERSION" \
35 | "$COMPILED_DIR/$NAME-$VERSION.pkg"
36 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 tsif
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/SourcePreview/GeneratePreviewForURL.m:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | #include "Regurgitator.h"
6 |
7 | OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options);
8 | void CancelPreviewGeneration(void *thisInterface, QLPreviewRequestRef preview);
9 |
10 | /* -----------------------------------------------------------------------------
11 | Generate a preview for file
12 |
13 | This function's job is to create preview for designated file
14 | ----------------------------------------------------------------------------- */
15 |
16 | OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options)
17 | {
18 | CFDataRef data = (__bridge CFDataRef) regurgitateHTMLData((__bridge NSURL*) url);
19 |
20 | if (data)
21 | {
22 | CFDictionaryRef props = (__bridge CFDictionaryRef) [NSDictionary dictionary];
23 | QLPreviewRequestSetDataRepresentation(preview, data, kUTTypeHTML, props);
24 | }
25 |
26 | return noErr;
27 | }
28 |
29 | void CancelPreviewGeneration(void *thisInterface, QLPreviewRequestRef preview)
30 | {
31 | // Implement only if supported
32 | }
33 |
--------------------------------------------------------------------------------
/SourcePreview/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDocumentTypes
8 |
9 |
10 | CFBundleTypeRole
11 | QLGenerator
12 | LSItemContentTypes
13 |
14 | public.swift-source
15 |
16 |
17 |
18 | CFBundleExecutable
19 | $(EXECUTABLE_NAME)
20 | CFBundleIdentifier
21 | $(PRODUCT_BUNDLE_IDENTIFIER)
22 | CFBundleInfoDictionaryVersion
23 | 6.0
24 | CFBundleName
25 | $(PRODUCT_NAME)
26 | CFBundleShortVersionString
27 | 1.0
28 | CFBundleVersion
29 | 1
30 | CFPlugInDynamicRegisterFunction
31 |
32 | CFPlugInDynamicRegistration
33 | NO
34 | CFPlugInFactories
35 |
36 | C3F3DA17-8E49-4B7F-9581-EC35FD86C4BB
37 | QuickLookGeneratorPluginFactory
38 |
39 | CFPlugInTypes
40 |
41 | 5E2D9680-5022-40FA-B806-43349622E5B9
42 |
43 | C3F3DA17-8E49-4B7F-9581-EC35FD86C4BB
44 |
45 |
46 | CFPlugInUnloadFunction
47 |
48 | NSHumanReadableCopyright
49 | Copyright © 2017 tsif. All rights reserved.
50 | QLNeedsToBeRunInMainThread
51 |
52 | QLPreviewHeight
53 | 600
54 | QLPreviewWidth
55 | 800
56 | QLSupportsConcurrentRequests
57 |
58 | QLThumbnailMinimumSize
59 | 17
60 |
61 |
62 |
--------------------------------------------------------------------------------
/SourcePreview/installer/files/SourcePreview.qlgenerator/Contents/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | BuildMachineOSBuild
6 | 17E199
7 | CFBundleDevelopmentRegion
8 | en
9 | CFBundleDocumentTypes
10 |
11 |
12 | CFBundleTypeRole
13 | QLGenerator
14 | LSItemContentTypes
15 |
16 | public.swift-source
17 |
18 |
19 |
20 | CFBundleExecutable
21 | SourcePreview
22 | CFBundleIdentifier
23 | tsif.swift-preview
24 | CFBundleInfoDictionaryVersion
25 | 6.0
26 | CFBundleName
27 | SourcePreview
28 | CFBundleShortVersionString
29 | 1.0
30 | CFBundleSupportedPlatforms
31 |
32 | MacOSX
33 |
34 | CFBundleVersion
35 | 1
36 | CFPlugInDynamicRegisterFunction
37 |
38 | CFPlugInDynamicRegistration
39 | NO
40 | CFPlugInFactories
41 |
42 | C3F3DA17-8E49-4B7F-9581-EC35FD86C4BB
43 | QuickLookGeneratorPluginFactory
44 |
45 | CFPlugInTypes
46 |
47 | 5E2D9680-5022-40FA-B806-43349622E5B9
48 |
49 | C3F3DA17-8E49-4B7F-9581-EC35FD86C4BB
50 |
51 |
52 | CFPlugInUnloadFunction
53 |
54 | DTCompiler
55 | com.apple.compilers.llvm.clang.1_0
56 | DTPlatformBuild
57 | 9F2000
58 | DTPlatformVersion
59 | GM
60 | DTSDKBuild
61 | 17E189
62 | DTSDKName
63 | macosx10.13
64 | DTXcode
65 | 0941
66 | DTXcodeBuild
67 | 9F2000
68 | NSHumanReadableCopyright
69 | Copyright © 2017 tsif. All rights reserved.
70 | QLNeedsToBeRunInMainThread
71 |
72 | QLPreviewHeight
73 | 600
74 | QLPreviewWidth
75 | 800
76 | QLSupportsConcurrentRequests
77 |
78 | QLThumbnailMinimumSize
79 | 17
80 |
81 |
82 |
--------------------------------------------------------------------------------
/SourcePreview/GenerateThumbnailForURL.m:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | #include "Regurgitator.h"
6 |
7 | OSStatus GenerateThumbnailForURL(void *thisInterface, QLThumbnailRequestRef thumbnail, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options, CGSize maxSize);
8 | void CancelThumbnailGeneration(void *thisInterface, QLThumbnailRequestRef thumbnail);
9 |
10 | /* -----------------------------------------------------------------------------
11 | Generate a thumbnail for file
12 |
13 | This function's job is to create thumbnail for designated file as fast as possible
14 | ----------------------------------------------------------------------------- */
15 |
16 | OSStatus GenerateThumbnailForURL(void *thisInterface, QLThumbnailRequestRef thumbnail, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options, CGSize maxSize)
17 | {
18 | NSStringEncoding usedEncoding = 0;
19 | NSError *readError = nil;
20 |
21 | NSString *source = [NSString stringWithContentsOfURL:(__bridge NSURL*)url
22 | usedEncoding:&usedEncoding
23 | error:&readError];
24 |
25 | if (usedEncoding == 0) {
26 | NSLog(@"Failed to determine encoding for file %@", [(__bridge NSURL*)url path]);
27 | return noErr;
28 | }
29 |
30 | source = [NSString stringWithCString:source.UTF8String
31 | encoding:NSUTF8StringEncoding];
32 |
33 | // Load water mark
34 |
35 | NSURL *imageURL = [[NSBundle bundleWithIdentifier:@"tsif.swift-preview"] URLForResource:@"swift_logo" withExtension:@"png"];
36 | NSImage *image = imageTintedWithColor([[NSImage alloc] initWithContentsOfURL:imageURL], [NSColor colorWithWhite:1.0f alpha:0.1f]);
37 | CGFloat iconScale = image.size.width / maxSize.width;
38 |
39 | NSRect renderRect = NSMakeRect(0.0, 0.0, maxSize.width, maxSize.height);
40 | CGFloat iconHeight = image.size.height / iconScale;
41 | NSRect iconRect = NSMakeRect(0.0, maxSize.height - iconHeight, maxSize.width, iconHeight);
42 |
43 | CGContextRef context = QLThumbnailRequestCreateContext(thumbnail, maxSize, false, NULL);
44 | if (context) {
45 | NSGraphicsContext* graphicsContext = [NSGraphicsContext graphicsContextWithGraphicsPort:(void *)context flipped:NO];
46 |
47 | [NSGraphicsContext setCurrentContext:graphicsContext];
48 | [image drawInRect:iconRect];
49 |
50 | NSDictionary *textAttributes =
51 | @{
52 | NSForegroundColorAttributeName: [NSColor blackColor],
53 | NSBackgroundColorAttributeName: [NSColor clearColor],
54 | NSFontAttributeName: [NSFont fontWithName:@"Monaco" size:10.0]
55 | };
56 | [source drawInRect:renderRect withAttributes:textAttributes];
57 |
58 | QLThumbnailRequestFlushContext(thumbnail, context);
59 | CFRelease(context);
60 | }
61 |
62 |
63 | // To complete your generator please implement the function GenerateThumbnailForURL in GenerateThumbnailForURL.c
64 | return noErr;
65 | }
66 |
67 | void CancelThumbnailGeneration(void *thisInterface, QLThumbnailRequestRef thumbnail)
68 | {
69 | // Implement only if supported
70 | }
71 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://travis-ci.com/tsif/SourcePreview) [](https://opensource.org/licenses/MIT) 
2 |
3 | # SourcePreview
4 |
5 | Quick look plugin for macOS for source code files in swift. Inspired by [QLMarkDown](https://github.com/toland/qlmarkdown) and [QLSwift](https://github.com/lexrus/QLSwift). Source code is rendered by using [prism.js](https://prismjs.com/). Features include the ability to copy the source file to the clipboard and the display of line numbers in the preview.
6 |
7 | written by [Dimitri James Tsiflitzis](https://github.com/tsif/)
8 |
9 | designed by [Dimitris Niavis](https://niavis.design/)
10 |
11 | 
12 |
13 | 
14 |
15 | ## Installation
16 |
17 | Pick any of the methods below:
18 |
19 | - Once you clone this repo, you can run the `SourcePreview` scheme in xcode. A post build step copies `SourcePreview.qlgenerator` into `~/Library/QuickLook` and you can start previewing swift files.
20 |
21 | - You can build an installer package yourself. Run the project at least once in xcode. Then, in a terminal, go to the `installer` folder located in the `SourcePreview` folder. Run the `build.sh` file. Running this command will create a `.pkg` file in the `compiled` folder. Double click on the `.pkg` and follow the prompts to install the plugin.
22 |
23 | - Download the latest [release](https://github.com/tsif/SourcePreview/releases/tag/1.0.1) from https://github.com/tsif/SourcePreview/releases. You can copy `SourcePreview.qlgenerator` into `~/Library/QuickLook` manually (run `qlmanage -r` once you do this) or you can run the installer package located here.
24 |
25 | ## Removal
26 |
27 | Drag `SourcePreview.qlgenerator` located in `~/Library/QuickLook` into the trash.
28 |
29 | ## License
30 |
31 | ```
32 | MIT License
33 |
34 | Copyright (c) 2018 tsif
35 |
36 | Permission is hereby granted, free of charge, to any person obtaining a copy
37 | of this software and associated documentation files (the "Software"), to deal
38 | in the Software without restriction, including without limitation the rights
39 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
40 | copies of the Software, and to permit persons to whom the Software is
41 | furnished to do so, subject to the following conditions:
42 |
43 | The above copyright notice and this permission notice shall be included in all
44 | copies or substantial portions of the Software.
45 |
46 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
47 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
48 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
49 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
50 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
51 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
52 | SOFTWARE.
53 | ```
54 |
55 | ## Version History
56 |
57 | Version 1.0.1 - September 18, 2018
58 |
59 | - Initial release.
60 |
61 |
--------------------------------------------------------------------------------
/SourcePreview.xcodeproj/xcshareddata/xcschemes/ql-swift.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
31 |
32 |
33 |
34 |
35 |
36 |
47 |
48 |
54 |
55 |
56 |
57 |
60 |
61 |
62 |
63 |
64 |
65 |
71 |
72 |
78 |
79 |
80 |
81 |
83 |
84 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/SourcePreview/installer/files/SourcePreview.qlgenerator/Contents/_CodeSignature/CodeResources:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | files
6 |
7 | Resources/page.html
8 |
9 | h7Pd11rkc2lvQhhfGkw/LmegU08=
10 |
11 | Resources/prism.css
12 |
13 | LgQVaLG9utEk4azmOOSauaAAH6U=
14 |
15 | Resources/prism.js
16 |
17 | Wc5Z1NJf32mOpCrgxf141PolDMU=
18 |
19 | Resources/swift_logo.png
20 |
21 | hjYEsWZ98ocANP14fq5e3iyjttc=
22 |
23 |
24 | files2
25 |
26 | Resources/page.html
27 |
28 | hash2
29 |
30 | QBwlbE27ak+bb+PKZdJfpCgwxz6ZrV6X3iFOjEUPMHc=
31 |
32 |
33 | Resources/prism.css
34 |
35 | hash2
36 |
37 | 8/3Jp799w9wDI3IAFJVf5PbOrqM8sO7dWTac2NJvico=
38 |
39 |
40 | Resources/prism.js
41 |
42 | hash2
43 |
44 | y8hn5tAHFdR6wsEZilb3j3TLTrAtVPZs2oyzxjXt6DU=
45 |
46 |
47 | Resources/swift_logo.png
48 |
49 | hash2
50 |
51 | J9tUaVU8I6Y0yyG54iSFOIBhbdq+oRLoII/zHpCy6bU=
52 |
53 |
54 |
55 | rules
56 |
57 | ^Resources/
58 |
59 | ^Resources/.*\.lproj/
60 |
61 | optional
62 |
63 | weight
64 | 1000
65 |
66 | ^Resources/.*\.lproj/locversion.plist$
67 |
68 | omit
69 |
70 | weight
71 | 1100
72 |
73 | ^Resources/Base\.lproj/
74 |
75 | weight
76 | 1010
77 |
78 | ^version.plist$
79 |
80 |
81 | rules2
82 |
83 | .*\.dSYM($|/)
84 |
85 | weight
86 | 11
87 |
88 | ^(.*/)?\.DS_Store$
89 |
90 | omit
91 |
92 | weight
93 | 2000
94 |
95 | ^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/
96 |
97 | nested
98 |
99 | weight
100 | 10
101 |
102 | ^.*
103 |
104 | ^Info\.plist$
105 |
106 | omit
107 |
108 | weight
109 | 20
110 |
111 | ^PkgInfo$
112 |
113 | omit
114 |
115 | weight
116 | 20
117 |
118 | ^Resources/
119 |
120 | weight
121 | 20
122 |
123 | ^Resources/.*\.lproj/
124 |
125 | optional
126 |
127 | weight
128 | 1000
129 |
130 | ^Resources/.*\.lproj/locversion.plist$
131 |
132 | omit
133 |
134 | weight
135 | 1100
136 |
137 | ^Resources/Base\.lproj/
138 |
139 | weight
140 | 1010
141 |
142 | ^[^/]+$
143 |
144 | nested
145 |
146 | weight
147 | 10
148 |
149 | ^embedded\.provisionprofile$
150 |
151 | weight
152 | 20
153 |
154 | ^version\.plist$
155 |
156 | weight
157 | 20
158 |
159 |
160 |
161 |
162 |
--------------------------------------------------------------------------------
/SourcePreview/prism/styles/prism.css:
--------------------------------------------------------------------------------
1 | /* PrismJS 1.10.0
2 | http://prismjs.com/download.html?themes=prism&languages=markup+css+clike+javascript&plugins=line-numbers */
3 | /**
4 | * prism.js default theme for JavaScript, CSS and HTML
5 | * Based on dabblet (http://dabblet.com)
6 | * @author Lea Verou
7 | */
8 |
9 | code[class*="language-"],
10 | pre[class*="language-"] {
11 | color: black;
12 | background: none;
13 | text-shadow: 0 1px white;
14 | font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
15 | text-align: left;
16 | white-space: pre;
17 | word-spacing: normal;
18 | word-break: normal;
19 | word-wrap: normal;
20 | line-height: 1.5;
21 |
22 | -moz-tab-size: 4;
23 | -o-tab-size: 4;
24 | tab-size: 4;
25 |
26 | -webkit-hyphens: none;
27 | -moz-hyphens: none;
28 | -ms-hyphens: none;
29 | hyphens: none;
30 | }
31 |
32 | pre[class*="language-"]::-moz-selection, pre[class*="language-"] ::-moz-selection,
33 | code[class*="language-"]::-moz-selection, code[class*="language-"] ::-moz-selection {
34 | text-shadow: none;
35 | background: #b3d4fc;
36 | }
37 |
38 | pre[class*="language-"]::selection, pre[class*="language-"] ::selection,
39 | code[class*="language-"]::selection, code[class*="language-"] ::selection {
40 | text-shadow: none;
41 | background: #b3d4fc;
42 | }
43 |
44 | @media print {
45 | code[class*="language-"],
46 | pre[class*="language-"] {
47 | text-shadow: none;
48 | }
49 | }
50 |
51 | /* Code blocks */
52 | pre[class*="language-"] {
53 | padding: 1em;
54 | margin: .5em 0;
55 | overflow: auto;
56 | }
57 |
58 | :not(pre) > code[class*="language-"],
59 | pre[class*="language-"] {
60 | background: #f5f2f0;
61 | }
62 |
63 | /* Inline code */
64 | :not(pre) > code[class*="language-"] {
65 | padding: .1em;
66 | border-radius: .3em;
67 | white-space: normal;
68 | }
69 |
70 | .token.comment,
71 | .token.prolog,
72 | .token.doctype,
73 | .token.cdata {
74 | color: slategray;
75 | }
76 |
77 | .token.punctuation {
78 | color: #999;
79 | }
80 |
81 | .namespace {
82 | opacity: .7;
83 | }
84 |
85 | .token.property,
86 | .token.tag,
87 | .token.boolean,
88 | .token.number,
89 | .token.constant,
90 | .token.symbol,
91 | .token.deleted {
92 | color: #905;
93 | }
94 |
95 | .token.selector,
96 | .token.attr-name,
97 | .token.string,
98 | .token.char,
99 | .token.builtin,
100 | .token.inserted {
101 | color: #690;
102 | }
103 |
104 | .token.operator,
105 | .token.entity,
106 | .token.url,
107 | .language-css .token.string,
108 | .style .token.string {
109 | color: #a67f59;
110 | background: hsla(0, 0%, 100%, .5);
111 | }
112 |
113 | .token.atrule,
114 | .token.attr-value,
115 | .token.keyword {
116 | color: #07a;
117 | }
118 |
119 | .token.function {
120 | color: #DD4A68;
121 | }
122 |
123 | .token.regex,
124 | .token.important,
125 | .token.variable {
126 | color: #e90;
127 | }
128 |
129 | .token.important,
130 | .token.bold {
131 | font-weight: bold;
132 | }
133 | .token.italic {
134 | font-style: italic;
135 | }
136 |
137 | .token.entity {
138 | cursor: help;
139 | }
140 |
141 | pre.line-numbers {
142 | position: relative;
143 | padding-left: 3.8em;
144 | counter-reset: linenumber;
145 | }
146 |
147 | pre.line-numbers > code {
148 | position: relative;
149 | white-space: inherit;
150 | }
151 |
152 | .line-numbers .line-numbers-rows {
153 | position: absolute;
154 | pointer-events: none;
155 | top: 0;
156 | font-size: 100%;
157 | left: -3.8em;
158 | width: 3em; /* works for line-numbers below 1000 lines */
159 | letter-spacing: -1px;
160 | border-right: 1px solid #999;
161 |
162 | -webkit-user-select: none;
163 | -moz-user-select: none;
164 | -ms-user-select: none;
165 | user-select: none;
166 |
167 | }
168 |
169 | .line-numbers-rows > span {
170 | pointer-events: none;
171 | display: block;
172 | counter-increment: linenumber;
173 | }
174 |
175 | .line-numbers-rows > span:before {
176 | content: counter(linenumber);
177 | color: #999;
178 | display: block;
179 | padding-right: 0.8em;
180 | text-align: right;
181 | }
182 |
--------------------------------------------------------------------------------
/SourcePreview/installer/files/SourcePreview.qlgenerator/Contents/Resources/prism.css:
--------------------------------------------------------------------------------
1 | /* PrismJS 1.10.0
2 | http://prismjs.com/download.html?themes=prism&languages=markup+css+clike+javascript&plugins=line-numbers */
3 | /**
4 | * prism.js default theme for JavaScript, CSS and HTML
5 | * Based on dabblet (http://dabblet.com)
6 | * @author Lea Verou
7 | */
8 |
9 | code[class*="language-"],
10 | pre[class*="language-"] {
11 | color: black;
12 | background: none;
13 | text-shadow: 0 1px white;
14 | font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
15 | text-align: left;
16 | white-space: pre;
17 | word-spacing: normal;
18 | word-break: normal;
19 | word-wrap: normal;
20 | line-height: 1.5;
21 |
22 | -moz-tab-size: 4;
23 | -o-tab-size: 4;
24 | tab-size: 4;
25 |
26 | -webkit-hyphens: none;
27 | -moz-hyphens: none;
28 | -ms-hyphens: none;
29 | hyphens: none;
30 | }
31 |
32 | pre[class*="language-"]::-moz-selection, pre[class*="language-"] ::-moz-selection,
33 | code[class*="language-"]::-moz-selection, code[class*="language-"] ::-moz-selection {
34 | text-shadow: none;
35 | background: #b3d4fc;
36 | }
37 |
38 | pre[class*="language-"]::selection, pre[class*="language-"] ::selection,
39 | code[class*="language-"]::selection, code[class*="language-"] ::selection {
40 | text-shadow: none;
41 | background: #b3d4fc;
42 | }
43 |
44 | @media print {
45 | code[class*="language-"],
46 | pre[class*="language-"] {
47 | text-shadow: none;
48 | }
49 | }
50 |
51 | /* Code blocks */
52 | pre[class*="language-"] {
53 | padding: 1em;
54 | margin: .5em 0;
55 | overflow: auto;
56 | }
57 |
58 | :not(pre) > code[class*="language-"],
59 | pre[class*="language-"] {
60 | background: #f5f2f0;
61 | }
62 |
63 | /* Inline code */
64 | :not(pre) > code[class*="language-"] {
65 | padding: .1em;
66 | border-radius: .3em;
67 | white-space: normal;
68 | }
69 |
70 | .token.comment,
71 | .token.prolog,
72 | .token.doctype,
73 | .token.cdata {
74 | color: slategray;
75 | }
76 |
77 | .token.punctuation {
78 | color: #999;
79 | }
80 |
81 | .namespace {
82 | opacity: .7;
83 | }
84 |
85 | .token.property,
86 | .token.tag,
87 | .token.boolean,
88 | .token.number,
89 | .token.constant,
90 | .token.symbol,
91 | .token.deleted {
92 | color: #905;
93 | }
94 |
95 | .token.selector,
96 | .token.attr-name,
97 | .token.string,
98 | .token.char,
99 | .token.builtin,
100 | .token.inserted {
101 | color: #690;
102 | }
103 |
104 | .token.operator,
105 | .token.entity,
106 | .token.url,
107 | .language-css .token.string,
108 | .style .token.string {
109 | color: #a67f59;
110 | background: hsla(0, 0%, 100%, .5);
111 | }
112 |
113 | .token.atrule,
114 | .token.attr-value,
115 | .token.keyword {
116 | color: #07a;
117 | }
118 |
119 | .token.function {
120 | color: #DD4A68;
121 | }
122 |
123 | .token.regex,
124 | .token.important,
125 | .token.variable {
126 | color: #e90;
127 | }
128 |
129 | .token.important,
130 | .token.bold {
131 | font-weight: bold;
132 | }
133 | .token.italic {
134 | font-style: italic;
135 | }
136 |
137 | .token.entity {
138 | cursor: help;
139 | }
140 |
141 | pre.line-numbers {
142 | position: relative;
143 | padding-left: 3.8em;
144 | counter-reset: linenumber;
145 | }
146 |
147 | pre.line-numbers > code {
148 | position: relative;
149 | white-space: inherit;
150 | }
151 |
152 | .line-numbers .line-numbers-rows {
153 | position: absolute;
154 | pointer-events: none;
155 | top: 0;
156 | font-size: 100%;
157 | left: -3.8em;
158 | width: 3em; /* works for line-numbers below 1000 lines */
159 | letter-spacing: -1px;
160 | border-right: 1px solid #999;
161 |
162 | -webkit-user-select: none;
163 | -moz-user-select: none;
164 | -ms-user-select: none;
165 | user-select: none;
166 |
167 | }
168 |
169 | .line-numbers-rows > span {
170 | pointer-events: none;
171 | display: block;
172 | counter-increment: linenumber;
173 | }
174 |
175 | .line-numbers-rows > span:before {
176 | content: counter(linenumber);
177 | color: #999;
178 | display: block;
179 | padding-right: 0.8em;
180 | text-align: right;
181 | }
182 |
--------------------------------------------------------------------------------
/SourcePreview/assets/page.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
156 |
157 |
158 |
159 |
163 |
164 |
167 |
168 |
169 |
170 |
171 |
--------------------------------------------------------------------------------
/SourcePreview/installer/files/SourcePreview.qlgenerator/Contents/Resources/page.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
156 |
157 |
158 |
159 |
163 |
164 |
167 |
168 |
169 |
170 |
171 |
--------------------------------------------------------------------------------
/SourcePreview/Regurgitator.m:
--------------------------------------------------------------------------------
1 | /*
2 | * Regurgitator.m
3 | */
4 |
5 | #import "Regurgitator.h"
6 |
7 | NSImage *imageTintedWithColor(NSImage *original, NSColor *tint)
8 | {
9 | NSImage *image = [original copy];
10 | if (tint) {
11 | NSImage *newImage = [[NSImage alloc] initWithSize:[image size]];
12 | [newImage lockFocus];
13 | [[NSColor whiteColor] set];
14 | NSRectFill(NSMakeRect(0,0,[newImage size].width, [newImage size].height));
15 | [image compositeToPoint:NSZeroPoint operation:NSCompositeCopy];
16 | [newImage unlockFocus];
17 |
18 | return newImage;
19 | }
20 | return image;
21 | }
22 |
23 | NSString *imageToNSString(NSImage *image)
24 | {
25 | NSData *imageData = [image TIFFRepresentation];
26 | NSBitmapImageRep *imageRep = [NSBitmapImageRep imageRepWithData:imageData];
27 | imageData = [imageRep representationUsingType:NSPNGFileType properties:Nil];
28 |
29 | NSString *base64 = [imageData base64EncodedStringWithOptions:nil];
30 |
31 | return base64;
32 | }
33 |
34 | NSString *regurgitateHTML(NSURL* url)
35 | {
36 | NSStringEncoding usedEncoding = 0;
37 | NSError *readError = nil;
38 |
39 | NSString *source = [NSString stringWithContentsOfURL:url usedEncoding:&usedEncoding error:&readError];
40 |
41 | if (usedEncoding == 0)
42 | {
43 | NSLog(@"Failed to determine encoding for file %@", [url path]);
44 | }
45 |
46 | NSURL *imageURL = [[NSBundle bundleWithIdentifier:@"tsif.swift-preview"] URLForResource:@"swift_logo" withExtension:@"png"];
47 | NSImage *image = imageTintedWithColor([[NSImage alloc] initWithContentsOfURL:imageURL], [NSColor colorWithWhite:1.0f alpha:0.95f]);
48 | NSString *base64Image = imageToNSString(image);
49 |
50 | NSString *cssPath = [[NSBundle bundleWithIdentifier:@"tsif.swift-preview"] pathForResource:@"prism.css" ofType:nil];
51 | NSString *cssContent = [NSString stringWithContentsOfFile:cssPath
52 | encoding:NSUTF8StringEncoding
53 | error:nil];
54 |
55 | NSString *jsPath = [[NSBundle bundleWithIdentifier:@"tsif.swift-preview"] pathForResource:@"prism.js" ofType:nil];
56 | NSString *jsContent = [NSString stringWithContentsOfFile:jsPath
57 | encoding:NSUTF8StringEncoding
58 | error:nil];
59 |
60 | NSString *htmlPath = [[NSBundle bundleWithIdentifier:@"tsif.swift-preview"] pathForResource:@"page.html" ofType:nil];
61 | NSString *htmlContent = [NSString stringWithContentsOfFile:htmlPath
62 | encoding:NSUTF8StringEncoding
63 | error:nil];
64 |
65 | NSString *html = [NSString stringWithFormat:htmlContent,
66 | base64Image,
67 | cssContent,
68 | url.absoluteString,
69 | [NSString stringWithCString:source.UTF8String encoding:NSUTF8StringEncoding],
70 | jsContent];
71 |
72 | return html;
73 | }
74 |
75 | NSData *regurgitateHTMLData(NSURL* url)
76 | {
77 | NSStringEncoding usedEncoding = 0;
78 | NSError *readError = nil;
79 |
80 | NSString *source = [NSString stringWithContentsOfURL:url usedEncoding:&usedEncoding error:&readError];
81 |
82 | if (usedEncoding == 0)
83 | {
84 | NSLog(@"Failed to determine encoding for file %@", [url path]);
85 | }
86 |
87 | NSURL *imageURL = [[NSBundle bundleWithIdentifier:@"tsif.swift-preview"] URLForResource:@"swift_logo" withExtension:@"png"];
88 | NSImage *image = imageTintedWithColor([[NSImage alloc] initWithContentsOfURL:imageURL], [NSColor colorWithWhite:1.0f alpha:0.95f]);
89 | NSString *base64Image = imageToNSString(image);
90 |
91 | NSString *cssPath = [[NSBundle bundleWithIdentifier:@"tsif.swift-preview"] pathForResource:@"prism.css" ofType:nil];
92 | NSString *cssContent = [NSString stringWithContentsOfFile:cssPath
93 | encoding:NSUTF8StringEncoding
94 | error:nil];
95 |
96 | NSString *jsPath = [[NSBundle bundleWithIdentifier:@"tsif.swift-preview"] pathForResource:@"prism.js" ofType:nil];
97 | NSString *jsContent = [NSString stringWithContentsOfFile:jsPath
98 | encoding:NSUTF8StringEncoding
99 | error:nil];
100 |
101 | NSString *htmlPath = [[NSBundle bundleWithIdentifier:@"tsif.swift-preview"] pathForResource:@"page.html" ofType:nil];
102 | NSString *htmlContent = [NSString stringWithContentsOfFile:htmlPath
103 | encoding:NSUTF8StringEncoding
104 | error:nil];
105 |
106 | NSString *swift = [NSString stringWithCString:source.UTF8String encoding:NSUTF8StringEncoding];
107 |
108 | NSString *html = [NSString stringWithFormat:htmlContent,
109 | base64Image,
110 | cssContent,
111 | url.absoluteString,
112 | swift,
113 | jsContent];
114 |
115 | return [html dataUsingEncoding:NSUTF8StringEncoding];
116 | }
117 |
--------------------------------------------------------------------------------
/SourcePreview/main.c:
--------------------------------------------------------------------------------
1 | //==============================================================================
2 | //
3 | // DO NO MODIFY THE CONTENT OF THIS FILE
4 | //
5 | // This file contains the generic CFPlug-in code necessary for your generator
6 | // To complete your generator implement the function in GenerateThumbnailForURL/GeneratePreviewForURL.c
7 | //
8 | //==============================================================================
9 |
10 |
11 |
12 |
13 |
14 |
15 | #include
16 | #include
17 | #include
18 | #include
19 |
20 | // -----------------------------------------------------------------------------
21 | // constants
22 | // -----------------------------------------------------------------------------
23 |
24 | // Don't modify this line
25 | #define PLUGIN_ID "C3F3DA17-8E49-4B7F-9581-EC35FD86C4BB"
26 |
27 | //
28 | // Below is the generic glue code for all plug-ins.
29 | //
30 | // You should not have to modify this code aside from changing
31 | // names if you decide to change the names defined in the Info.plist
32 | //
33 |
34 |
35 | // -----------------------------------------------------------------------------
36 | // typedefs
37 | // -----------------------------------------------------------------------------
38 |
39 | // The thumbnail generation function to be implemented in GenerateThumbnailForURL.c
40 | OSStatus GenerateThumbnailForURL(void *thisInterface, QLThumbnailRequestRef thumbnail, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options, CGSize maxSize);
41 | void CancelThumbnailGeneration(void* thisInterface, QLThumbnailRequestRef thumbnail);
42 |
43 | // The preview generation function to be implemented in GeneratePreviewForURL.c
44 | OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options);
45 | void CancelPreviewGeneration(void *thisInterface, QLPreviewRequestRef preview);
46 |
47 | // The layout for an instance of QuickLookGeneratorPlugIn
48 | typedef struct __QuickLookGeneratorPluginType
49 | {
50 | void *conduitInterface;
51 | CFUUIDRef factoryID;
52 | UInt32 refCount;
53 | } QuickLookGeneratorPluginType;
54 |
55 | // -----------------------------------------------------------------------------
56 | // prototypes
57 | // -----------------------------------------------------------------------------
58 | // Forward declaration for the IUnknown implementation.
59 | //
60 |
61 | QuickLookGeneratorPluginType *AllocQuickLookGeneratorPluginType(CFUUIDRef inFactoryID);
62 | void DeallocQuickLookGeneratorPluginType(QuickLookGeneratorPluginType *thisInstance);
63 | HRESULT QuickLookGeneratorQueryInterface(void *thisInstance,REFIID iid,LPVOID *ppv);
64 | void *QuickLookGeneratorPluginFactory(CFAllocatorRef allocator,CFUUIDRef typeID);
65 | ULONG QuickLookGeneratorPluginAddRef(void *thisInstance);
66 | ULONG QuickLookGeneratorPluginRelease(void *thisInstance);
67 |
68 | // -----------------------------------------------------------------------------
69 | // myInterfaceFtbl definition
70 | // -----------------------------------------------------------------------------
71 | // The QLGeneratorInterfaceStruct function table.
72 | //
73 | static QLGeneratorInterfaceStruct myInterfaceFtbl = {
74 | NULL,
75 | QuickLookGeneratorQueryInterface,
76 | QuickLookGeneratorPluginAddRef,
77 | QuickLookGeneratorPluginRelease,
78 | NULL,
79 | NULL,
80 | NULL,
81 | NULL
82 | };
83 |
84 |
85 | // -----------------------------------------------------------------------------
86 | // AllocQuickLookGeneratorPluginType
87 | // -----------------------------------------------------------------------------
88 | // Utility function that allocates a new instance.
89 | // You can do some initial setup for the generator here if you wish
90 | // like allocating globals etc...
91 | //
92 | QuickLookGeneratorPluginType *AllocQuickLookGeneratorPluginType(CFUUIDRef inFactoryID)
93 | {
94 | QuickLookGeneratorPluginType *theNewInstance;
95 |
96 | theNewInstance = (QuickLookGeneratorPluginType *)malloc(sizeof(QuickLookGeneratorPluginType));
97 | memset(theNewInstance,0,sizeof(QuickLookGeneratorPluginType));
98 |
99 | /* Point to the function table Malloc enough to store the stuff and copy the filler from myInterfaceFtbl over */
100 | theNewInstance->conduitInterface = malloc(sizeof(QLGeneratorInterfaceStruct));
101 | memcpy(theNewInstance->conduitInterface,&myInterfaceFtbl,sizeof(QLGeneratorInterfaceStruct));
102 |
103 | /* Retain and keep an open instance refcount for each factory. */
104 | theNewInstance->factoryID = CFRetain(inFactoryID);
105 | CFPlugInAddInstanceForFactory(inFactoryID);
106 |
107 | /* This function returns the IUnknown interface so set the refCount to one. */
108 | theNewInstance->refCount = 1;
109 | return theNewInstance;
110 | }
111 |
112 | // -----------------------------------------------------------------------------
113 | // DeallocQuickLookGeneratorPluginType
114 | // -----------------------------------------------------------------------------
115 | // Utility function that deallocates the instance when
116 | // the refCount goes to zero.
117 | // In the current implementation generator interfaces are never deallocated
118 | // but implement this as this might change in the future
119 | //
120 | void DeallocQuickLookGeneratorPluginType(QuickLookGeneratorPluginType *thisInstance)
121 | {
122 | CFUUIDRef theFactoryID;
123 |
124 | theFactoryID = thisInstance->factoryID;
125 | /* Free the conduitInterface table up */
126 | free(thisInstance->conduitInterface);
127 |
128 | /* Free the instance structure */
129 | free(thisInstance);
130 | if (theFactoryID){
131 | CFPlugInRemoveInstanceForFactory(theFactoryID);
132 | CFRelease(theFactoryID);
133 | }
134 | }
135 |
136 | // -----------------------------------------------------------------------------
137 | // QuickLookGeneratorQueryInterface
138 | // -----------------------------------------------------------------------------
139 | // Implementation of the IUnknown QueryInterface function.
140 | //
141 | HRESULT QuickLookGeneratorQueryInterface(void *thisInstance,REFIID iid,LPVOID *ppv)
142 | {
143 | CFUUIDRef interfaceID;
144 |
145 | interfaceID = CFUUIDCreateFromUUIDBytes(kCFAllocatorDefault,iid);
146 |
147 | if (CFEqual(interfaceID,kQLGeneratorCallbacksInterfaceID)){
148 | /* If the Right interface was requested, bump the ref count,
149 | * set the ppv parameter equal to the instance, and
150 | * return good status.
151 | */
152 | ((QLGeneratorInterfaceStruct *)((QuickLookGeneratorPluginType *)thisInstance)->conduitInterface)->GenerateThumbnailForURL = GenerateThumbnailForURL;
153 | ((QLGeneratorInterfaceStruct *)((QuickLookGeneratorPluginType *)thisInstance)->conduitInterface)->CancelThumbnailGeneration = CancelThumbnailGeneration;
154 | ((QLGeneratorInterfaceStruct *)((QuickLookGeneratorPluginType *)thisInstance)->conduitInterface)->GeneratePreviewForURL = GeneratePreviewForURL;
155 | ((QLGeneratorInterfaceStruct *)((QuickLookGeneratorPluginType *)thisInstance)->conduitInterface)->CancelPreviewGeneration = CancelPreviewGeneration;
156 | ((QLGeneratorInterfaceStruct *)((QuickLookGeneratorPluginType*)thisInstance)->conduitInterface)->AddRef(thisInstance);
157 | *ppv = thisInstance;
158 | CFRelease(interfaceID);
159 | return S_OK;
160 | }else{
161 | /* Requested interface unknown, bail with error. */
162 | *ppv = NULL;
163 | CFRelease(interfaceID);
164 | return E_NOINTERFACE;
165 | }
166 | }
167 |
168 | // -----------------------------------------------------------------------------
169 | // QuickLookGeneratorPluginAddRef
170 | // -----------------------------------------------------------------------------
171 | // Implementation of reference counting for this type. Whenever an interface
172 | // is requested, bump the refCount for the instance. NOTE: returning the
173 | // refcount is a convention but is not required so don't rely on it.
174 | //
175 | ULONG QuickLookGeneratorPluginAddRef(void *thisInstance)
176 | {
177 | ((QuickLookGeneratorPluginType *)thisInstance )->refCount += 1;
178 | return ((QuickLookGeneratorPluginType*) thisInstance)->refCount;
179 | }
180 |
181 | // -----------------------------------------------------------------------------
182 | // QuickLookGeneratorPluginRelease
183 | // -----------------------------------------------------------------------------
184 | // When an interface is released, decrement the refCount.
185 | // If the refCount goes to zero, deallocate the instance.
186 | //
187 | ULONG QuickLookGeneratorPluginRelease(void *thisInstance)
188 | {
189 | ((QuickLookGeneratorPluginType*)thisInstance)->refCount -= 1;
190 | if (((QuickLookGeneratorPluginType*)thisInstance)->refCount == 0){
191 | DeallocQuickLookGeneratorPluginType((QuickLookGeneratorPluginType*)thisInstance );
192 | return 0;
193 | }else{
194 | return ((QuickLookGeneratorPluginType*) thisInstance )->refCount;
195 | }
196 | }
197 |
198 | // -----------------------------------------------------------------------------
199 | // QuickLookGeneratorPluginFactory
200 | // -----------------------------------------------------------------------------
201 | void *QuickLookGeneratorPluginFactory(CFAllocatorRef allocator,CFUUIDRef typeID)
202 | {
203 | QuickLookGeneratorPluginType *result;
204 | CFUUIDRef uuid;
205 |
206 | /* If correct type is being requested, allocate an
207 | * instance of kQLGeneratorTypeID and return the IUnknown interface.
208 | */
209 | if (CFEqual(typeID,kQLGeneratorTypeID)){
210 | uuid = CFUUIDCreateFromString(kCFAllocatorDefault,CFSTR(PLUGIN_ID));
211 | result = AllocQuickLookGeneratorPluginType(uuid);
212 | CFRelease(uuid);
213 | return result;
214 | }
215 | /* If the requested type is incorrect, return NULL. */
216 | return NULL;
217 | }
218 |
219 |
--------------------------------------------------------------------------------
/SourcePreview.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | F327F611214677330043E9A6 /* prism.css in Resources */ = {isa = PBXBuildFile; fileRef = F385338820C1132F0056AAD6 /* prism.css */; };
11 | F3363BCF1FFD339900148B4F /* Regurgitator.m in Sources */ = {isa = PBXBuildFile; fileRef = F3363BCE1FFD339900148B4F /* Regurgitator.m */; };
12 | F3363BD11FFD33AD00148B4F /* Regurgitator.h in Headers */ = {isa = PBXBuildFile; fileRef = F3363BD01FFD33AD00148B4F /* Regurgitator.h */; };
13 | F36C99FE1FFFCFEE001F5748 /* swift_logo.png in Resources */ = {isa = PBXBuildFile; fileRef = F36C99FD1FFFCFEE001F5748 /* swift_logo.png */; };
14 | F36C9A001FFFDB34001F5748 /* page.html in Resources */ = {isa = PBXBuildFile; fileRef = F36C99FF1FFFDB34001F5748 /* page.html */; };
15 | F38DB20C1F3C546300896C80 /* GenerateThumbnailForURL.m in Sources */ = {isa = PBXBuildFile; fileRef = F38DB20B1F3C546300896C80 /* GenerateThumbnailForURL.m */; };
16 | F38DB20E1F3C546300896C80 /* GeneratePreviewForURL.m in Sources */ = {isa = PBXBuildFile; fileRef = F38DB20D1F3C546300896C80 /* GeneratePreviewForURL.m */; };
17 | F38DB2101F3C546300896C80 /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = F38DB20F1F3C546300896C80 /* main.c */; };
18 | F3964AC61FFB9D1900CA6A1C /* prism.js in Resources */ = {isa = PBXBuildFile; fileRef = F3964AC51FFB9D1900CA6A1C /* prism.js */; };
19 | /* End PBXBuildFile section */
20 |
21 | /* Begin PBXFileReference section */
22 | F3363BCE1FFD339900148B4F /* Regurgitator.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Regurgitator.m; sourceTree = ""; };
23 | F3363BD01FFD33AD00148B4F /* Regurgitator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Regurgitator.h; sourceTree = ""; };
24 | F36C99FD1FFFCFEE001F5748 /* swift_logo.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = swift_logo.png; sourceTree = ""; };
25 | F36C99FF1FFFDB34001F5748 /* page.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = page.html; sourceTree = ""; };
26 | F385338820C1132F0056AAD6 /* prism.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; name = prism.css; path = SourcePreview/prism/styles/prism.css; sourceTree = SOURCE_ROOT; };
27 | F38DB2081F3C546300896C80 /* SourcePreview.qlgenerator */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SourcePreview.qlgenerator; sourceTree = BUILT_PRODUCTS_DIR; };
28 | F38DB20B1F3C546300896C80 /* GenerateThumbnailForURL.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GenerateThumbnailForURL.m; sourceTree = ""; };
29 | F38DB20D1F3C546300896C80 /* GeneratePreviewForURL.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GeneratePreviewForURL.m; sourceTree = ""; };
30 | F38DB20F1F3C546300896C80 /* main.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = main.c; sourceTree = ""; };
31 | F38DB2111F3C546300896C80 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
32 | F3964AC51FFB9D1900CA6A1C /* prism.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = prism.js; sourceTree = ""; };
33 | /* End PBXFileReference section */
34 |
35 | /* Begin PBXFrameworksBuildPhase section */
36 | F38DB2041F3C546300896C80 /* Frameworks */ = {
37 | isa = PBXFrameworksBuildPhase;
38 | buildActionMask = 2147483647;
39 | files = (
40 | );
41 | runOnlyForDeploymentPostprocessing = 0;
42 | };
43 | /* End PBXFrameworksBuildPhase section */
44 |
45 | /* Begin PBXGroup section */
46 | F38DB1FE1F3C546300896C80 = {
47 | isa = PBXGroup;
48 | children = (
49 | F38DB20A1F3C546300896C80 /* SourcePreview */,
50 | F38DB2091F3C546300896C80 /* Products */,
51 | );
52 | sourceTree = "";
53 | };
54 | F38DB2091F3C546300896C80 /* Products */ = {
55 | isa = PBXGroup;
56 | children = (
57 | F38DB2081F3C546300896C80 /* SourcePreview.qlgenerator */,
58 | );
59 | name = Products;
60 | sourceTree = "";
61 | };
62 | F38DB20A1F3C546300896C80 /* SourcePreview */ = {
63 | isa = PBXGroup;
64 | children = (
65 | F3964AC41FFB95AF00CA6A1C /* prism */,
66 | F3964AC31FFB95A300CA6A1C /* assets */,
67 | F38DB20B1F3C546300896C80 /* GenerateThumbnailForURL.m */,
68 | F38DB20D1F3C546300896C80 /* GeneratePreviewForURL.m */,
69 | F3363BD01FFD33AD00148B4F /* Regurgitator.h */,
70 | F3363BCE1FFD339900148B4F /* Regurgitator.m */,
71 | F38DB20F1F3C546300896C80 /* main.c */,
72 | F38DB2111F3C546300896C80 /* Info.plist */,
73 | );
74 | path = SourcePreview;
75 | sourceTree = "";
76 | };
77 | F3964AC31FFB95A300CA6A1C /* assets */ = {
78 | isa = PBXGroup;
79 | children = (
80 | F36C99FD1FFFCFEE001F5748 /* swift_logo.png */,
81 | F36C99FF1FFFDB34001F5748 /* page.html */,
82 | );
83 | path = assets;
84 | sourceTree = "";
85 | };
86 | F3964AC41FFB95AF00CA6A1C /* prism */ = {
87 | isa = PBXGroup;
88 | children = (
89 | F3964AC71FFB9D1C00CA6A1C /* styles */,
90 | F3964AC51FFB9D1900CA6A1C /* prism.js */,
91 | );
92 | path = prism;
93 | sourceTree = "";
94 | };
95 | F3964AC71FFB9D1C00CA6A1C /* styles */ = {
96 | isa = PBXGroup;
97 | children = (
98 | F385338820C1132F0056AAD6 /* prism.css */,
99 | );
100 | name = styles;
101 | path = "New Group";
102 | sourceTree = "";
103 | };
104 | /* End PBXGroup section */
105 |
106 | /* Begin PBXHeadersBuildPhase section */
107 | F38DB2051F3C546300896C80 /* Headers */ = {
108 | isa = PBXHeadersBuildPhase;
109 | buildActionMask = 2147483647;
110 | files = (
111 | F3363BD11FFD33AD00148B4F /* Regurgitator.h in Headers */,
112 | );
113 | runOnlyForDeploymentPostprocessing = 0;
114 | };
115 | /* End PBXHeadersBuildPhase section */
116 |
117 | /* Begin PBXNativeTarget section */
118 | F38DB2071F3C546300896C80 /* SourcePreview */ = {
119 | isa = PBXNativeTarget;
120 | buildConfigurationList = F38DB2141F3C546300896C80 /* Build configuration list for PBXNativeTarget "SourcePreview" */;
121 | buildPhases = (
122 | F38DB2031F3C546300896C80 /* Sources */,
123 | F38DB2041F3C546300896C80 /* Frameworks */,
124 | F38DB2051F3C546300896C80 /* Headers */,
125 | F38DB2061F3C546300896C80 /* Resources */,
126 | F3EB3EDE2008B90E00CD705D /* ShellScript */,
127 | );
128 | buildRules = (
129 | );
130 | dependencies = (
131 | );
132 | name = SourcePreview;
133 | productName = "ql-swift";
134 | productReference = F38DB2081F3C546300896C80 /* SourcePreview.qlgenerator */;
135 | productType = "com.apple.product-type.bundle";
136 | };
137 | /* End PBXNativeTarget section */
138 |
139 | /* Begin PBXProject section */
140 | F38DB1FF1F3C546300896C80 /* Project object */ = {
141 | isa = PBXProject;
142 | attributes = {
143 | LastUpgradeCheck = 0830;
144 | ORGANIZATIONNAME = tsif;
145 | TargetAttributes = {
146 | F38DB2071F3C546300896C80 = {
147 | CreatedOnToolsVersion = 8.3.2;
148 | LastSwiftMigration = 0920;
149 | ProvisioningStyle = Automatic;
150 | };
151 | };
152 | };
153 | buildConfigurationList = F38DB2021F3C546300896C80 /* Build configuration list for PBXProject "SourcePreview" */;
154 | compatibilityVersion = "Xcode 3.2";
155 | developmentRegion = English;
156 | hasScannedForEncodings = 0;
157 | knownRegions = (
158 | en,
159 | );
160 | mainGroup = F38DB1FE1F3C546300896C80;
161 | productRefGroup = F38DB2091F3C546300896C80 /* Products */;
162 | projectDirPath = "";
163 | projectRoot = "";
164 | targets = (
165 | F38DB2071F3C546300896C80 /* SourcePreview */,
166 | );
167 | };
168 | /* End PBXProject section */
169 |
170 | /* Begin PBXResourcesBuildPhase section */
171 | F38DB2061F3C546300896C80 /* Resources */ = {
172 | isa = PBXResourcesBuildPhase;
173 | buildActionMask = 2147483647;
174 | files = (
175 | F327F611214677330043E9A6 /* prism.css in Resources */,
176 | F36C9A001FFFDB34001F5748 /* page.html in Resources */,
177 | F3964AC61FFB9D1900CA6A1C /* prism.js in Resources */,
178 | F36C99FE1FFFCFEE001F5748 /* swift_logo.png in Resources */,
179 | );
180 | runOnlyForDeploymentPostprocessing = 0;
181 | };
182 | /* End PBXResourcesBuildPhase section */
183 |
184 | /* Begin PBXShellScriptBuildPhase section */
185 | F3EB3EDE2008B90E00CD705D /* ShellScript */ = {
186 | isa = PBXShellScriptBuildPhase;
187 | buildActionMask = 2147483647;
188 | files = (
189 | );
190 | inputPaths = (
191 | );
192 | outputPaths = (
193 | );
194 | runOnlyForDeploymentPostprocessing = 0;
195 | shellPath = /bin/sh;
196 | shellScript = "# Remove previous version if it exists\nrm -Rf \"~/Library/QuickLook/$FULL_PRODUCT_NAME\"\n\n# Copy the compiled version to the user QuickLook directory\ncp -R \"$BUILT_PRODUCTS_DIR/$FULL_PRODUCT_NAME\" ~/Library/QuickLook\n\n# Reset thumbnail disk cache\nqlmanage -r\n\n# Copy the compiled version to installer directory\ncp -R \"$BUILT_PRODUCTS_DIR/$FULL_PRODUCT_NAME\" \"$PROJECT_DIR/$PRODUCT_NAME/installer/files\"";
197 | };
198 | /* End PBXShellScriptBuildPhase section */
199 |
200 | /* Begin PBXSourcesBuildPhase section */
201 | F38DB2031F3C546300896C80 /* Sources */ = {
202 | isa = PBXSourcesBuildPhase;
203 | buildActionMask = 2147483647;
204 | files = (
205 | F3363BCF1FFD339900148B4F /* Regurgitator.m in Sources */,
206 | F38DB20C1F3C546300896C80 /* GenerateThumbnailForURL.m in Sources */,
207 | F38DB20E1F3C546300896C80 /* GeneratePreviewForURL.m in Sources */,
208 | F38DB2101F3C546300896C80 /* main.c in Sources */,
209 | );
210 | runOnlyForDeploymentPostprocessing = 0;
211 | };
212 | /* End PBXSourcesBuildPhase section */
213 |
214 | /* Begin XCBuildConfiguration section */
215 | F38DB2121F3C546300896C80 /* Debug */ = {
216 | isa = XCBuildConfiguration;
217 | buildSettings = {
218 | ALWAYS_SEARCH_USER_PATHS = NO;
219 | CLANG_ANALYZER_NONNULL = YES;
220 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
221 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
222 | CLANG_CXX_LIBRARY = "libc++";
223 | CLANG_ENABLE_MODULES = YES;
224 | CLANG_ENABLE_OBJC_ARC = YES;
225 | CLANG_WARN_BOOL_CONVERSION = YES;
226 | CLANG_WARN_CONSTANT_CONVERSION = YES;
227 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
228 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
229 | CLANG_WARN_EMPTY_BODY = YES;
230 | CLANG_WARN_ENUM_CONVERSION = YES;
231 | CLANG_WARN_INFINITE_RECURSION = YES;
232 | CLANG_WARN_INT_CONVERSION = YES;
233 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
234 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
235 | CLANG_WARN_UNREACHABLE_CODE = YES;
236 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
237 | CODE_SIGN_IDENTITY = "-";
238 | COPY_PHASE_STRIP = NO;
239 | DEBUG_INFORMATION_FORMAT = dwarf;
240 | ENABLE_STRICT_OBJC_MSGSEND = YES;
241 | ENABLE_TESTABILITY = YES;
242 | GCC_C_LANGUAGE_STANDARD = gnu99;
243 | GCC_DYNAMIC_NO_PIC = NO;
244 | GCC_NO_COMMON_BLOCKS = YES;
245 | GCC_OPTIMIZATION_LEVEL = 0;
246 | GCC_PREPROCESSOR_DEFINITIONS = (
247 | "DEBUG=1",
248 | "$(inherited)",
249 | );
250 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
251 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
252 | GCC_WARN_UNDECLARED_SELECTOR = YES;
253 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
254 | GCC_WARN_UNUSED_FUNCTION = YES;
255 | GCC_WARN_UNUSED_VARIABLE = YES;
256 | MACOSX_DEPLOYMENT_TARGET = 10.12;
257 | MTL_ENABLE_DEBUG_INFO = YES;
258 | ONLY_ACTIVE_ARCH = YES;
259 | SDKROOT = macosx;
260 | };
261 | name = Debug;
262 | };
263 | F38DB2131F3C546300896C80 /* Release */ = {
264 | isa = XCBuildConfiguration;
265 | buildSettings = {
266 | ALWAYS_SEARCH_USER_PATHS = NO;
267 | CLANG_ANALYZER_NONNULL = YES;
268 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
269 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
270 | CLANG_CXX_LIBRARY = "libc++";
271 | CLANG_ENABLE_MODULES = YES;
272 | CLANG_ENABLE_OBJC_ARC = YES;
273 | CLANG_WARN_BOOL_CONVERSION = YES;
274 | CLANG_WARN_CONSTANT_CONVERSION = YES;
275 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
276 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
277 | CLANG_WARN_EMPTY_BODY = YES;
278 | CLANG_WARN_ENUM_CONVERSION = YES;
279 | CLANG_WARN_INFINITE_RECURSION = YES;
280 | CLANG_WARN_INT_CONVERSION = YES;
281 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
282 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
283 | CLANG_WARN_UNREACHABLE_CODE = YES;
284 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
285 | CODE_SIGN_IDENTITY = "-";
286 | COPY_PHASE_STRIP = NO;
287 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
288 | ENABLE_NS_ASSERTIONS = NO;
289 | ENABLE_STRICT_OBJC_MSGSEND = YES;
290 | GCC_C_LANGUAGE_STANDARD = gnu99;
291 | GCC_NO_COMMON_BLOCKS = YES;
292 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
293 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
294 | GCC_WARN_UNDECLARED_SELECTOR = YES;
295 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
296 | GCC_WARN_UNUSED_FUNCTION = YES;
297 | GCC_WARN_UNUSED_VARIABLE = YES;
298 | MACOSX_DEPLOYMENT_TARGET = 10.12;
299 | MTL_ENABLE_DEBUG_INFO = NO;
300 | SDKROOT = macosx;
301 | };
302 | name = Release;
303 | };
304 | F38DB2151F3C546300896C80 /* Debug */ = {
305 | isa = XCBuildConfiguration;
306 | buildSettings = {
307 | CLANG_ENABLE_MODULES = YES;
308 | COMBINE_HIDPI_IMAGES = YES;
309 | INFOPLIST_FILE = SourcePreview/Info.plist;
310 | INSTALL_PATH = /Library/QuickLook;
311 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
312 | PRODUCT_BUNDLE_IDENTIFIER = "tsif.swift-preview";
313 | PRODUCT_NAME = "$(TARGET_NAME)";
314 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
315 | SWIFT_VERSION = 3.0;
316 | WRAPPER_EXTENSION = qlgenerator;
317 | };
318 | name = Debug;
319 | };
320 | F38DB2161F3C546300896C80 /* Release */ = {
321 | isa = XCBuildConfiguration;
322 | buildSettings = {
323 | CLANG_ENABLE_MODULES = YES;
324 | COMBINE_HIDPI_IMAGES = YES;
325 | INFOPLIST_FILE = SourcePreview/Info.plist;
326 | INSTALL_PATH = /Library/QuickLook;
327 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
328 | PRODUCT_BUNDLE_IDENTIFIER = "tsif.swift-preview";
329 | PRODUCT_NAME = "$(TARGET_NAME)";
330 | SWIFT_VERSION = 3.0;
331 | WRAPPER_EXTENSION = qlgenerator;
332 | };
333 | name = Release;
334 | };
335 | /* End XCBuildConfiguration section */
336 |
337 | /* Begin XCConfigurationList section */
338 | F38DB2021F3C546300896C80 /* Build configuration list for PBXProject "SourcePreview" */ = {
339 | isa = XCConfigurationList;
340 | buildConfigurations = (
341 | F38DB2121F3C546300896C80 /* Debug */,
342 | F38DB2131F3C546300896C80 /* Release */,
343 | );
344 | defaultConfigurationIsVisible = 0;
345 | defaultConfigurationName = Release;
346 | };
347 | F38DB2141F3C546300896C80 /* Build configuration list for PBXNativeTarget "SourcePreview" */ = {
348 | isa = XCConfigurationList;
349 | buildConfigurations = (
350 | F38DB2151F3C546300896C80 /* Debug */,
351 | F38DB2161F3C546300896C80 /* Release */,
352 | );
353 | defaultConfigurationIsVisible = 0;
354 | defaultConfigurationName = Release;
355 | };
356 | /* End XCConfigurationList section */
357 | };
358 | rootObject = F38DB1FF1F3C546300896C80 /* Project object */;
359 | }
360 |
--------------------------------------------------------------------------------
/SourcePreview/prism/prism.js:
--------------------------------------------------------------------------------
1 | /* PrismJS 1.10.0
2 | http://prismjs.com/download.html?themes=prism&languages=markup+css+clike+javascript+swift&plugins=line-highlight+line-numbers+toolbar+show-language+copy-to-clipboard */
3 | var _self="undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:{},Prism=function(){var e=/\blang(?:uage)?-(\w+)\b/i,t=0,n=_self.Prism={manual:_self.Prism&&_self.Prism.manual,disableWorkerMessageHandler:_self.Prism&&_self.Prism.disableWorkerMessageHandler,util:{encode:function(e){return e instanceof r?new r(e.type,n.util.encode(e.content),e.alias):"Array"===n.util.type(e)?e.map(n.util.encode):e.replace(/&/g,"&").replace(/e.length)return;if(!(w instanceof s)){h.lastIndex=0;var _=h.exec(w),P=1;if(!_&&m&&b!=t.length-1){if(h.lastIndex=k,_=h.exec(e),!_)break;for(var A=_.index+(d?_[1].length:0),j=_.index+_[0].length,x=b,O=k,N=t.length;N>x&&(j>O||!t[x].type&&!t[x-1].greedy);++x)O+=t[x].length,A>=O&&(++b,k=O);if(t[b]instanceof s||t[x-1].greedy)continue;P=x-b,w=e.slice(k,O),_.index-=k}if(_){d&&(p=_[1].length);var A=_.index+p,_=_[0].slice(p),j=A+_.length,S=w.slice(0,A),C=w.slice(j),M=[b,P];S&&(++b,k+=S.length,M.push(S));var E=new s(g,f?n.tokenize(_,f):_,y,_,m);if(M.push(E),C&&M.push(C),Array.prototype.splice.apply(t,M),1!=P&&n.matchGrammar(e,t,r,b,k,!0,g),i)break}else if(i)break}}}}},tokenize:function(e,t){var r=[e],a=t.rest;if(a){for(var l in a)t[l]=a[l];delete t.rest}return n.matchGrammar(e,r,t,0,0,!1),r},hooks:{all:{},add:function(e,t){var r=n.hooks.all;r[e]=r[e]||[],r[e].push(t)},run:function(e,t){var r=n.hooks.all[e];if(r&&r.length)for(var a,l=0;a=r[l++];)a(t)}}},r=n.Token=function(e,t,n,r,a){this.type=e,this.content=t,this.alias=n,this.length=0|(r||"").length,this.greedy=!!a};if(r.stringify=function(e,t,a){if("string"==typeof e)return e;if("Array"===n.util.type(e))return e.map(function(n){return r.stringify(n,t,e)}).join("");var l={type:e.type,content:r.stringify(e.content,t,a),tag:"span",classes:["token",e.type],attributes:{},language:t,parent:a};if(e.alias){var i="Array"===n.util.type(e.alias)?e.alias:[e.alias];Array.prototype.push.apply(l.classes,i)}n.hooks.run("wrap",l);var o=Object.keys(l.attributes).map(function(e){return e+'="'+(l.attributes[e]||"").replace(/"/g,""")+'"'}).join(" ");return"<"+l.tag+' class="'+l.classes.join(" ")+'"'+(o?" "+o:"")+">"+l.content+""+l.tag+">"},!_self.document)return _self.addEventListener?(n.disableWorkerMessageHandler||_self.addEventListener("message",function(e){var t=JSON.parse(e.data),r=t.language,a=t.code,l=t.immediateClose;_self.postMessage(n.highlight(a,n.languages[r],r)),l&&_self.close()},!1),_self.Prism):_self.Prism;var a=document.currentScript||[].slice.call(document.getElementsByTagName("script")).pop();return a&&(n.filename=a.src,n.manual||a.hasAttribute("data-manual")||("loading"!==document.readyState?window.requestAnimationFrame?window.requestAnimationFrame(n.highlightAll):window.setTimeout(n.highlightAll,16):document.addEventListener("DOMContentLoaded",n.highlightAll))),_self.Prism}();"undefined"!=typeof module&&module.exports&&(module.exports=Prism),"undefined"!=typeof global&&(global.Prism=Prism);
4 | Prism.languages.markup={comment://,prolog:/<\?[\s\S]+?\?>/,doctype://i,cdata://i,tag:{pattern:/<\/?(?!\d)[^\s>\/=$<]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">=]+))?)*\s*\/?>/i,inside:{tag:{pattern:/^<\/?[^\s>\/]+/i,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"attr-value":{pattern:/=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">=]+)/i,inside:{punctuation:[/^=/,{pattern:/(^|[^\\])["']/,lookbehind:!0}]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:/?[\da-z]{1,8};/i},Prism.languages.markup.tag.inside["attr-value"].inside.entity=Prism.languages.markup.entity,Prism.hooks.add("wrap",function(a){"entity"===a.type&&(a.attributes.title=a.content.replace(/&/,"&"))}),Prism.languages.xml=Prism.languages.markup,Prism.languages.html=Prism.languages.markup,Prism.languages.mathml=Prism.languages.markup,Prism.languages.svg=Prism.languages.markup;
5 | Prism.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:/@[\w-]+?.*?(?:;|(?=\s*\{))/i,inside:{rule:/@[\w-]+/}},url:/url\((?:(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1|.*?)\)/i,selector:/[^{}\s][^{};]*?(?=\s*\{)/,string:{pattern:/("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},property:/[-_a-z\xA0-\uFFFF][-\w\xA0-\uFFFF]*(?=\s*:)/i,important:/\B!important\b/i,"function":/[-a-z0-9]+(?=\()/i,punctuation:/[(){};:]/},Prism.languages.css.atrule.inside.rest=Prism.util.clone(Prism.languages.css),Prism.languages.markup&&(Prism.languages.insertBefore("markup","tag",{style:{pattern:/(