-
Notifications
You must be signed in to change notification settings - Fork 1
/
ObsidianKnittr.ahk
709 lines (698 loc) · 46.6 KB
/
ObsidianKnittr.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#Requires AutoHotkey v1.1.35+ ;; version at which script was written.
#SingleInstance Force
#MaxHotkeysPerInterval 99999999
#Warn All, Outputdebug
;#Persistent
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
DetectHiddenWindows On
SetKeyDelay -1,-1
SetBatchLines -1
SetTitleMatchMode 2
FileGetTime ModDate,%A_ScriptFullPath%,M
FileGetTime CrtDate,%A_ScriptFullPath%,C
CrtDate:=SubStr(CrtDate,7, 2) "." SubStr(CrtDate,5,2) "." SubStr(CrtDate,1,4)
ModDate:=SubStr(ModDate,7, 2) "." SubStr(ModDate,5,2) "." SubStr(ModDate,1,4)
global script := new script()
script := {base : script.base
, name : regexreplace(A_ScriptName, "\.\w+")
, crtdate : CrtDate
, moddate : ModDate
, resfolder : A_ScriptDir "\res"
, iconfile : ""
, version : ""
, config: []
, configfile : A_ScriptDir "\INI-Files\" regexreplace(A_ScriptName, "\.\w+") ".ini"
, configfolder : A_ScriptDir "\INI-Files"
, aboutPath : A_ScriptDir "\res\About.html"
, reqInternet: false
; , vfile_local : A_ScriptDir "\res\version.ini"
, authorID : "Laptop-C"
, Computername : A_ComputerName
, license : A_ScriptDir "\res\LICENSE.txt" ;; do not edit the variables above if you don't know what you are doing.
, blank : "" }
global DEBUG:=IsDebug()
main()
ExitApp 0
return
main() {
EL := new log(A_ScriptDir "\Executionlog.txt", true)
, fTraySetup()
, script.loadCredits(script.resfolder "\credits.txt")
, script.loadMetadata(script.resfolder "\meta.txt")
, erh:=Func("fonError").Bind(DEBUG,EL)
, onError(erh)
, exh:=Func("fonExit").Bind(DEBUG,EL)
, onExit(exh)
;; LOAD/INIT SCRIPT-CONFIGS
ATC_TOTAL1:=A_TickCount
if !script.load() {
RS_C:=rscript_check()
, OHTML_C:=obsidianhtml_check()
, QUARTO_C:=quarto_check()
if (!RS_C[1]) {
ttip("rscript not available")
if (InStr(rscript_path,"`n")){
rscript_path:=StrReplace(rscript_path, "`r`n")
, rscript_path:=StrSplit(rscript_path)
, found:=false
for _, path in rscript_path { ;; check if an installation of rscript is found; then check if there are multiple
if !InStr(path,".exe") { ;; skip wrong file formats.
continue
}
if (FileExist(path)) { ;; if a qualified hit is found, reassign it to the required variable, then break out.
found:=true
, rscript_path:=path
break
}
}
if (!found) { ;; no
InputBox rscript_path, % script.name,% "Please give the absolute path of your installed 'Rscript.exe'-file you wish to use.`nIf you don't want to use this step, leave this empty and continue.",,,,,,,, % "C:\Program Files\R\R-MAJORVERSION.MINORVERSION.PATCH\bin\Rscript.exe"
}
} else {
if !(FileExist(rscript_path)) {
InputBox rscript_path, % script.name,% "Please give the absolute path of your installed 'Rscript.exe'-file you wish to use.`nIf you don't want to use this step, leave this empty and continue.",,,,,,,, % "C:\Program Files\R\R-MAJORVERSION.MINORVERSION.PATCH\bin\Rscript.exe"
}
}
} else {
rscript_path:=RS_C[2]
}
if (!OHTML_C[1]) {
ttip()
Message:="The external python 3.11-package ObsidianHTML was not found.`nWithout this package, this program cannot function. Please set up ObsidianHTML first, then rerun this program."
, Title:="External Dependency not found."
AppError(Title, Message)
}
if (!QUARTO_C[1]) {
ttip("quarto not available")
}
if (!InStr(FileExist(script.configfolder),"D")) {
FileCreateDir % script.configfolder
}
setupDefaultConfig(script.configfile,RS_C,OHTML_C,QUARTO_C)
, script.load()
, writeFile(A_ScriptDir "\INI-Files\ObsidianKnittr_Version.ini",script.config.Version.ObsidianKnittr_Version,"UTF-16")
}
if (FileExist(OK_V:=A_ScriptDir "\INI-Files\ObsidianKnittr_Version.ini")) {
FileRead ObsidianKnittr_Version, % OK_V
} else {
if (script.config.HasKey("Version")) {
ObsidianKnittr_Version:=script.config.Version.ObsidianKnittr_Version
, writeFile(A_ScriptDir "\INI-Files\ObsidianKnittr_Version.ini",script.config.Version.ObsidianKnittr_Version,"UTF-16")
}
}
script.version:=script.config.version.ObsidianKnittr_Version:=Regexreplace(ObsidianKnittr_Version,"\s*")
, clArgs:=A_Args
/*
clArgs:=["-h"]
clArgs:=["path=D:\Dokumente neu\Obsidian NoteTaking\The Universe\200 University\06 Interns and Unis\BE28 Internship Report\Submission\BE28 Internship Report.md","format=quarto::html","format=quarto::docx","LastExecutionDirectory=0","OHTMLLevel=2"]
clArgs:=["path=D:\Dokumente neu\Obsidian NoteTaking\BE31-Thesis\100 Thesis\Submission\BE31 Thesis Report.md","format=quarto::html","Verbose=0","UseOwnOHTMLFork=1","LastExecutionDirectory=1","OHTMLLevel=2","quarto::html.number-depth=2","quarto::html.author=Manfred von Karma","quarto::html.toc=1","quarto::html.toc-location=left"]
clArgs:=["path=C:\Users\Claudius Main\Desktop\TempTemporal\BE31-Thesis-quarto\Report\___manuscript.md","format=quarto::html","Verbose=0","UseOwnOHTMLFork=1","LastExecutionDirectory=1","OHTMLLevel=-1","RenderToOutputs=0","--noMove","--noRender","--noOpen","--noIntermediates"]
clArgs:=["path=C:/Users/Claudius Main/Desktop/TempTemporal/BE31-Thesis-quarto/documentation/methods/___grain-success.md","format=quarto::html","Verbose=0","UseOwnOHTMLFork=1","LastExecutionDirectory=1","OHTMLLevel=-1","RenderToOutputs=0","--noMove","--noRender","--noOpen","--noIntermediates"]
clArgs:=["path=D:\Dokumente neu\Obsidian NoteTaking\BE31-Thesis-quarto\documentation\methods\___grain-success.md","format=quarto::html","Verbose=0","UseOwnOHTMLFork=1","LastExecutionDirectory=1","OHTMLLevel=1","RenderToOutputs=0","--noMove","--noRender","--noOpen","--notify"]
clArgs:=["format=quarto::html","Verbose=1","UseOwnOHTMLFork=1","LastExecutionDirectory=1","OHTMLLevel=-1","RenderToOutputs=0","--noMove","--noRender","--noOpen","--noIntermediates","path=D:\Dokumente neu\Obsidian NoteTaking\BE31-Thesis-quarto/documentation/methods/___grain-success.md"]
clArgs:=["OHTMLLevel=0","format=quarto::docx","format=quarto::html","Verbose=3","UseOwnOHTMLFork=1","LastExecutionDirectory=1","RenderToOutputs=0","--noRender","--notify","--noIntermediates","--noOpen","path=D:\Dokumente neu\Obsidian NoteTaking\The Universe\019-Bugtesting-Subvault\nesting\nesting2\nesting3\019-ObsHTML_EmbeddedTitleStripping_Main.md"]
clArgs:=["format=quarto::docx","format=quarto::html","OHTMLLevel=2","Verbose=0","UseOwnOHTMLFork=1","LastExecutionDirectory=1","RenderToOutputs=0","--notify","--noIntermediates","--noMove","--noOpen","path=D:\Dokumente neu\Obsidian NoteTaking\The Universe\019-Bugtesting-Subvault\nesting\nesting2\nesting3\019-ObsHTML_EmbeddedTitleStripping_Main.md"]
clArgs:=["format=quarto::html","quarto::html.author=Professor E. Gadd","OHTMLLevel=2","--OHTML.UseCustomFork","--OHTML.Convert","LastExecutionDirectory=1","--notify","--noIntermediates","--noMove","--noOpen","--noOKLOG","path=D:\Dokumente neu\Obsidian NoteTaking\The Universe\019-Bugtesting-Subvault\nesting\nesting2\nesting3\019-ObsHTML_EmbeddedTitleStripping_Main.md"]
clArgs:=["format=quarto::html","quarto::html.author=Professor E. Gadd","OHTMLLevel=2","--OHTML.UseCustomFork","--OHTML.Convert","LastExecutionDirectory=1","--notify","--noIntermediates","--noMove","--noOpen","path=D:\Dokumente neu\Obsidian NoteTaking\The Universe\019-Bugtesting-Subvault\nesting\nesting2\nesting3\019-ObsHTML_EmbeddedTitleStripping_Main.md"]
clArgs:=["format=quarto::html","quarto::html.author=Professor E. Gadd","OHTMLLevel=2","--OHTML.UseCustomFork","--OHTML.Convert","LastExecutionDirectory=1","--notify","--noIntermediates","IntermediatesRemovalLevel=4","--noMove","--noOpen","path=D:\Dokumente neu\Obsidian NoteTaking\The Universe\200 University\06 Interns and Unis\BE28 Internship Report\Submission\BE28 Internship Report.md"]
clArgs:=["format=quarto::html","quarto::html.author=Professor E. Gadd","OHTMLLevel=2","--OHTML.UseCustomFork","--OHTML.Convert","LastExecutionDirectory=1","--notify","--noIntermediates","IntermediatesRemovalLevel=4","--noOpen","path=D:\Dokumente neu\Obsidian NoteTaking\The Universe\200 University\06 Interns and Unis\BE28 Internship Report\Submission\BE28 Internship Report.md"]
if (DEBUG && GetKeyState("LShift","P")) {
clArgs:=["path=D:\Dokumente neu\Obsidian NoteTaking\BE31-Thesis-quarto\Report\___manuscript.md","format=quarto::html","LastExecutionDirectory=1","OHTMLLevel=-1","Verbose=1","--OHTML.Convert","--OHTML.UseCustomFork","--OHTML.TrimErrors","--noMove","--noRender","--noOpen","--notify","--noIntermediates","--SourceNameIndex"]
}
clArgs:=["format=quarto::html","quarto::html.author=Professor E. Gadd","OHTMLLevel=2","--OHTML.UseCustomFork","--OHTML.Convert","--OHTML.TrimErrors","--notify","--noIntermediates","IntermediatesRemovalLevel=4","--noOpen","--Quarto.TrimRefTypes","path=D:\Dokumente neu\Obsidian NoteTaking\The Universe\200 University\06 Interns and Unis\BE28 Internship Report\Submission\BE28 Internship Report.md"]
clArgs:=["format=quarto::html","quarto::html.author=Professor E. Gadd","OHTMLLevel=2","--OHTML.UseCustomFork","--OHTML.Convert","--OHTML.TrimErrors","LastExecutionDirectory=0","--notify","--noIntermediates","IntermediatesRemovalLevel=4","--noOpen","--Quarto.TrimRefTypes","path=D:\Dokumente neu\Obsidian NoteTaking\The Universe\200 University\06 Interns and Unis\BE28 Internship Report\Submission\BE28 Internship Report.md"]
clArgs:=["format=quarto::html","quarto::html.author=Professor E. Gadd","OHTMLLevel=2","--OHTML.UseCustomFork","--OHTML.Convert","--OHTML.TrimErrors","LastExecutionDirectory=1","--notify","--noIntermediates","IntermediatesRemovalLevel=4","--noOpen","--Quarto.TrimRefTypes","path=D:\Dokumente neu\Obsidian NoteTaking\The Universe\200 University\06 Interns and Unis\BE28 Internship Report\Submission\BE28 Internship Report.md"]
clArgs:=["format=quarto::html","quarto::html.author=Professor E. Gadd","OHTMLLevel=2","--OHTML.UseCustomFork","--OHTML.Convert","--OHTML.TrimErrors","LastExecutionDirectory=2","--notify","--noIntermediates","IntermediatesRemovalLevel=4","--noOpen","--Quarto.TrimRefTypes","path=D:\Dokumente neu\Obsidian NoteTaking\The Universe\200 University\06 Interns and Unis\BE28 Internship Report\Submission\BE28 Internship Report.md"]
clArgs:=["format=quarto::html","quarto::html.author=Professor E. Gadd","OHTMLLevel=2","--OHTML.UseCustomFork","--OHTML.Convert","--OHTML.TrimErrors","LastExecutionDirectory=3","--notify","--noIntermediates","IntermediatesRemovalLevel=4","--noOpen","--Quarto.TrimRefTypes","path=D:\Dokumente neu\Obsidian NoteTaking\The Universe\200 University\06 Interns and Unis\BE28 Internship Report\Submission\BE28 Internship Report.md"]
clArgs:=["format=quarto::html","quarto::html.author=Professor E. Gadd","OHTMLLevel=2","--OHTML.UseCustomFork","--OHTML.Convert","--OHTML.TrimErrors","LastExecutionDirectory=4","--notify","--noIntermediates","IntermediatesRemovalLevel=4","--noOpen","--Quarto.TrimRefTypes","path=D:\Dokumente neu\Obsidian NoteTaking\The Universe\200 University\06 Interns and Unis\BE28 Internship Report\Submission\BE28 Internship Report.md"]
clArgs:=["format=quarto::html","quarto::html.author=Professor E. Gadd","--OHTML.UseCustomFork","--OHTML.Convert","--OHTML.TrimErrors","LastExecutionDirectory=5","--notify","--noIntermediates","IntermediatesRemovalLevel=4","--noOpen","--Quarto.TrimRefTypes","--keepFilename","path=D:\Dokumente neu\Obsidian NoteTaking\The Universe\200 University\06 Interns and Unis\BE28 Internship Report\Submission\BE28 Internship Report.md"]
clArgs:=["format=quarto::html","quarto::html.author=Professor E. Gadd","OHTMLLevel=2","RestrictOHTMLScope=0","--OHTML.UseCustomFork","--OHTML.Convert","--OHTML.TrimErrors","LastExecutionDirectory=5","--notify","--noIntermediates","IntermediatesRemovalLevel=4","--noOpen","--Quarto.TrimRefTypes","--keepFilename","path=D:\Dokumente neu\Obsidian NoteTaking\The Universe\200 University\06 Interns and Unis\BE28 Internship Report\Submission\BE28 Internship Report.md"]
*/
if (!clArgs.length()) {
guiOut:=guiShow()
} else {
CLIArgs:=parseA_Args(clArgs)
if (HasVal(CLIArgs, "-h") || CLIArgs.HasKey("-h")) {
CLI_help()
ExitApp 2
} else if (HasVal(CLIArgs,"-v") || CLIArgs.HasKey("-v")) {
ttip(script.name " - " script.version,5)
while (1) {
if GetKeyState("Escape") {
break
}
}
ExitApp 2
} else {
if !requireA_Args(CLIArgs) {
msgbox % "error: arguments could not be validated. Missings Args?`n`nExpand upon this error message."
ExitApp -1
} else {
processCLIFlags(CLIArgs)
processCLIArgs(CLIArgs)
}
validateCLIArgs(CLIArgs)
, script.config.LastRun.manuscriptpath:=CLIArgs.path
, script.config.DDLHistory:=buildHistory(script.config.DDLHistory,script.config.Config.HistoryLimit,script.config.LastRun.manuscriptpath)
, script.config.LastRun.last_output_type:=CLIArgs.format
if (CLIArgs.noOKLog) { ;; disable logging by immediately returning out of the 'class.__Set()'-call
EL.toggleAutoWrite(0) ;; don't write every new change to file directly ;; works for both error and exit
} else {
EL.toggleAutoWrite(1) ;; write every new change to file directly ;; works for both error and exit
}
global manuscriptpath:=CLIArgs.path
guiOut:=guiShow(true,CLIArgs)
}
}
;; POPULATE EL WITH VALUES
EL.manuscriptname:=guiOut.manuscriptname
, EL.formats:=concat_formats(guiOut.Outputformats)
, EL.manuscriptpath:=guiOut.manuscriptpath
, EL.bVerboseCheckbox:=guiOut.Settings.bVerboseCheckbox
, EL.bKeepFilename:=guiOut.Settings.bKeepFilename
, EL.bRendertoOutputs:=guiOut.Settings.bRendertoOutputs
, EL.bRemoveHashTagFromTags:=guiOut.Settings.bRemoveHashTagFromTags
, EL.bConvertInsteadofRun:=guiOut.Settings.bConvertInsteadofRun
, EL.bRemoveObsidianHTMLErrors:=guiOut.Settings.bRemoveObsidianHTMLErrors
, EL.bStripLocalMarkdownLinks:=guiOut.Settings.bStripLocalMarkdownLinks
, EL.bUseOwnOHTMLFork:=guiOut.Settings.bUseOwnOHTMLFork
, EL.bRestrictOHTMLScope:=guiOut.Settings.bRestrictOHTMLScope
, EL.bRemoveQuartoReferenceTypesFromCrossrefs:=guiOut.Settings.bRemoveQuartoReferenceTypesFromCrossrefs
, EL.ObsidianKnittr_Version:=Regexreplace(ObsidianKnittr_Version,"\s*")
if (guiOut.sel="") && (guiOut.Settings.bVerboseCheckbox="") && (!CLIArgs.Count()) {
ExitApp -1
}
;; OBSIDIANHTML SETUP CONFIGFILE
obsidianhtml_configfile:=script.config.config.obsidianhtml_configfile
tmpObsidianHTML_Config:=createTemporaryObsidianHTML_Config(guiOut.manuscriptpath, obsidianhtml_configfile,guiOut.Settings.bConvertInsteadofRun,guiOut.Settings.bUseOwnOHTMLFork)
, EL.configtemplate_path:=obsidianhtml_configfile
, EL.configfile_contents:=tmpObsidianHTML_Config[2]
notify("Running ObsidianHTML",CLIArgs)
if (obsidianhtml_configfile="") {
obsidianhtml_configfile:=script.config.config.obsidianhtml_configfile
}
EL.ObsidianHTML_Start:=A_DD "." A_MM "." A_YYYY " - " A_Hour ":" A_Min ":" A_Sec
ATC1:=A_TickCount
Codetimer_Log()
;; OBSIDIANHTML SETUP VAULT LIMITER
OHTML_OutputDir:=Deref(script.config.config.OHTML_OutputDir)
, OHTML_WorkDir:=Deref(script.config.config.OHTML_WorkDir)
, OHTML_WorkDir_OwnFork := script.config.Config.OHTML_WorkDir_OwnFork ; "D:\Dokumente neu\ObsidianPluginDev\obsidian-html"
if (guiOut.Settings.bRestrictOHTMLScope) {
if (CLIArgs!="") && (FileExist(CLIArgs.path)) { ;; CLI-path
OHTMLScopeRestrictor_Object:=createTemporaryObsidianVaultRoot(guiOut.manuscriptpath,guiOut.Settings.bAutoSubmitOTGUI,CLIArgs.OHTMLLevel,CLIArgs)
} else { ;; GUI-path
if (guiOut.manuscriptpath==script.config.LastRun.path_lastmanuscript) {
OHTMLScopeRestrictor_Object:=createTemporaryObsidianVaultRoot(guiOut.manuscriptpath,guiOut.Settings.bAutoSubmitOTGUI,script.config.LastRun.LastRelativeLevel)
} else {
script.config.LastRun.LastRelativeLevel:=-1
OHTMLScopeRestrictor_Object:=createTemporaryObsidianVaultRoot(guiOut.manuscriptpath,guiOut.Settings.bAutoSubmitOTGUI)
}
}
if (!OHTMLScopeRestrictor_Object.IsVaultRoot) { ;; ensure that the Restrictor-`.obsidian`-path gets removed in case of an error.
OnExit(Func("removeTempDir").bind(OHTMLScopeRestrictor_Object.Path,false))
OnError(Func("removeTempDir").bind(OHTMLScopeRestrictor_Object.Path,false))
}
}
;; OBSIDIANHTML EXECUTE OBSIDIANHTML
if (tmpObsidianHTML_Config[1] && guiOut.Settings.bConvertInsteadofRun) {
obsidianhtml_ret:=ObsidianHtml(,tmpObsidianHTML_Config[1],,guiOut.Settings.bUseOwnOHTMLFork,guiOut.Settings.bVerboseCheckbox,OHTML_OutputDir,OHTML_WorkDir,OHTML_WorkDir_OwnFork,OHTMLScopeRestrictor_Object,guiOut.Settings.bAutoSubmitOTGUI)
} else {
obsidianhtml_ret:=ObsidianHtml(guiOut.manuscriptpath,tmpObsidianHTML_Config[1],,guiOut.Settings.bUseOwnOHTMLFork,guiOut.Settings.bVerboseCheckbox,OHTML_OutputDir,OHTML_WorkDir,OHTML_WorkDir_OwnFork,OHTMLScopeRestrictor_Object,guiOut.Settings.bAutoSubmitOTGUI)
}
;; OBSIDIANHTML REMOVE VAULT LIMITER
if (guiOut.Settings.bRestrictOHTMLScope) {
tempOVaultRoot:=removeTemporaryObsidianVaultRoot(OHTMLScopeRestrictor_Object.Path,OHTMLScopeRestrictor_Object.Graph)
if (tempOVaultRoot.Removed) {
EL.temporaryVaultpath:=OHTMLScopeRestrictor_Object.Path
, EL.temporaryVaultpathRemoved:="Yes"
OnExit(Func("removeTempDir"),0) ;; as the folder has been removed successfully, we can now remove this callback. #FIXME: This does not seem to work at all. Why?
OnError(Func("removeTempDir"),0)
} else {
if tempOVaultRoot.IsVaultRoot {
EL.temporaryVaultpath:=OHTMLScopeRestrictor_Object.Path
, EL.temporaryVaultpathRemoved:="No - vault root"
} else {
EL.temporaryVaultpath:=OHTMLScopeRestrictor_Object.Path
, EL.temporaryVaultpathRemoved:="No - not removed, but not vault root"
}
}
}
;; OBSIDIANHTML POSTPROCESS RESULTS
EL.ObsidianHTML_Duration:=Codetimer_Log()
, EL.ObsidianHTML_End:=A_DD "." A_MM "." A_YYYY " - " A_Hour ":" A_Min ":" A_Sec
, EL.obsidianhtml_version:=strreplace(obsidianhtml_ret.obsidianhtml_version,"`n")
, EL.obsidianhtml_path:=obsidianhtml_ret.obsidianhtml_path
, EL.UsedVerb:=(guiOut.Settings.bConvertInsteadofRun?"Convert":"Run")
, EL.ObsidianHTMLWorkDir:=obsidianhtml_ret["WorkDir"]
, EL.ObsidianHTMLOutputpath:=obsidianhtml_ret["Outputpath"]
, EL.ObsidianHTMLCopyDir:=obsidianhtml_ret["ObsidianHTMLCopyDir"]
, EL.ObsidianHTMLCMD:=obsidianhtml_ret["CMD"]
, EL.ObsidianHTMLstdOut:=obsidianhtml_ret["stdOut"]
vMDPath:=getObsidianHTML_MDPath(obsidianhtml_ret)
;; INTERMEDIARY PROCESSING
;; Intermediary
EL.Intermediary_Start:=A_DD "." A_MM "." A_YYYY " - " A_Hour ":" A_Min ":" A_Sec
Codetimer_Log()
notify("Converting to .rmd-file",CLIArgs)
rmd_Path:=convertMDToRMD(vMDPath,"index")
; 5, 6
notify("Moving to output folder",CLIArgs)
Destination:=(InStr(Deref(guiOut.Settings.ExecutionDirectory),A_Desktop)?0:guiOut.Settings.ExecutionDirectory)
, rmd_Path:=copyBack(rmd_Path,Destination,guiOut.manuscriptpath)
SplitPath % rmd_Path,, OutDir
rawinputCopyLocation:=regexreplace(OutDir "\" guiOut.manuscriptName "_vault.md","\\{2,}","\")
, EL.output_path
, EL.rawInputcopyLocation:=rawinputCopyLocation
; 7
notify("Converting Image SRC's",CLIArgs)
NewContents:=ConvertSRC_SYNTAX_V4(rmd_Path,guiOut.Settings.bRemoveObsidianHTMLErrors,guiOut.Settings.bStripLocalMarkdownLinks)
notify("Processing Tags",CLIArgs)
NewContents:=processTags(NewContents,guiOut.Settings.bRemoveHashTagFromTags)
notify("Processing Abstract",CLIArgs)
NewContents:=processAbstract(NewContents)
for _, format in guiOut.Outputformats { ;; rmd → qmd conversion
if (format.package="quarto") {
notify("Convert to QMD",CLIArgs)
qmdContents:=convertToQMD(NewContents,guiOut.Settings.bRemoveQuartoReferenceTypesFromCrossrefs)
, qmd_Path:=strreplace(rmd_Path,".rmd",".qmd")
break ;; if a format is of quarto, run the quarto-conversion once, then continue on.
}
}
;; postprocess rmd-filecontent (some of the steps below are already done to qmd-content during `convertToQMD()`)
NewContents:=cleanLatexEnvironmentsforRMarkdown(NewContents)
, NewContents:=fixNullFields(NewContents)
, EL.Intermediary_Duration:=Codetimer_Log()
, EL.Intermediary_End:=A_DD "." A_MM "." A_YYYY " - " A_Hour ":" A_Min ":" A_Sec
;; COMPILE VIA RSCRIPT OR QUARTO_CLI
EL.Compilation_Start:=A_DD "." A_MM "." A_YYYY " - " A_Hour ":" A_Min ":" A_Sec
, Codetimer_Log()
, writeFile(rmd_Path,NewContents,"UTF-8",,true)
if (qmd_Path!="") {
if (CLIArgs.noMove) {
qmd_Path:=regexreplace(guiOut.manuscriptdir "\" guiOut.manuscriptname ".qmd","\\{2,}","\")
, qmdContents:=quartopurgeTags(qmdContents)
}
if (CLIArgs.noContent) {
/*
;; #TODO decide if I want to implement this as an actual feature
;; or just as a commandline arg to extract the outline into its own file to be rendered, e.g.
qmd_Path_structure:=regexreplace(guiOut.manuscriptdir "\" guiOut.manuscriptname "_structure.qmd","\\{2,}","\")
*/
qmdOutline:=quartopurgeContents(qmdContents)
answer:=AppError("Save outline-doc?", "Do you want to save the outline of the current document as a separte qmd-file?`nOtherwhise, the contents of the document will be copied to the clipboard.", Options := 0x24, TitlePrefix := "",Timeout:=0)
if (answer=="Yes") {
qmdOutline_Path:=regexreplace(guiOut.manuscriptdir "\" guiOut.manuscriptname "_outline.qmd","\\{2,}","\")
writeFile(qmdOutline_Path,qmdOutline,"UTF-8-RAW",,true)
MsgBox % "written outline to '" qmdOutline_Path "'"
} else {
Clipboard:=qmdOutline
}
}
writeFile(qmd_Path,qmdContents,"UTF-8-RAW",,true)
}
if (script.config.config.useQuartoCLI) {
EL.Quarto_Version:=quartogetVersion()
if (guiOut.Settings.bRendertoOutputs) {
if (guiOut.Settings.bBackupOutput && !CLIArgs.noMove) {
ttip(-1)
notify("Backing up Files",CLIArgs)
BackupDirectory:=backupOutput(qmd_Path,guiOut)
}
if (script.config.config.backupCount) {
limitBackups(BackupDirectory,script.config.config.backupCount)
}
ttip(-1)
notify("Executing quarto-CLI",CLIArgs)
SplitPath % qmd_Path,, OutDir
quarto_ret:=["","",OutDir]
tmp:=""
for _, output_type in guiOut.sel {
;; use "index.qmd" if we explicitly use the flag to do so, or if we are not running in CLI-mode.
if (CLIArgs.SourceNameIndex || CLIArgs="") {
SourceFileName:="index"
} else {
SourceFileName:=guiOut.manuscriptname
}
if (guiOut.Settings.bkeepFilename) {
guiOut.Outputformats[output_type].filename:=guiOut.manuscriptname
guiOut.Outputformats[output_type].filenameMod:=" (" guiOut.Outputformats[output_type].package ")"
}
tmp.=output_type ":`n" write_quarto_yaml(guiOut.Outputformats[output_type],OutDir,"qCLI_yaml_" guiOut.Outputformats[output_type].filesuffix ".yaml")
, CMD:="quarto render " SourceFileName ".qmd --to " guiOut.Outputformats[output_type].filesuffix
, CMD.=" --metadata-file=""qCLI_yaml_" guiOut.Outputformats[output_type].filesuffix ".yaml"""
, CMD.=" --output """ guiOut.Outputformats[output_type].Filename guiOut.Outputformats[output_type].FilenameMod "." guiOut.Outputformats[output_type].filesuffix """"
, GetStdStreams_WithInput(CMD, OutDir, InOut:="`n")
, quarto_ret[1].="`nFormat " output_type ":`n" InOut
, quarto_ret[2].=CMD
if (DEBUG) {
Clipboard:=(IsObject(InOut)?ttip_Obj2Str(InOut):InOut)
}
if (!CLIArgs.noIntermediates) {
writeFile(OutDir "\build_" guiOut.Outputformats[output_type].filesuffix ".cmd",CMD,"UTF-8-RAW",,true)
}
}
EL.Rdata_out:=quarto_ret[1]
, EL.RCMD:=quarto_ret[2]
, EL.RWD:=quarto_ret[3]
EL.DocumentSettings:=tmp
}
} else {
notify("Creating R-BuildScript",CLIArgs)
if (guiOut.Settings.bKeepFilename) {
tmp:=buildRScriptContent(rmd_Path,guiOut.manuscriptName,guiOut)
} else {
tmp:=buildRScriptContent(rmd_Path,,guiOut)
}
if (qmd_Path!="") {
tmp.1:=modifyQuartobuildscript(tmp.1,tmp.3,guiOut)
}
format:=tmp.2
script_contents:=tmp.1
if (guiOut.Settings.bRendertoOutputs) {
ttip(-1)
notify("Executing R-BuildScript",CLIArgs)
if (guiOut.Settings.bBackupOutput) {
BackupDirectory:=backupOutput(rmd_Path,guiOut)
}
if (script.config.config.backupCount) {
limitBackups(BackupDirectory,script.config.config.backupCount)
}
rscript_ret:=runRScript(rmd_Path,script_contents,guiOut.Outputformats,script.config.config.RScriptPath)
EL.Rdata_out:=rscript_ret[1]
, EL.RCMD:=rscript_ret[2]
, EL.RWD:=rscript_ret[3]
} Else {
notify("Opening RMD-File",CLIArgs)
SplitPath % rmd_Path,, OutDir
writeFile(OutDir "\build.R",script_contents,"UTF-8-RAW",,true)
if (!DEBUG) {
run % rmd_Path
}
}
;; create ahk starter if running via rscript
notify("Building AHK-Starterscript",CLIArgs)
buildAHKScriptContent(rmd_Path,script.config.config.RScriptPath)
EL.DocumentSettings:=tmp[2]
}
EL.Compilation_Duration:=Codetimer_Log()
, EL.Compilation_End:=A_DD "." A_MM "." A_YYYY " - " A_Hour ":" A_Min ":" A_Sec
, EL.getTotalDuration(ATC1,A_TickCount)
, EL.getTotalDuration(ATC_TOTAL1,A_TickCount,"TOTAL_COUNT")
;; moving shit to output folder
SplitPath % Path,, OutDir
SplitPath % OutDir,, OutDir2
if (script.config.config.OpenParentfolderInstead) {
EL.output_path:=OutDir
} else {
EL.output_path:=OutDir2
}
if !DEBUG && !CLIArgs.HasKey("--noOpen") {
openFolder(rmd_Path)
}
SplitPath % rmd_Path,, OutDir
if (!CLIArgs.noMove) {
if (FileExist(quarto_ret[3])) {
; removeTempDir(quarto_ret[3],false) ;; FIXME: Which directory should get remvoed here? Under which conditions?
} else if (FileExist(rscript_ret.Output_Path)) {
; removeTempDir(rscript_ret.OutputPath,false)
}
}
;; CLEANUP
if (CLIArgs.count()) {
if (FileExist(EL.__path)) {
if (CLIArgs.noOKLog) {
FileDelete % EL.__path
} else if (CLIArgs.keepOKLog) {
FileMove % EL.__path , % A_ScriptDir "\Executionlog (" guiOut.manuscriptname ").txt", true
} else { ;; only copy back the log if it is required
SplitPath % rmd_Path,, OutDir
FileMove % EL.__path, % OutDir "\Executionlog.txt",true
}
}
} else {
FileMove % EL.__path, % OutDir "\Executionlog.txt",true
}
if (CLIArgs.noIntermediates) {
guiOut.removableintermediates:=collectQuartoIntermediates(guiOut,CLIArgs)
failedRemovals:=cleanupIntermediatequartoFiles(guiOut)
if (failedRemovals.Count()) {
Title:=": clean-up of intermediates unsuccessful"
Message:="The following intermediate-files resulting from executing quarto could not be removed:"
for _, path in failedRemovals {
Message.="`n '" path "'"
}
Message.="`n`nYou may either ignore this warning, or remove them yourself"
AppError(Title, Message,0x40010," > " A_ThisFunc)
}
}
if (!CLIArgs.Count()) { ;; only change config when running in GUI mode
script.config.LastRun.manuscriptpath:=StrReplace(script.config.LastRun.manuscriptpath, "/","\")
script.save()
}
return
}
openFolder(Path) {
SplitPath % Path,, OutDir
SplitPath % OutDir, OutFileName, OutDir2
if (WinExist(OutFileName " ahk_exe explorer.exe")) {
WinActivate
return
}
if (script.config.config.OpenParentfolderInstead) {
run % OutDir2
} else {
run % OutDir
}
return
}
buildAHKScriptContent(Path,RSCRIPT_PATH:="") {
SplitPath % Path,, OutDir
if (script.config.config.bundleStarterScript && (RSCRIPT_PATH!="")) {
BUILD_RPATH:=strreplace(OutDir "\build.R","\","\\")
, OUTDIR_PATH:=OutDir
AHK_Build=
(Join`s LTRIM
#Requires AutoHotkey v1.1.36+
`nrun, `% `"`"`"%RSCRIPT_PATH%"""
A_Space """%BUILD_RPATH%"""
, `% "%OUTDIR_PATH%"
)
writeFile(OutDir "\build.ahk",AHK_Build,"UTF-8",,true)
}
return
}
copyBack(Source,noDesktopDestination,manuscript_path) {
SplitPath % Source, OutFileName, Dir,
SplitPath % manuscript_path,,,,manuscript_name,
if noDesktopDestination {
FileCopyDir % Dir, % Output_Path:=regexreplace(noDesktopDestination "\" manuscript_name "\","\\{2,}","\"), true
writeFile(Output_Path "\index.md",manuscriptcontent,,,true)
pd:=Trim(regexreplace(Output_Path "\" manuscript_name "_vault.md ","\\{2,}","\"))
FileCopy % manuscript_path, % pd, 1
} Else {
FileCopyDir % Dir, % Output_Path:= A_Desktop "\TempTemporal\" manuscript_name "\" , true
if Errorlevel {
msgbox % Errorlevel
}
pd:=Trim(regexreplace(Output_Path "\" manuscript_name "_vault.md ","\\{2,}","\"))
FileCopy % manuscript_path, % pd, 1
}
path:=regexreplace(Output_Path OutFileName,"\\{2,}","\")
return path
}
removeTempDir(Path,RemoveParent:=TRUE) {
SplitPath % Path,, OutDir
if RemoveParent {
FileRemoveDir % OutDir,1
if FileExist(OutDir) {
Title:=": folder is busy"
Message:="The temp-directory '" OutDir "' could not be removed"
AppError(Title, Message,0x40010," > " A_ThisFunc)
Run % "explorer " OutDir
}
} else {
FileRemoveDir % Path,1
if FileExist(Path) {
Title:=": folder is busy"
Message:="The temp-directory '" OutDir "' could not be removed"
AppError(Title, Message,0x40010," > " A_ThisFunc)
Run % "explorer " Path
}
}
return
}
getPotentialWorkDir(File,ExecutionDirectory) {
gui submit, nohide
SplitPath % File,, OutDir
ExecutionDirectories:= OutDir "\ObsidianKnittr_output"
return {relativeToNote:ExecutionDirectory,ExecutionDirectories:ExecutionDirectories}
}
getDefinedOutputFormats(Path) {
PotentialOutputs:=["bookdown::word_document2", "html_document", "bookdown::html_document2", "bookdown::pdf_document2", "odt_document", "rtf_document", "md_document", "tufte::tufte_html", "github_document"]
, Arr:=[]
, filesuffixes:=[]
, inputsuffixes:=[]
if !FileExist(Path) {
Gui +OwnDialogs
Title:="File not found"
Message:="A required file containing the GUI definitions for the output formats does not exist under `n`n'" Path "`n`nThis script will only use the default options for any format not found in this file"
AppError(Title, Message,0x40030," > " A_ThisFunc)
Arr:=PotentialOutputs ;; fallback to hardcoded default
} else {
FileRead FileString, % Path
if (!InStr(FileString,"`r`n") && InStr(FileString,"`n")) {
FileString:=StrReplace(FileString, "`n","`r`n")
writeFile(Path,FileString,,,true)
FileRead FileString, % Path
}
Lines:=strsplit(FileString,"`r`n")
bFindSuffix:=false
for _, Line in Lines {
if SubStr(LTrim(Line),1,1)=";" {
continue
}
if (Line="") {
continue
} else {
if (RegexMatch(Line,"m)^\S")) {
Pos:=HasVal(PotentialOutputs,Line)
, PotentialOutputs.RemoveAt(Pos,1)
, Arr.push(Line)
, bFindSuffix:=true
}
}
if (bFindSuffix) {
if InStr(Line, "filesuffix:Meta") {
filesuffixes[Arr[Arr.MaxIndex()]]:=strsplit(Line,"Value:").2
}
if InStr(Line, "inputsuffix:Meta") {
inputsuffixes[Arr[Arr.MaxIndex()]]:=strsplit(Line,"Value:").2
}
}
}
for _, potential_output_type in PotentialOutputs {
Arr.push(potential_output_type)
}
}
return [Arr,filesuffixes,inputsuffixes]
}
concat_formats(formats) {
for _,format in formats {
if format.HasKey("Error") && (format.Error.ID=0) {
Reload
ExitApp -1 ;; fucking weird bug. DO NOT remove this exitapp below the reload-command. for some reason, removing it results in the script just ignoring the reload and continuing on as normal under certain situations
}
format_str.=_ ", "
}
format_str:=SubStr(format_str,1,StrLen(format_str)-2)
return format_str
}
buildHistory(History,NumberOfRecords,manuscriptpath:="") {
if (manuscriptpath!="") {
if HasVal(History,manuscriptpath) {
History.RemoveAt(HasVal(History,manuscriptpath),1)
}
History.InsertAt(1,manuscriptpath)
}
if (History.Count()>NumberOfRecords) {
History.Delete(NumberOfRecords+1,History.Count())
}
h:=[]
for _, file in History {
h.push(file)
}
History:=h.clone()
return History
}
editMainConfig(configfile) {
static
gui Submit, NoHide
RunWait % configfile,,,PID
WinWaitClose % "ahk_PID" PID
Gui +OwnDialogs
OnMessage(0x44, "DA_OnMsgBox")
Title:=this.ClassName " > " A_ThisFunc
Message:="You modified the configuration for this class.`nReload?"
AppError(Title, Message, 0x40044,"")
OnMessage(0x44, "")
IfMsgBox Yes, {
reload
}
}
chooseFile() {
if FileExist(strreplace(clipboard,"/","\")) {
clipboard:=strreplace(clipboard,"/","\")
} else {
ttip("Clipboard does not contain a valid path.")
}
SplitPath % clipboard,,, Ext
if CF_bool:=FileExist(clipboard) && (Ext="md") && !GetKeyState("LShift","P") {
manuscriptpath:=(CF_bool?clipboard:script.config.searchroot)
} else {
if (script.config.config.SetSearchRootToLastRunManuscriptFolder) {
SplitPath % script.config.Lastrun.manuscriptpath,, LastRunDir
FileSelectFile manuscriptpath, 3, % (FileExist(clipboard)?clipboard:LastRunDir) , % "Choose &manuscript file", *.md
} else {
FileSelectFile manuscriptpath, 3, % (FileExist(clipboard)?clipboard:script.config.config.searchroot) , % "Choose &manuscript file", *.md
}
if (manuscriptpath="") {
return
}
}
script.config.DDLHistory:=buildHistory(script.config.DDLHistory,script.config.Config.HistoryLimit,manuscriptpath)
, HistoryString:=""
for each, File in script.config.DDLHistory {
SplitPath % File,, OutDir,, FileName
SplitPath % OutDir,OutFileName
HistoryString.=((each=1)?"":"|") FileName "(" OutFileName ")" " -<>- " File
if (each=1) {
HistoryString.="|"
}
}
GuiControl,, ChosenFile, |
guicontrol,, ChosenFile, % HistoryString
return manuscriptpath
}
fTraySetup() {
b64QuickIcon_64x64 := "iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAABlFSURBVHhe1VsJeE3X9r+JKYMgEkNQKaE1JyQiIUIkkoiIKaMkMojUFEMoQWZBZELEFKqpMTw6PGqq0kGLp2iK0j9qKJGipoRoi/XWWufsc8+9Lv++V31t1/et78xnr99vr7X22vvcq/kTpM727dubV1dXtzl+/Lj9wYMHnY6cOOHw9OnTNjt37mxha2trIt/39xcAqHn27Nkul69eHXP79u1Vd+7c+bSqqupCZVVV5a+PHz95/PgxCKVjvFZVWVn5/d27dz9DXV1eXj7u5MmT9viqWtIb/yZiojFxbdX4tcXvb9t+Bkn4XfLLL79A1YMH3924cWNpWVlZb7mJv57YODqa1Te2jnNu2/+orcXrUF9jDc3MX4XREWPh25PfynAAnjx9Ck+ePFH0sazqc2pVy1PU+/fvn7h69eq4tLS0unLTf7oYY/yOnxA18btGxi1hoEsMeHULhhZmbaCexgpqaEygUe1mMOmNqfD9ue8lJChMhKz4PKsgR02Iel8tDx48OH/t2rVJ2H5NyYw/QTA+PaofVR96WFUNbRu3g45NXSDQawIM6fMGeDoEwStIgqWmETRANdLUgeb1bCFjVhZUlP8ow8BeFeARoNj+v4r3Cbl3795X3377rbds0v9Mal2/fr2AkhfJm2OToLbGAjzsgyAhJgfiQ9PB23EEekIItDBtjQRYg7XGhj3CSFMbWjd6HXLn5MP9e5X8PInWA17sBWKftzIR9GxFRcWywMBAU9m+P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k5YPGUwk8eVQeg6dlrglR83lFiGeMoveFyqCFJ9D8361TgPJ5nra8KCuBL8f9VDz/1/gDJfZCQ3d396m4exYVQ6EbBPSUyl//XqOkVSH0BEqE9G8yH8wDEgmkBFzsS+BJKf672PXSAY96Do+TUK1R/5JCKy2+NWvUfMeti/8V+tcYAYwalATZyaVcHA3rO0ZaN0AiaKFzgOz2vPaPwyDFPVWXQ3uPA9sm7YiAH7DH12N4+eP+3+ff5Y3QPXs7+PV0dxw23a1DwJYx4eknUqeX/Bjim/ikv4OcCOXYp48kSMqTft1Cb2Du+NrDIWhrnx4hSTaWrd3wVRbSG1+2aDT/BtnUHzfcnqz7AAAAAElFTkSuQmCC"
hICON := Base64PNG_to_HICON( b64QuickIcon_64x64 ) ; Create a HICON for Tray
Menu Tray, Icon, HICON:*%hICON% ; AHK makes a copy of HICON when * is used
Menu Tray, Icon
DllCall( "DestroyIcon", "Ptr",hICON ) ; Destroy original HICON
menu tray, add,
Menu tray, add, Update ObsidianHTML to Master Branch ,updateObsidianHTMLToMaster
Menu tray, add, Update ObsidianHTML to Last Release ,updateObsidianHTMLToLastRelease
return
}
#Include <PrettyTickCount>
#Include <st_count>
#Include <HasVal>
#Include <Base64PNG_to_HICON>
#Include <script>
#Include <enableGuiDrag>
#Include <Quote>
#Include <ttip>
#Include <DynamicArguments>
#Include <SRC_ImageConverter>
#Include <ObsidianHTML>
#Include <writeFile>
#Include <RScript>
#Include <RMarkdown>
#Include <RegexMatchAll>
#Include <Deref>
#Include <OnError>
#Include <OnExit>
#Include <Log>
#Include <Outputbackup>
#Include <TemporaryObsidianVaultRoot>
#Include <Quarto>
#Include <script>
#Include <ownCLI>
#Include <Configuration>
#Include <messageboxes>
#Include <notify>
#Include <processing>
#Include <gui>