Skip to content

Commit

Permalink
Bugfix on heads and emoji extensions.
Browse files Browse the repository at this point in the history
  • Loading branch information
sbarex committed Jan 16, 2021
1 parent 1b7546f commit b9eaaf2
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 61 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Changelog
=======

### 1.0b16
Bugfix:
- Fix on heads extension.
- Fix on emoji extension.
- Fix for exporting a source color scheme as a CSS style.

### 1.0b15
New features:
- Option to export the generated preview to an HTML file in the main application.
Expand Down
2 changes: 1 addition & 1 deletion QLExtension/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
<string>QLExtension</string>
<string>QLMarkdown Preview Extension</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
Expand Down
31 changes: 8 additions & 23 deletions QLMarkdown.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@
83E7FEF1258FBF37003ECF9B /* highlight in Resources */ = {isa = PBXBuildFile; fileRef = 83E7FEF0258FBF37003ECF9B /* highlight */; };
83EF951D2585367500B56FA3 /* NSColor+ext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 83EF951C2585367500B56FA3 /* NSColor+ext.swift */; };
83EF95232585476800B56FA3 /* emoji.c in Sources */ = {isa = PBXBuildFile; fileRef = 83EF95222585476800B56FA3 /* emoji.c */; };
83F1FE4C259CEE7400257DAC /* external-launcher.xpc in Embed XPC Services */ = {isa = PBXBuildFile; fileRef = 83F1FE41259CEE7400257DAC /* external-launcher.xpc */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
83F1FE53259CEEC900257DAC /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 83F1FE52259CEEC900257DAC /* main.swift */; };
83F1FE57259CEF0100257DAC /* external_launcherProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 83F1FE56259CEF0100257DAC /* external_launcherProtocol.swift */; };
83F1FE5B259CEF4300257DAC /* external_launcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 83F1FE5A259CEF4300257DAC /* external_launcher.swift */; };
Expand Down Expand Up @@ -177,13 +176,6 @@
remoteGlobalIDString = 836B3007259E222600A6A5F7;
remoteInfo = "highlight-wrapper";
};
83F1FE4A259CEE7400257DAC /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 83598E5925818808004664D3 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 83F1FE40259CEE7400257DAC;
remoteInfo = "external-launcher";
};
83F1FE6C259CF02900257DAC /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 83598E5925818808004664D3 /* Project object */;
Expand Down Expand Up @@ -233,7 +225,6 @@
dstPath = "$(CONTENTS_FOLDER_PATH)/XPCServices";
dstSubfolderSpec = 16;
files = (
83F1FE4C259CEE7400257DAC /* external-launcher.xpc in Embed XPC Services */,
83F882412598A8C4008C5071 /* org.sparkle-project.InstallerStatus.xpc in Embed XPC Services */,
83F8823F2598A8C2008C5071 /* org.sparkle-project.InstallerLauncher.xpc in Embed XPC Services */,
83F8823D2598A8C0008C5071 /* org.sparkle-project.InstallerConnection.xpc in Embed XPC Services */,
Expand Down Expand Up @@ -529,19 +520,19 @@
83598E6D2581880A004664D3 /* Info.plist */,
83598E6E2581880A004664D3 /* QLMarkdown.entitlements */,
83598E7925818839004664D3 /* QLMarkdown-Bridging-Header.h */,
8357EB762587DBDE002C2C45 /* Themes */,
83598E6425818808004664D3 /* AppDelegate.swift */,
83598E6625818808004664D3 /* ViewController.swift */,
83598E6A2581880A004664D3 /* Main.storyboard */,
836B747C259E2D7B00A6A5F7 /* AboutViewController.swift */,
83598E682581880A004664D3 /* Assets.xcassets */,
83EF951C2585367500B56FA3 /* NSColor+ext.swift */,
8357EB7E2588262C002C2C45 /* String+ext.swift */,
8357EB762587DBDE002C2C45 /* Themes */,
836B747C259E2D7B00A6A5F7 /* AboutViewController.swift */,
83598EF92582098A004664D3 /* test1.md */,
83598EFA258209C7004664D3 /* test2.md */,
837D20D5258362A5008FC698 /* example.jpg */,
83F4B99125868A7400FC58A7 /* Settings.swift */,
83327D452595E15700E76CF6 /* Settings+ext.swift */,
8357EB7E2588262C002C2C45 /* String+ext.swift */,
83EF951C2585367500B56FA3 /* NSColor+ext.swift */,
834CAB89259167B800673002 /* examples */,
);
path = QLMarkdown;
Expand Down Expand Up @@ -767,7 +758,6 @@
dependencies = (
836B7472259E23DB00A6A5F7 /* PBXTargetDependency */,
831A8C4B258ABADA00E36182 /* PBXTargetDependency */,
83F1FE4B259CEE7400257DAC /* PBXTargetDependency */,
);
name = QLMarkdown;
productName = QLMarkdown;
Expand Down Expand Up @@ -1035,11 +1025,6 @@
name = "highlight-wrapper";
targetProxy = 836B7478259E2BA400A6A5F7 /* PBXContainerItemProxy */;
};
83F1FE4B259CEE7400257DAC /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 83F1FE40259CEE7400257DAC /* external-launcher */;
targetProxy = 83F1FE4A259CEE7400257DAC /* PBXContainerItemProxy */;
};
83F1FE6D259CF02900257DAC /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 83F1FE40259CEE7400257DAC /* external-launcher */;
Expand Down Expand Up @@ -1074,7 +1059,7 @@
CODE_SIGN_ENTITLEMENTS = QLExtension/QLExtension.entitlements;
CODE_SIGN_IDENTITY = "-";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 15;
CURRENT_PROJECT_VERSION = 16;
DEVELOPMENT_TEAM = "";
ENABLE_HARDENED_RUNTIME = NO;
HEADER_SEARCH_PATHS = (
Expand Down Expand Up @@ -1110,7 +1095,7 @@
CODE_SIGN_ENTITLEMENTS = QLExtension/QLExtension.entitlements;
CODE_SIGN_IDENTITY = "-";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 15;
CURRENT_PROJECT_VERSION = 16;
DEVELOPMENT_TEAM = "";
ENABLE_HARDENED_RUNTIME = NO;
HEADER_SEARCH_PATHS = (
Expand Down Expand Up @@ -1265,7 +1250,7 @@
CODE_SIGN_IDENTITY = "-";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 15;
CURRENT_PROJECT_VERSION = 16;
DEVELOPMENT_TEAM = "";
ENABLE_HARDENED_RUNTIME = NO;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -1310,7 +1295,7 @@
CODE_SIGN_IDENTITY = "-";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 15;
CURRENT_PROJECT_VERSION = 16;
DEVELOPMENT_TEAM = "";
ENABLE_HARDENED_RUNTIME = NO;
FRAMEWORK_SEARCH_PATHS = (
Expand Down
6 changes: 3 additions & 3 deletions QLMarkdown/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -2069,7 +2069,7 @@ Gw
<scene sceneID="WNd-O7-Vdp">
<objects>
<windowController showSeguePresentationStyle="single" id="VZF-nt-1dI" customClass="AboutWindowController" customModule="QLMarkdown" customModuleProvider="target" sceneMemberID="viewController">
<window key="window" title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" restorable="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" frameAutosaveName="" animationBehavior="default" titlebarAppearsTransparent="YES" titleVisibility="hidden" id="07D-zf-Sfn">
<window key="window" title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" restorable="NO" hidesOnDeactivate="YES" releasedWhenClosed="NO" visibleAtLaunch="NO" frameAutosaveName="" animationBehavior="default" titlebarAppearsTransparent="YES" titleVisibility="hidden" id="07D-zf-Sfn">
<windowStyleMask key="styleMask" titled="YES" closable="YES"/>
<rect key="contentRect" x="196" y="239" width="291" height="176"/>
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="875"/>
Expand All @@ -2087,7 +2087,7 @@ Gw
</windowController>
<customObject id="kjp-9V-P2O" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="618.5" y="705"/>
<point key="canvasLocation" x="730" y="704"/>
</scene>
<!--About View Controller-->
<scene sceneID="VRI-xW-cZ4">
Expand Down Expand Up @@ -2184,7 +2184,7 @@ Gw
</viewController>
<customObject id="bdx-fe-T4t" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1150.5" y="726.5"/>
<point key="canvasLocation" x="1150" y="698"/>
</scene>
<!--Window Controller-->
<scene sceneID="DFL-JM-PTQ">
Expand Down
2 changes: 1 addition & 1 deletion QLMarkdown/Themes/SaveAsFormatView.xib
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<menu key="menu" id="5D6-pF-Hwe">
<items>
<menuItem title="Highlight theme" state="on" id="yPr-jP-u5s"/>
<menuItem title="CSS" id="Lmi-6w-SwN"/>
<menuItem title="CSS Style" id="Lmi-6w-SwN"/>
</items>
</menu>
</popUpButtonCell>
Expand Down
28 changes: 18 additions & 10 deletions QLMarkdown/Themes/Theme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ import Cocoa
}

class PropertyStyle {
enum Name: String {
enum Attribute: String {
case italic = "italic"
case bold = "bold"
case underline = "underline"
Expand Down Expand Up @@ -117,7 +117,7 @@ import Cocoa
self.init(color: color, italic: italic, bold: bold, underline: underline)
}

func getCSSStyle(withColor: Bool = true) -> String {
func getCSSStyle() -> String {
var style = ""
if let italic = self.italic {
style += "font-style: \(italic ? "italic" : "normal"); "
Expand All @@ -128,14 +128,14 @@ import Cocoa
if let underline = self.underline {
style += "text-decoration: \(underline ? "underline" : "none"); "
}
if withColor, let color = self.color {
if let color = self.color {
style += "color: \(color); "
}

return style
}

subscript(name: Name)->AnyHashable? {
subscript(name: Attribute)->AnyHashable? {
get {
switch name {
case .bold:
Expand Down Expand Up @@ -323,20 +323,18 @@ import Cocoa
self.keywords = []
}

func getHtmlExample() -> String {

func getCSSStyle() -> String {
let formatPropertyCss = { (name: PropertyName, property: PropertyStyle) -> String in
var css = "." + name.cssClass.joined(separator: ".") + " {"
var css = "." + name.cssClass.joined(separator: ".") + " {\n"
if name == .canvas {
css += "background-color: \(property.color ?? "#ffffff");"
css += " background-color: \(property.color ?? "#ffffff");\n"
} else {
css += property.getCSSStyle()
}
css += "}\n"
return css
}
let formatProperty = { (name: PropertyName, property: PropertyStyle) -> String in
return "<div class='\(name.cssClass.joined(separator: " "))'>\(name.name)</div>\n"
}

var css = ""

Expand All @@ -363,6 +361,16 @@ import Cocoa
css += formatPropertyCss(.keyword(index: i), keyword)
}

return css
}

func getHtmlExample() -> String {
let formatProperty = { (name: PropertyName, property: PropertyStyle) -> String in
return "<div class='\(name.cssClass.joined(separator: " "))'>\(name.name)</div>\n"
}

let css = self.getCSSStyle()

var s = """
<html>
<head>
Expand Down
7 changes: 6 additions & 1 deletion QLMarkdown/Themes/ThemeTableView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,12 @@ class ThemeTableView: NSView {
return
}
do {
try theme.write(toFile: url.path)
if url.pathExtension == "css" {
let css = theme.getCSSStyle()
try css.write(toFile: url.path, atomically: true, encoding: .utf8)
} else {
try theme.write(toFile: url.path)
}
} catch {
let alert = NSAlert()
alert.alertStyle = .critical
Expand Down
32 changes: 16 additions & 16 deletions QLMarkdown/Themes/ThemeTableView.xib
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,31 @@
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customView id="c22-O7-iKe">
<rect key="frame" x="0.0" y="0.0" width="834" height="252"/>
<rect key="frame" x="0.0" y="0.0" width="834" height="289"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<stackView distribution="fill" orientation="horizontal" alignment="centerY" spacing="13" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="9z1-P5-xCv">
<rect key="frame" x="20" y="210" width="794" height="22"/>
<rect key="frame" x="20" y="247" width="794" height="22"/>
<subviews>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="751" translatesAutoresizingMaskIntoConstraints="NO" id="Ery-aX-B9J">
<rect key="frame" x="-2" y="3" width="40" height="16"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Name" id="1nU-gL-k7z">
<rect key="frame" x="-2" y="3" width="44" height="16"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Name:" id="1nU-gL-k7z">
<font key="font" usesAppearanceFont="YES"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="249" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="ASO-vk-aSO">
<rect key="frame" x="49" y="1" width="584" height="21"/>
<rect key="frame" x="53" y="1" width="576" height="21"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" title="name" drawsBackground="YES" id="opJ-Rz-dRH">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="aju-NW-Clo">
<rect key="frame" x="644" y="3" width="35" height="16"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Style" id="2xc-bp-K7V">
<rect key="frame" x="640" y="3" width="39" height="16"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Style:" id="2xc-bp-K7V">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
Expand Down Expand Up @@ -76,18 +76,18 @@
</customSpacing>
</stackView>
<stackView distribution="fill" orientation="horizontal" alignment="centerY" spacing="13" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="tPS-RX-tli">
<rect key="frame" x="20" y="153" width="794" height="49"/>
<rect key="frame" x="20" y="134" width="794" height="105"/>
<subviews>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="751" translatesAutoresizingMaskIntoConstraints="NO" id="FB7-mZ-emk">
<rect key="frame" x="-2" y="17" width="74" height="16"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Description" id="4f0-qH-Fn5">
<rect key="frame" x="-2" y="45" width="78" height="16"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Description:" id="4f0-qH-Fn5">
<font key="font" usesAppearanceFont="YES"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="249" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Yjt-aa-AKJ">
<rect key="frame" x="83" y="14" width="711" height="21"/>
<rect key="frame" x="87" y="42" width="707" height="21"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" drawsBackground="YES" id="rYM-Rv-Vga">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
Expand All @@ -105,16 +105,16 @@
</customSpacing>
</stackView>
<box verticalHuggingPriority="750" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="z4p-sq-cAh">
<rect key="frame" x="0.0" y="142" width="834" height="5"/>
<rect key="frame" x="0.0" y="123" width="834" height="5"/>
</box>
<scrollView borderType="none" autohidesScrollers="YES" horizontalLineScroll="24" horizontalPageScroll="10" verticalLineScroll="24" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ENC-Dy-j05">
<rect key="frame" x="0.0" y="31" width="834" height="113"/>
<rect key="frame" x="0.0" y="31" width="834" height="94"/>
<clipView key="contentView" id="Qff-rN-ejQ">
<rect key="frame" x="0.0" y="0.0" width="834" height="113"/>
<rect key="frame" x="0.0" y="0.0" width="834" height="94"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" columnSelection="YES" multipleSelection="NO" autosaveColumns="NO" rowHeight="24" rowSizeStyle="medium" headerView="SVs-zS-bwY" viewBased="YES" id="85v-Ra-SaE">
<rect key="frame" x="0.0" y="0.0" width="834" height="85"/>
<rect key="frame" x="0.0" y="0.0" width="834" height="66"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<size key="intercellSpacing" width="17" height="0.0"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
Expand Down Expand Up @@ -500,7 +500,7 @@
<constraint firstAttribute="trailing" secondItem="cFa-mF-X9v" secondAttribute="trailing" id="p5F-RL-1ZC"/>
<constraint firstItem="z4p-sq-cAh" firstAttribute="leading" secondItem="c22-O7-iKe" secondAttribute="leading" id="vDv-eH-Mzk"/>
</constraints>
<point key="canvasLocation" x="-18" y="273"/>
<point key="canvasLocation" x="-18" y="291.5"/>
</customView>
</objects>
<resources>
Expand Down
Loading

0 comments on commit b9eaaf2

Please sign in to comment.