Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions QLMarkdown.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
831A8C6B258ABD8900E36182 /* syntaxhighlight.c in Sources */ = {isa = PBXBuildFile; fileRef = 83598EF525818BCB004664D3 /* syntaxhighlight.c */; };
831A8C6E258ABD8D00E36182 /* emoji.c in Sources */ = {isa = PBXBuildFile; fileRef = 83EF95222585476800B56FA3 /* emoji.c */; };
831A8C71258ABD9300E36182 /* mention.c in Sources */ = {isa = PBXBuildFile; fileRef = 838109C2258403CA000AFE3C /* mention.c */; };
7273677933E44FAD8B3EEA1D /* wikilink.c in Sources */ = {isa = PBXBuildFile; fileRef = 1DDD0092C9DF487BBB99BB1D /* wikilink.c */; };
831A8C74258ABD9600E36182 /* checkbox.c in Sources */ = {isa = PBXBuildFile; fileRef = 838109C625840429000AFE3C /* checkbox.c */; };
831A8CC1258AC18300E36182 /* Settings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 83F4B99125868A7400FC58A7 /* Settings.swift */; };
8320D5942D1C25B1005868BD /* QLMarkdown Shortcut Extension.appex in Embed ExtensionKit Extensions */ = {isa = PBXBuildFile; fileRef = 8320D58A2D1C25B1005868BD /* QLMarkdown Shortcut Extension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
Expand Down Expand Up @@ -76,6 +77,7 @@
8320D5E32D1C3AA7005868BD /* sup_ext.c in Sources */ = {isa = PBXBuildFile; fileRef = 83CF71CD2C60023E0066A195 /* sup_ext.c */; };
8320D5E42D1C3AA7005868BD /* syntaxhighlight.c in Sources */ = {isa = PBXBuildFile; fileRef = 83598EF525818BCB004664D3 /* syntaxhighlight.c */; };
8320D5E52D1C3AA7005868BD /* mention.c in Sources */ = {isa = PBXBuildFile; fileRef = 838109C2258403CA000AFE3C /* mention.c */; };
138DFA4523EA4D8DA48F233D /* wikilink.c in Sources */ = {isa = PBXBuildFile; fileRef = 1DDD0092C9DF487BBB99BB1D /* wikilink.c */; };
8320D5E62D1C3AA7005868BD /* checkbox.c in Sources */ = {isa = PBXBuildFile; fileRef = 838109C625840429000AFE3C /* checkbox.c */; };
8320D5E72D1C3AA7005868BD /* math_ext.c in Sources */ = {isa = PBXBuildFile; fileRef = 835886B229E960050088DF7D /* math_ext.c */; };
8320D5E82D1C3AA7005868BD /* extra-extensions.c in Sources */ = {isa = PBXBuildFile; fileRef = 834A4F8129E92AE800692964 /* extra-extensions.c */; };
Expand All @@ -99,6 +101,7 @@
83437985271D49FF00A5D6EA /* MIMEtype.c in Sources */ = {isa = PBXBuildFile; fileRef = 83327D2E2594066300E76CF6 /* MIMEtype.c */; };
83437986271D4A1900A5D6EA /* inlineimage.c in Sources */ = {isa = PBXBuildFile; fileRef = 83760300258C1813004799ED /* inlineimage.c */; };
83437987271D4A1900A5D6EA /* mention.c in Sources */ = {isa = PBXBuildFile; fileRef = 838109C2258403CA000AFE3C /* mention.c */; };
CB9185D831D741DCB49AF8D3 /* wikilink.c in Sources */ = {isa = PBXBuildFile; fileRef = 1DDD0092C9DF487BBB99BB1D /* wikilink.c */; };
83437988271D4A1900A5D6EA /* checkbox.c in Sources */ = {isa = PBXBuildFile; fileRef = 838109C625840429000AFE3C /* checkbox.c */; };
83437989271D4A1900A5D6EA /* heads_utils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83F8825C25991BFC008C5071 /* heads_utils.cpp */; };
8343798D271D4A1900A5D6EA /* heads.c in Sources */ = {isa = PBXBuildFile; fileRef = 83F88258259906C7008C5071 /* heads.c */; };
Expand Down Expand Up @@ -243,6 +246,7 @@
8376EAE427E8C67F00AB44B8 /* c_log.c in Sources */ = {isa = PBXBuildFile; fileRef = 8376EAE127E8C67F00AB44B8 /* c_log.c */; };
837F97D6271EA12A009F4605 /* qlmarkdown_cli in Resources */ = {isa = PBXBuildFile; fileRef = 837F97CE271EA098009F4605 /* qlmarkdown_cli */; };
838109C3258403CA000AFE3C /* mention.c in Sources */ = {isa = PBXBuildFile; fileRef = 838109C2258403CA000AFE3C /* mention.c */; };
0342FC81767440D68CFDD7B4 /* wikilink.c in Sources */ = {isa = PBXBuildFile; fileRef = 1DDD0092C9DF487BBB99BB1D /* wikilink.c */; };
838109C725840429000AFE3C /* checkbox.c in Sources */ = {isa = PBXBuildFile; fileRef = 838109C625840429000AFE3C /* checkbox.c */; };
8382D05C2664051400210A0A /* Yams in Frameworks */ = {isa = PBXBuildFile; productRef = 8382D05B2664051400210A0A /* Yams */; };
8382D05E2664052E00210A0A /* Yams in Frameworks */ = {isa = PBXBuildFile; productRef = 8382D05D2664052E00210A0A /* Yams */; };
Expand Down Expand Up @@ -651,6 +655,8 @@
837F97CE271EA098009F4605 /* qlmarkdown_cli */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; path = qlmarkdown_cli; sourceTree = BUILT_PRODUCTS_DIR; };
838109C1258403CA000AFE3C /* mention.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = mention.h; sourceTree = "<group>"; };
838109C2258403CA000AFE3C /* mention.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = mention.c; sourceTree = "<group>"; };
8C0194F6D1944DC681276B11 /* wikilink.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = wikilink.h; sourceTree = "<group>"; };
1DDD0092C9DF487BBB99BB1D /* wikilink.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = wikilink.c; sourceTree = "<group>"; };
838109C525840429000AFE3C /* checkbox.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = checkbox.h; sourceTree = "<group>"; };
838109C625840429000AFE3C /* checkbox.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = checkbox.c; sourceTree = "<group>"; };
838A5D5C29F1139200D704AB /* makefile2.makefile */ = {isa = PBXFileReference; lastKnownFileType = text; path = makefile2.makefile; sourceTree = "<group>"; usesTabs = 1; };
Expand Down Expand Up @@ -843,6 +849,8 @@
835886B229E960050088DF7D /* math_ext.c */,
838109C1258403CA000AFE3C /* mention.h */,
838109C2258403CA000AFE3C /* mention.c */,
8C0194F6D1944DC681276B11 /* wikilink.h */,
1DDD0092C9DF487BBB99BB1D /* wikilink.c */,
83CF71CC2C60023E0066A195 /* sup_ext.h */,
83CF71CD2C60023E0066A195 /* sup_ext.c */,
83CF71D12C6005370066A195 /* sub_ext.h */,
Expand Down Expand Up @@ -1504,6 +1512,7 @@
834A4EF829E8AD8C00692964 /* table.c in Sources */,
834A4F1929E8AD8D00692964 /* blocks.c in Sources */,
831A8C71258ABD9300E36182 /* mention.c in Sources */,
7273677933E44FAD8B3EEA1D /* wikilink.c in Sources */,
836B747E259E2D7B00A6A5F7 /* AboutViewController.swift in Sources */,
835886B429E960050088DF7D /* math_ext.c in Sources */,
834CAB9D2593650900673002 /* emoji_utils.cpp in Sources */,
Expand Down Expand Up @@ -1561,6 +1570,7 @@
8320D5E32D1C3AA7005868BD /* sup_ext.c in Sources */,
8320D5E42D1C3AA7005868BD /* syntaxhighlight.c in Sources */,
8320D5E52D1C3AA7005868BD /* mention.c in Sources */,
138DFA4523EA4D8DA48F233D /* wikilink.c in Sources */,
8320D5E62D1C3AA7005868BD /* checkbox.c in Sources */,
8320D5E72D1C3AA7005868BD /* math_ext.c in Sources */,
8320D5E82D1C3AA7005868BD /* extra-extensions.c in Sources */,
Expand Down Expand Up @@ -1622,6 +1632,7 @@
834A4F2829E8AD8D00692964 /* houdini_href_e.c in Sources */,
834A4EF929E8AD8C00692964 /* table.c in Sources */,
83437987271D4A1900A5D6EA /* mention.c in Sources */,
CB9185D831D741DCB49AF8D3 /* wikilink.c in Sources */,
834A4F1429E8AD8C00692964 /* man.c in Sources */,
834A4F6529E8AD8E00692964 /* houdini_html_u.c in Sources */,
834A4F0C29E8AD8C00692964 /* xml.c in Sources */,
Expand Down Expand Up @@ -1715,6 +1726,7 @@
83720A2825B8E93D00B49FEC /* decode.c in Sources */,
834A4F8229E92AE800692964 /* extra-extensions.c in Sources */,
838109C3258403CA000AFE3C /* mention.c in Sources */,
0342FC81767440D68CFDD7B4 /* wikilink.c in Sources */,
834A4F6629E8AD8E00692964 /* registry.c in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
22 changes: 22 additions & 0 deletions QLMarkdown/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,7 @@
<gridRow topPadding="8" id="mRf-rL-ZFR"/>
<gridRow id="6bo-pC-VNr"/>
<gridRow id="axC-Xg-GDO"/>
<gridRow id="wkl-Rw-grd"/>
</rows>
<columns>
<gridColumn id="Kw4-iz-WrK"/>
Expand Down Expand Up @@ -1591,6 +1592,27 @@
</customSpacing>
</stackView>
</gridCell>
<gridCell row="wkl-Rw-grd" column="Kw4-iz-WrK" id="wkl-C0-cel">
<button key="contentView" toolTip="Render [[Page Name]] and [[Target|Display]] wikilinks as links." horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="wkl-Bt-btn">
<rect key="frame" x="0.0" y="0.0" width="117" height="16"/>
<buttonCell key="cell" type="check" title="Wikilinks" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="wkl-Bc-cel">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<binding destination="XfG-lQ-9wD" name="value" keyPath="self.wikilinkExtension" id="wkl-Vb-bnd"/>
<binding destination="XfG-lQ-9wD" name="enabled" keyPath="self.renderAsCode" id="wkl-Eb-bnd">
<dictionary key="options">
<string key="NSValueTransformerName">NSNegateBoolean</string>
</dictionary>
</binding>
</connections>
</button>
</gridCell>
<gridCell row="wkl-Rw-grd" column="h9h-fV-gFn" id="wkl-C1-cel"/>
<gridCell row="wkl-Rw-grd" column="LDl-3O-4gf" id="wkl-C2-cel"/>
<gridCell row="wkl-Rw-grd" column="Frg-Lu-cBX" id="wkl-C3-cel"/>
<gridCell row="wkl-Rw-grd" column="EM0-Js-ao5" id="wkl-C4-cel"/>
</gridCells>
</gridView>
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Ccb-oe-cYh">
Expand Down
1 change: 1 addition & 0 deletions QLMarkdown/Settings+ext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ extension Settings {
defaults.set(mermaidExtension.stripDefaultUrl(cacheUrl: self.mermaidFileUrl, cdnUrl: Self.mermaidWebUrl).toDict(), forKey: Self.CodingKeys.mermaidExtension.rawValue)

defaults.set(mentionExtension, forKey: Self.CodingKeys.mentionExtension.rawValue)
defaults.set(wikilinkExtension, forKey: Self.CodingKeys.wikilinkExtension.rawValue)
defaults.set(checkboxExtension, forKey: Self.CodingKeys.checkboxExtension.rawValue)
defaults.set(headsExtension, forKey: Self.CodingKeys.headsExtension.rawValue)

Expand Down
17 changes: 17 additions & 0 deletions QLMarkdown/Settings+render.swift
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,15 @@ extension Settings {
}
}

if self.wikilinkExtension {
if let ext = cmark_find_syntax_extension("wikilink") {
cmark_parser_attach_syntax_extension(parser, ext)
os_log("Enabled markdown `wikilink` extension.", log: OSLog.rendering, type: .debug)
} else {
os_log("Could not enable markdown `wikilink` extension!", log: OSLog.rendering, type: .error)
}
}

if self.headsExtension {
if let ext = cmark_find_syntax_extension("heads") {
cmark_parser_attach_syntax_extension(parser, ext)
Expand Down Expand Up @@ -650,6 +659,14 @@ table.debug td {
html_debug += "off"
}
html_debug += "</td></tr>\n"

html_debug += "<tr><td>wikilink extension</td><td>"
if self.wikilinkExtension {
html_debug += "on " + (cmark_find_syntax_extension("wikilink") == nil ? " (NOT AVAILABLE" : "")
} else {
html_debug += "off"
}
html_debug += "</td></tr>\n"

html_debug += "<tr><td>strikethrough extension</td><td>"
switch self.strikethroughExtension {
Expand Down
8 changes: 8 additions & 0 deletions QLMarkdown/Settings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ class Settings: Codable {
case mathExtension
case mermaidExtension
case mentionExtension
case wikilinkExtension
case subExtension
case supExtension
case tableExtension
Expand Down Expand Up @@ -475,6 +476,7 @@ class Settings: Codable {
var mathExtension: JSExtension = .link(url: nil)
var mermaidExtension: JSExtension = .link(url: nil)
var mentionExtension: Bool = false
var wikilinkExtension: Bool = false
var subExtension: Bool = false
var supExtension: Bool = false
var tableExtension: Bool = true
Expand Down Expand Up @@ -548,6 +550,7 @@ class Settings: Codable {
self.mermaidExtension = try container.decode(JSExtension.self, forKey:.mermaidExtension)

self.mentionExtension = try container.decode(Bool.self, forKey:.mentionExtension)
self.wikilinkExtension = try container.decode(Bool.self, forKey:.wikilinkExtension)
self.checkboxExtension = try container.decode(Bool.self, forKey:.checkboxExtension)
self.headsExtension = try container.decode(Bool.self, forKey:.headsExtension)
self.highlightExtension = try container.decode(Bool.self, forKey: .hightlightExtension)
Expand Down Expand Up @@ -625,6 +628,7 @@ class Settings: Codable {
try container.encode(self.mermaidExtension, forKey: .mermaidExtension)

try container.encode(self.mentionExtension, forKey: .mentionExtension)
try container.encode(self.wikilinkExtension, forKey: .wikilinkExtension)
try container.encode(self.checkboxExtension, forKey: .checkboxExtension)
try container.encode(self.headsExtension, forKey: .headsExtension)
try container.encode(self.highlightExtension, forKey: .hightlightExtension)
Expand Down Expand Up @@ -717,6 +721,7 @@ class Settings: Codable {
self.mathExtension = s.mathExtension
self.mermaidExtension = s.mermaidExtension
self.mentionExtension = s.mentionExtension
self.wikilinkExtension = s.wikilinkExtension
self.checkboxExtension = s.checkboxExtension
self.headsExtension = s.headsExtension

Expand Down Expand Up @@ -794,6 +799,9 @@ class Settings: Codable {
if let ext = defaultsDomain[Self.CodingKeys.mentionExtension.rawValue] as? Bool {
mentionExtension = ext
}
if let ext = defaultsDomain[Self.CodingKeys.wikilinkExtension.rawValue] as? Bool {
wikilinkExtension = ext
}
if let ext = defaultsDomain[Self.CodingKeys.checkboxExtension.rawValue] as? Bool {
checkboxExtension = ext
}
Expand Down
9 changes: 9 additions & 0 deletions QLMarkdown/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ class ViewController: NSViewController {
}
}

@objc dynamic var wikilinkExtension: Bool = Settings.factorySettings.wikilinkExtension {
didSet {
guard oldValue != wikilinkExtension else { return }
isDirty = true
}
}

@objc dynamic var syntaxHighlightExtension: Bool = Settings.factorySettings.syntaxHighlightExtension {
didSet {
guard oldValue != syntaxHighlightExtension else { return }
Expand Down Expand Up @@ -1357,6 +1364,7 @@ document.addEventListener('scroll', function(e) {
self.mermaidExtensionEmbed = settings.mermaidExtension.getMode()?.embed ?? false

self.mentionExtension = settings.mentionExtension
self.wikilinkExtension = settings.wikilinkExtension
self.syntaxHighlightExtension = settings.syntaxHighlightExtension

self.emojiExtension = settings.emojiExtension != .disabled
Expand Down Expand Up @@ -1418,6 +1426,7 @@ document.addEventListener('scroll', function(e) {
settings.mathExtension = self.mathExtension ? (self.mathExtensionEmbed ? .embed(url: nil) : .link(url: nil)) : .disabled
settings.mermaidExtension = self.mermaidExtension ? (self.mermaidExtensionEmbed ? .embed(url: nil) : .link(url: nil)) : .disabled
settings.mentionExtension = self.mentionExtension
settings.wikilinkExtension = self.wikilinkExtension

settings.emojiExtension = self.emojiExtension ? (self.emojiImageOption ? .images : .font) : .disabled

Expand Down
6 changes: 6 additions & 0 deletions Resources/default.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
--frame-border: #e3e4e8;
--frame-color: #242528;
--mention-color: #242528;
--wikilink-color: #8250df;
--email-toggle-color: #4b4d58; /* unused variable */
--email-toggle-background: #e3e4e8; /* unused variable */
--email-quoted-color: #6a6d7c; /* unused variable */
Expand Down Expand Up @@ -73,6 +74,7 @@
--frame-border: #ff08d6;
--frame-color: #242528;
--mention-color: #242528;
--wikilink-color: #ab7df8;
--email-toggle-color: #4b4d58;
--email-toggle-background: #e3e4e8;
--email-quoted-color: #6a6d7c;
Expand Down Expand Up @@ -175,6 +177,10 @@ a:hover {
text-decoration: underline;
}

.wikilink {
color: var(--wikilink-color);
}

details summary {
outline: 0;
}
Expand Down
2 changes: 2 additions & 0 deletions cmark-extra/extensions/extra-extensions.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "plugin.h"

#include "mention.h"
#include "wikilink.h"
// #include "checkbox.h"
#include "syntaxhighlight.h"
#include "inlineimage.h"
Expand All @@ -24,6 +25,7 @@

static int extra_extensions_registration(cmark_plugin *plugin) {
cmark_plugin_register_syntax_extension(plugin, create_mention_extension());
cmark_plugin_register_syntax_extension(plugin, create_wikilink_extension());
//cmark_plugin_register_syntax_extension(plugin, create_checkbox_extension());
cmark_plugin_register_syntax_extension(plugin, create_inlineimage_extension());

Expand Down
Loading