-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfragment.edt
71 lines (54 loc) · 2 KB
/
fragment.edt
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
// Save current paragraph in current TeX Document.
Requires(20110504);
PushTagsandRegisters;
:Prepare:: ==========================================================
IfisMode("TeX","%!m","","JMP('Exit')");
IfisMode("STY","%!m","JMP('Exit')","");
IfisMode("AUX","%!m","JMP('Exit')","");
IfFileExists("%@('APPDATA');\QuadView\running","","JMP('Exit')");
OpenOutput("%@('APPDATA');\QuadView\directory.txt",0,0,0,"%F");
WrL("%P");
CloseOutput;
:Fragment:: =========================================================
LetReg(9, "%L");
LetRegNum(4, %l);
LetRegNum(5, %l);
Loop(!|>
LetRegNum(4, %!4-1);>
IfNum(%!4, 0, '<=', 'Break', '');>
GetLine(3, %!4);>
IfStr('%!3', '', '=', 'Break', !'InsertByIndex(9, "%!9", "%!3%\", 0);');>
|);
Loop(!|>
LetRegNum(5, %!5+1);>
GetLine(3, %!5);>
GetLength(6, "%!9");>
IfStr('%!3', '', '=', 'Break', !'InsertByIndex(9, "%!9", "%\%!3", %!6);');>
|);
:Compare:: ==========================================================
Assign('quadview-fragment-old', '%$(|quadview-fragment|)');
Assign('quadview-fragment', '%!9');
IfStr('%$(|quadview-fragment|)', '%$(|quadview-fragment-old|)', '=', 'JMP("Exit")', '');
:Preamble:: =========================================================
GetPreamble("\begin{document}",8);
IfOK(!'Relax;',!|LetReg(8,>
'\documentclass{article}%\'+>
'\usepackage{amsmath}%\'>
);|);
FindInString("%!8\begin{document}%\", "%!9", -1, -1, 10);
IfOK("JMP('Exit')");
:Output:: ===========================================================
OpenOutput("%@('APPDATA');\QuadView\fragment.tex",0,0,0,"%F");
WrL("%$('quadview-version')");
//WrL("%$('quadview-handout')");
WrL("%!8");
WrL("%$('quadview-preview')");
WrL("\begin{document}");
WrL;
WrL("%$('quadview-fragment')");
WrL;
WrL("\end{document}");
CloseOutput;
:Exit:: =============================================================
PopTagsandRegisters;
End;