1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20\ifdefined\ecmacode
21 \expandafter \endinput
22\fi
23
24\registerctxluafile{libsimpmujs}{autosuffix}
25
26\unprotect
27
28
29
30\let\stopecmacode\relax
31
32\protected\def\startecmacode
33 {\begingroup
34 \obeyluatokens
35 \luat_start_ecma_code_indeed}
36
37\def\luat_start_ecma_code_indeed#1\stopecmacode
38 {\normalexpanded{\endgroup\noexpand\ecmacode{#1}}}
39
40\protect
41
42\continueifinputfile{libsimpmujs.mkxl}
43
44\usemodule[articlebasic,abbreviationslogos]
45
46\starttext
47
48\startbuffer
49\startluacode
50 local mujs = require("libs-imp-mujs")
51
52 mujs.execute [[
53 var MyMax = 1000;
54 ]]
55
56 mujs.execute [[
57 console("Example One!");
58 texsprint("\\startpacked");
59 for (var i = 1; i <= MyMax; i = i + 1) {
60 texprint(
61 "This is a buildbot compilation challenge for Mojca: "
62 .concat(Math.sqrt(i/MyMax))
63 .concat("!\\par")
64 );
65 }
66 texsprint("\\stoppacked");
67 ]]
68
69
70
71
72\stopluacode
73
74\startecmacode
75 console("Example Two!");
76 for (var i = 1; i <= MyMax; i = i 1) {
77 texsprint(
78 "And an opportunity for Alan to attract highschool students to \\TeX: "
79 .concat(i)
80 .concat("! ")
81 );
82 }
83\stopecmacode
84
85\ecmacode {
86 console("Example Three!");
87 texprint("And otherwise a way to prototype \\JAVASCRIPT\\ code in \\PDF.")
88}
89
90\startecmacode
91 var f = File("libsimpmujs.mkxl","r");
92 console(f);
93 var l = f.read(400);
94 var l = f.read("*a");
95 console(l);
96 f.close();
97\stopecmacode
98
99\startecmacode
100 console("Example Four!");
101 texsprint("\\startMPcode "
102 .concat( fill fullcircle scaled 6cm withcolor "darkred";)
103 .concat( fill fullcircle scaled 4cm withcolor "darkgreen";)
104 .concat( fill fullcircle scaled 2cm withcolor "darkblue";)
105 .concat("\\stopMPcode ")
106 );
107\stopecmacode
108
109\startluacode
110 context.startMPcode()
111 context('fill fullcircle scaled 6cm withcolor "middlecyan";')
112 context('fill fullcircle scaled 4cm withcolor "middlemagenta";')
113 context('fill fullcircle scaled 2cm withcolor "middleyellow";')
114 context.stopMPcode()
115\stopluacode
116\stopbuffer
117
118\typebuffer \page \getbuffer
119
120\stoptext
121 |