-
Notifications
You must be signed in to change notification settings - Fork 0
/
emo.dtx
1763 lines (1724 loc) · 72.6 KB
/
emo.dtx
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
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
% \iffalse meta-comment
%
% emo•ji for all (LaTeX engines)
% (C) Copyright 2023 by Robert Grimm
% Released under LPPL v1.3c or later
% <https://github.com/apparebit/emo>
%
% \fi
% ^^A ----------------------------------------------------------------------------------
% \iffalse
%<*scaffold>
\iffalse
%</scaffold>
% ======================================================================================
%<*readme>
# emo•ji for all (LaTeX engines)
This package defines the `\emo{<emoji-name>}` macro for including color emoji in
a document no matter the LaTeX engine. It uses the Noto color emoji font if the
engine supports doing so and falls back onto PDF graphics otherwise. In either
case, `\emo{desert-island}` results in 🏝 and `\emo{parrot}` results in 🦜. Emo
may come in particularly handy when dealing with academic publishers that
provide only minimal support for non-Latin scripts (cough,
[ACM](https://www.acm.org), cough).
Emo's source repository is <https://github.com/apparebit/emo>. It also is
available [through CTAN](https://ctan.org/pkg/emo). Emo supports conversion to
HTML with [LaTeXML](https://github.com/brucemiller/LaTeXML) or
[TeX4ht](https://tug.org/tex4ht/). When using the latter tool, please be sure to
use |make4ht -l| as invocation.
## Package Options
When emo is used with the `extra` option, this package also defines the
`\lingchi` and `\YHWH` macros for 凌遲 and יהוה, respectively. Both macros
preserve a subsequent space as space, no backslash needed.
When used with the `index` option, this package also emits a raw index entry for
each use of an emoji into an emo index or `.edx` file.
## Installation
To **extract files** embedded in [emo.dtx](emo.dtx), run `pdftex emo.dtx`. Note
that plain old `tex` won't do, since it mangles this README. `pdflatex` works,
but also generates the package documentation. The embedded files are `build.sh`,
`emo.ins`, `emo.sty`, `emo.sty.ltxml`, `emo-support.sty`, `canary.tex`,
`demo.tex`, and `README.md`.
To **run emo's tests and build its documentation**, make `build.sh` executable
by invoking `chmod +x build.sh` and then run `./build.sh`, which:
* Tests emo on pdfTeX, XeTeX, and LuaTeX—see [canary.pdf](canary.pdf);
* Tests emo with LaTeXML and TeX4ht—see [demo.html](demo.html);
* Builds the documentation with indices—see [emo.pdf](emo.pdf).
To **configure the emoji**, run `python3 config/emo.py` with appropriate
arguments. The [package documentation](emo.pdf) explains the configuration tool
in detail, but you may find the `-h` for help option sufficient to get started.
To **install this package**, place `emo.def`, `emo.sty`, `emo.sty.ltxml`,
`emo-lingchi.ttf`, and the `emo-graphics` directory with the fallback PDF files
somewhere where LaTeX can find them. In a pinch, your project directory will do.
## Supported Emoji
By default, emo supports all of the emoji listed below. In order of Unicode's
emoji groups, emo's pre-configured emoji include:
* All emoji in Unicode's *Smileys & Emotion* group;
* All emoji in the *People & Body* group that do *not* override gender, hair,
or skin color;
* All emoji in the *Animals & Nature*, *Food & Drink*, *Travel & Places*,
*Activities*, *Objects*, and *Symbols* groups;
* All emoji in the *flag* subgroup of the *Flags* group;
* The EU flag.
In Unicode display order, that's the following 1,415 out of 3,655 possible emoji
as of Unicode 15.0:
😀 😃 😄 😁 😆 😅 🤣 😂 🙂 🙃 🫠 😉 😊 😇 🥰 😍 🤩 😘 😗 ☺️ 😚 😙 🥲 😋 😛 😜 🤪
😝 🤑 🤗 🤭 🫢 🫣 🤫 🤔 🫡 🤐 🤨 😐 😑 😶 🫥 😶🌫️ 😏 😒 🙄 😬 😮💨 🤥 🫨 😌
😔 😪 🤤 😴 😷 🤒 🤕 🤢 🤮 🤧 🥵 🥶 🥴 😵 😵💫 🤯 🤠 🥳 🥸 😎 🤓 🧐 😕 🫤 😟 🙁
☹️ 😮 😯 😲 😳 🥺 🥹 😦 😧 😨 😰 😥 😢 😭 😱 😖 😣 😞 😓 😩 😫 🥱 😤 😡 😠 🤬 😈
👿 💀 ☠️ 💩 🤡 👹 👺 👻 👽 👾 🤖 😺 😸 😹 😻 😼 😽 🙀 😿 😾 🙈 🙉 🙊 💌 💘 💝 💖
💗 💓 💞 💕 💟 ❣️ 💔 ❤️🔥 ❤️🩹 ❤️ 🩷 🧡 💛 💚 💙 🩵 💜 🤎 🖤 🩶 🤍 💋 💯 💢 💥
💫 💦 💨 🕳️ 💬 👁️🗨️ 🗨️ 🗯️ 💭 💤 👋 🤚 🖐️ ✋ 🖖 🫱 🫲 🫳 🫴 🫷 🫸 👌 🤌 🤏
✌️ 🤞 🫰 🤟 🤘 🤙 👈 👉 👆 🖕 👇 ☝️ 🫵 👍 👎 ✊ 👊 🤛 🤜 👏 🙌 🫶 👐 🤲 🤝 🙏 ✍️
💅 🤳 💪 🦾 🦿 🦵 🦶 👂 🦻 👃 🧠 🫀 🫁 🦷 🦴 👀 👁️ 👅 👄 🫦 👶 🧒 👦 👧 🧑 👱
🧔 🧓 🙍 🙎 🙅 🙆 💁 🙋 🧏 🙇 🤦 🤷 🧑⚕️ 🧑🎓 🧑🏫 🧑⚖️ 🧑🌾 🧑🍳 🧑🔧
🧑🏭 🧑💼 🧑🔬 🧑💻 🧑🎤 🧑🎨 🧑✈️ 🧑🚀 🧑🚒 👮 🕵️ 💂 🥷 👷 🫅 🤴 👸
👳 👲 🤵 👰 🫄 🤱 🧑🍼 👼 🎅 🤶 🧑🎄 🦸 🦹 🧙 🧚 🧛 🧜 🧜♂️ 🧜♀️ 🧝 🧞 🧟 🧌
💆 💇 🚶 🧍 🧎 🧑🦯 🧑🦼 🧑🦽 🏃 🕴️ 👯 👯♂️ 👯♀️ 🧖 🧗 🤺 🏇 ⛷️ 🏂 🏌️ 🏄
🚣 🏊 ⛹️ 🏋️ 🚴 🚵 🤸 🤼 🤼♂️ 🤼♀️ 🤽 🤾 🤹 🧘 🛀 🛌 🧑🤝🧑 👭 👬 💏 💑 👪
🗣️ 👤 👥 🫂 👣 🐵 🐒 🦍 🦧 🐶 🐕 🦮 🐕🦺 🐩 🐺 🦊 🦝 🐱 🐈 🐈⬛ 🦁 🐯 🐅 🐆 🐴
🫎 🫏 🐎 🦄 🦓 🦌 🦬 🐮 🐂 🐃 🐄 🐷 🐖 🐗 🐽 🐏 🐑 🐐 🐪 🐫 🦙 🦒 🐘 🦣 🦏 🦛 🐭
🐁 🐀 🐹 🐰 🐇 🐿️ 🦫 🦔 🦇 🐻 🐻❄️ 🐨 🐼 🦥 🦦 🦨 🦘 🦡 🐾 🦃 🐔 🐓 🐣 🐤 🐥
🐦 🐧 🕊️ 🦅 🦆 🦢 🦉 🦤 🪶 🦩 🦚 🦜 🪽 🐦⬛ 🪿 🐸 🐊 🐢 🦎 🐍 🐲 🐉 🦕 🦖 🐳 🐋
🐬 🦭 🐟 🐠 🐡 🦈 🐙 🐚 🪸 🪼 🐌 🦋 🐛 🐜 🐝 🪲 🐞 🦗 🪳 🕷️ 🕸️ 🦂 🦟 🪰 🪱 🦠
💐 🌸 💮 🪷 🏵️ 🌹 🥀 🌺 🌻 🌼 🌷 🪻 🌱 🪴 🌲 🌳 🌴 🌵 🌾 🌿 ☘️ 🍀 🍁 🍂 🍃 🪹
🪺 🍄 🍇 🍈 🍉 🍊 🍋 🍌 🍍 🥭 🍎 🍏 🍐 🍑 🍒 🍓 🫐 🥝 🍅 🫒 🥥 🥑 🍆 🥔 🥕 🌽
🌶️ 🫑 🥒 🥬 🥦 🧄 🧅 🥜 🫘 🌰 🫚 🫛 🍞 🥐 🥖 🫓 🥨 🥯 🥞 🧇 🧀 🍖 🍗 🥩 🥓 🍔
🍟 🍕 🌭 🥪 🌮 🌯 🫔 🥙 🧆 🥚 🍳 🥘 🍲 🫕 🥣 🥗 🍿 🧈 🧂 🥫 🍱 🍘 🍙 🍚 🍛 🍜 🍝
🍠 🍢 🍣 🍤 🍥 🥮 🍡 🥟 🥠 🥡 🦀 🦞 🦐 🦑 🦪 🍦 🍧 🍨 🍩 🍪 🎂 🍰 🧁 🥧 🍫 🍬 🍭
🍮 🍯 🍼 🥛 ☕ 🫖 🍵 🍶 🍾 🍷 🍸 🍹 🍺 🍻 🥂 🥃 🫗 🥤 🧋 🧃 🧉 🧊 🥢 🍽️ 🍴 🥄 🔪
🫙 🏺 🌍 🌎 🌏 🌐 🗺️ 🗾 🧭 🏔️ ⛰️ 🌋 🗻 🏕️ 🏖️ 🏜️ 🏝️ 🏞️ 🏟️ 🏛️ 🏗️ 🧱 🪨
🪵 🛖 🏘️ 🏚️ 🏠 🏡 🏢 🏣 🏤 🏥 🏦 🏨 🏩 🏪 🏫 🏬 🏭 🏯 🏰 💒 🗼 🗽 ⛪ 🕌 🛕 🕍
⛩️ 🕋 ⛲ ⛺ 🌁 🌃 🏙️ 🌄 🌅 🌆 🌇 🌉 ♨️ 🎠 🛝 🎡 🎢 💈 🎪 🚂 🚃 🚄 🚅 🚆 🚇 🚈 🚉
🚊 🚝 🚞 🚋 🚌 🚍 🚎 🚐 🚑 🚒 🚓 🚔 🚕 🚖 🚗 🚘 🚙 🛻 🚚 🚛 🚜 🏎️ 🏍️ 🛵 🦽 🦼
🛺 🚲 🛴 🛹 🛼 🚏 🛣️ 🛤️ 🛢️ ⛽ 🛞 🚨 🚥 🚦 🛑 🚧 ⚓ 🛟 ⛵ 🛶 🚤 🛳️ ⛴️ 🛥️ 🚢 ✈️
🛩️ 🛫 🛬 🪂 💺 🚁 🚟 🚠 🚡 🛰️ 🚀 🛸 🛎️ 🧳 ⌛ ⏳ ⌚ ⏰ ⏱️ ⏲️ 🕰️ 🕛 🕧 🕐 🕜 🕑 🕝
🕒 🕞 🕓 🕟 🕔 🕠 🕕 🕡 🕖 🕢 🕗 🕣 🕘 🕤 🕙 🕥 🕚 🕦 🌑 🌒 🌓 🌔 🌕 🌖 🌗 🌘 🌙
🌚 🌛 🌜 🌡️ ☀️ 🌝 🌞 🪐 ⭐ 🌟 🌠 🌌 ☁️ ⛅ ⛈️ 🌤️ 🌥️ 🌦️ 🌧️ 🌨️ 🌩️ 🌪️ 🌫️ 🌬️
🌀 🌈 🌂 ☂️ ☔ ⛱️ ⚡ ❄️ ☃️ ⛄ ☄️ 🔥 💧 🌊 🎃 🎄 🎆 🎇 🧨 ✨ 🎈 🎉 🎊 🎋 🎍 🎎 🎏 🎐
🎑 🧧 🎀 🎁 🎗️ 🎟️ 🎫 🎖️ 🏆 🏅 🥇 🥈 🥉 ⚽ ⚾ 🥎 🏀 🏐 🏈 🏉 🎾 🥏 🎳 🏏 🏑 🏒
🥍 🏓 🏸 🥊 🥋 🥅 ⛳ ⛸️ 🎣 🤿 🎽 🎿 🛷 🥌 🎯 🪀 🪁 🔫 🎱 🔮 🪄 🎮 🕹️ 🎰 🎲 🧩 🧸
🪅 🪩 🪆 ♠️ ♥️ ♦️ ♣️ ♟️ 🃏 🀄 🎴 🎭 🖼️ 🎨 🧵 🪡 🧶 🪢 👓 🕶️ 🥽 🥼 🦺 👔 👕 👖
🧣 🧤 🧥 🧦 👗 👘 🥻 🩱 🩲 🩳 👙 👚 🪭 👛 👜 👝 🛍️ 🎒 🩴 👞 👟 🥾 🥿 👠 👡 🩰
👢 🪮 👑 👒 🎩 🎓 🧢 🪖 ⛑️ 📿 💄 💍 💎 🔇 🔈 🔉 🔊 📢 📣 📯 🔔 🔕 🎼 🎵 🎶 🎙️
🎚️ 🎛️ 🎤 🎧 📻 🎷 🪗 🎸 🎹 🎺 🎻 🪕 🥁 🪘 🪇 🪈 📱 📲 ☎️ 📞 📟 📠 🔋 🪫 🔌 💻
🖥️ 🖨️ ⌨️ 🖱️ 🖲️ 💽 💾 💿 📀 🧮 🎥 🎞️ 📽️ 🎬 📺 📷 📸 📹 📼 🔍 🔎 🕯️ 💡 🔦
🏮 🪔 📔 📕 📖 📗 📘 📙 📚 📓 📒 📃 📜 📄 📰 🗞️ 📑 🔖 🏷️ 💰 🪙 💴 💵 💶 💷 💸
💳 🧾 💹 ✉️ 📧 📨 📩 📤 📥 📦 📫 📪 📬 📭 📮 🗳️ ✏️ ✒️ 🖋️ 🖊️ 🖌️ 🖍️ 📝 💼 📁
📂 🗂️ 📅 📆 🗒️ 🗓️ 📇 📈 📉 📊 📋 📌 📍 📎 🖇️ 📏 📐 ✂️ 🗃️ 🗄️ 🗑️ 🔒 🔓 🔏
🔐 🔑 🗝️ 🔨 🪓 ⛏️ ⚒️ 🛠️ 🗡️ ⚔️ 💣 🪃 🏹 🛡️ 🪚 🔧 🪛 🔩 ⚙️ 🗜️ ⚖️ 🦯 🔗 ⛓️ 🪝
🧰 🧲 🪜 ⚗️ 🧪 🧫 🧬 🔬 🔭 📡 💉 🩸 💊 🩹 🩼 🩺 🩻 🚪 🛗 🪞 🪟 🛏️ 🛋️ 🪑 🚽 🪠
🚿 🛁 🪤 🪒 🧴 🧷 🧹 🧺 🧻 🪣 🧼 🫧 🪥 🧽 🧯 🛒 🚬 ⚰️ 🪦 ⚱️ 🧿 🪬 🗿 🪧 🪪 🏧 🚮
🚰 ♿ 🚹 🚺 🚻 🚼 🚾 🛂 🛃 🛄 🛅 ⚠️ 🚸 ⛔ 🚫 🚳 🚭 🚯 🚱 🚷 📵 🔞 ☢️ ☣️ ⬆️ ↗️ ➡️
↘️ ⬇️ ↙️ ⬅️ ↖️ ↕️ ↔️ ↩️ ↪️ ⤴️ ⤵️ 🔃 🔄 🔙 🔚 🔛 🔜 🔝 🛐 ⚛️ 🕉️ ✡️ ☸️ ☯️ ✝️ ☦️
☪️ ☮️ 🕎 🔯 🪯 ♈ ♉ ♊ ♋ ♌ ♍ ♎ ♏ ♐ ♑ ♒ ♓ ⛎ 🔀 🔁 🔂 ▶️ ⏩ ⏭️ ⏯️ ◀️ ⏪ ⏮️ 🔼 ⏫ 🔽 ⏬
⏸️ ⏹️ ⏺️ ⏏️ 🎦 🔅 🔆 📶 🛜 📳 📴 ♀️ ♂️ ⚧️ ✖️ ➕ ➖ ➗ 🟰 ♾️ ‼️ ⁉️ ❓ ❔ ❕ ❗ 〰️ 💱 💲
⚕️ ♻️ ⚜️ 🔱 📛 🔰 ⭕ ✅ ☑️ ✔️ ❌ ❎ ➰ ➿ 〽️ ✳️ ✴️ ❇️ ©️ ®️ ™️ #️⃣ *️⃣ 0️⃣ 1️⃣ 2️⃣
3️⃣ 4️⃣ 5️⃣ 6️⃣ 7️⃣ 8️⃣ 9️⃣ 🔟 🔠 🔡 🔢 🔣 🔤 🅰️ 🆎 🅱️ 🆑 🆒 🆓 ℹ️ 🆔 Ⓜ️ 🆕 🆖
🅾️ 🆗 🅿️ 🆘 🆙 🆚 🈁 🈂️ 🈷️ 🈶 🈯 🉐 🈹 🈚 🈲 🉑 🈸 🈴 🈳 ㊗️ ㊙️ 🈺 🈵 🔴 🟠
🟡 🟢 🔵 🟣 🟤 ⚫ ⚪ 🟥 🟧 🟨 🟩 🟦 🟪 🟫 ⬛ ⬜ ◼️ ◻️ ◾ ◽ ▪️ ▫️ 🔶 🔷 🔸 🔹 🔺 🔻 💠
🔘 🔳 🔲 🏁 🚩 🎌 🏴 🏳️ 🏳️🌈 🏳️⚧️ 🏴☠️ 🇪🇺
The [package documentation](emo.pdf) explains the underlying naming scheme. It
also explains how to update the configuration with the [emo.py](config.emo.py)
script, which takes care of most heavy lifting by downloading the sources for
Noto color emoji, converting SVG into PDF graphics compatible with pdfTeX and
XeTeX, and generating up-to-date `emo.def` files.
## Copyright and Licensing
This package combines code written in LaTeX, Python, and Perl with Unicode data
about emoji as well as graphics and fonts derived from Google's Noto fonts. As a
result, a number of different licenses apply, all of which are [OSI
approved](https://opensource.org/licenses/) and non-copyleft:
* This package's [LaTeX code](emo.dtx) is © Copyright 2023 by Robert Grimm and
has been released under the [LPPL
v1.3c](https://www.latex-project.org/lppl/lppl-1-3c/) or later.
* The [emo.py](config/emo.py) configuration script also is © Copyright 2023 by
Robert Grimm but has been released under the [Apache 2.0
license](https://www.apache.org/licenses/LICENSE-2.0).
* The [emoji-test.txt](config/emoji-test.txt) configuration file is a data
file from [Unicode TR-51](https://unicode.org/reports/tr51/) and hence
subject to the [Unicode License](https://www.unicode.org/license.txt).
* The `emo-lingchi.ttf` font is a two-glyph subset of the serif traditional
Chinese version of Google's [Noto
fonts](https://github.com/notofonts/noto-cjk) and hence subject to the [SIL
Open Font License v1.1](https://scripts.sil.org/ofl).
* The PDF graphics in the `emo-graphics` directory are derived from the
sources for [Noto's color emoji](https://github.com/googlefonts/noto-emoji)
and hence subject to the Apache 2.0 license.
%</readme>
% --------------------------------------------------------------------------------------
%<*buildscript>
#!/bin/bash
if [[ -z ${NOCOLOR} ]] && [ -t 2 ]; then
EXTRA="\e[1m"
ERROR="\e[1;31m"
WARN="\e[1;38;5;208m"
INFO="\e[1;34m"
RESET="\e[0m"
else
EXTRA=""
ERROR=""
WARN=""
INFO=""
RESET=""
fi
log() {
eval "STYLE=\"\${$1}\""
printf "${STYLE}$1 $2 ${RESET}\n" >&2
}
log_help() {
log EXTRA "Invoke as \'./build.sh [<cmd>]\' with <cmd> one of these:"
log EXTRA " test -- run emo's cross-engine tests"
log EXTRA " html -- run emo's HTML conversions"
log EXTRA " docs -- build emo's documentation on pdfTeX"
log EXTRA " all -- execute test, html, and docs in that order (default)"
log EXTRA " luadocs -- build emo's documentation on LuaTeX"
log EXTRA " luaall -- execute test, html, and luadocs in that order"
}
if [[ -z ${BASH} ]]; then
log ERROR "It looks like you source'd this script; please run it instead"
log EXTRA '$ chmod +x build.sh'
log EXTRA '$ ./build.sh'
return 1
fi
test-with-engine() {
log INFO "Test with $1"
"$1" -jobname=$1-canary -interaction=batchmode canary
if [ $? -ne 0 ]; then
log ERROR "$1 failed to compile 'canary.tex'"
exit 1
fi
}
test() {
test-with-engine pdflatex
test-with-engine xelatex
test-with-engine lualatex
pdfunite pdflatex-canary.pdf xelatex-canary.pdf lualatex-canary.pdf canary.pdf
log INFO 'Be sure to inspect "canary.pdf"!'
}
html() {
log INFO "Convert to HTML with LaTeXML"
# LaTeXML: --includestyles handles emo-supprt package
latexmlc --includestyles --dest=demo-latexml.html demo.tex
if [ $? -ne 0 ]; then
log ERROR "latexml failed to convert 'demo.tex' to HTML"
exit 1
fi
# Remove run date comment and footer. The latter is just plain tacky.
sed -i '' '/^<!--Generated on /d' ./demo-latexml.html
sed -i '' '/^<footer class="ltx_page_footer">/{N;N;d;}' ./demo-latexml.html
log INFO "Convert to HTML with TeX4ht"
# TeX4ht: -l is necessary for selecting LuaTeX engine
make4ht -l -j demo-tex4ht demo.tex
if [ $? -ne 0 ]; then
log ERROR "tex4ht failed to convert 'demo.tex' to HTML"
exit 1
fi
log INFO 'Be sure to inspect "demo.html"!'
}
build-docs() {
log INFO "Build documentation with $1"
$1 -interaction=batchmode emo.dtx
#if [ $? -ne 0 ]; then
# log ERROR "$1 failed to compile 'emo.dtx'"
# exit 1
#fi
}
docs() {
build-docs "$1"
log INFO "Make indices"
makeindex -s gind.ist -o emo.ind emo.idx
makeindex -s gglo.ist -o emo.gls emo.glo
build-docs "$1"
build-docs "$1"
}
target=${1:-all}
case $target in
test ) test ;;
html ) html ;;
docs ) docs pdflatex ;;
luadocs ) docs lualatex ;;
all )
test
html
docs pdflatex
;;
luaall )
test
html
docs lualatex
;;
* )
log ERROR "Unknown command \'${target}\'!"
log_help
exit 1
;;
esac
%</buildscript>
% ======================================================================================
%<*scaffold>
\fi
\def\nameofplainTeX{plain}
\ifx\fmtname\nameofplainTeX\else
\expandafter\begingroup
\fi
%</scaffold>
% --------------------------------------------------------------------------------------
%<*install>
\input docstrip.tex
\keepsilent
\askforoverwritefalse
\preamble
emo•ji for all (LaTeX engines)
(C) Copyright 2023 by Robert Grimm
Released under LPPL v1.3c or later
<https://github.com/apparebit/emo>
\endpreamble
\usedir{tex/latex/emo}
\generate{
\file{\jobname.sty}{\from{\jobname.dtx}{package}}}
\generate{
\nopreamble\nopostamble
\file{\jobname.sty.ltxml}{\from{\jobname.dtx}{latexml-binding}}}
%</install>
%<install>\endbatchfile
% --------------------------------------------------------------------------------------
%<*scaffold>
\usedir{source/latex/emo}
\generate{\file{\jobname.ins}{\from{\jobname.dtx}{install}}}
\generate{\file{emo-support.sty}{\from{\jobname.dtx}{support}}}
\generate{\file{canary.tex}{\from{\jobname.dtx}{canary}}}
\generate{\file{demo.tex}{\from{\jobname.dtx}{oneliner}}}
\nopreamble\nopostamble
\usedir{source/latex/emo}
\generate{\file{build.sh}{\from{\jobname.dtx}{buildscript}}}
\usedir{doc/latex/emo}
\generate{\file{README.md}{\from{\jobname.dtx}{readme}}}
\ifx\fmtname\nameofplainTeX
\expandafter\endbatchfile
\else
\expandafter\endgroup
\fi
%</scaffold>
% ======================================================================================
% See https://tug.org/TUGboat/tb29-2/tb92pakin.pdf.
%<*scaffold>
\ProvidesFile{emo.dtx}
%</scaffold>
%<package>\NeedsTeXFormat{LaTeX2e}
%<package>\ProvidesPackage{emo}
%<*scaffold,package>
[2023/05/22 v1.0 emo•ji for all (LaTeX engines)]
%</scaffold,package>
% ======================================================================================
%<*driver>
\PassOptionsToPackage{utf8}{inputenc}
\documentclass{ltxdoc}
% Override the default \small, which looks odd typeset in Inconsolata.
\renewcommand{\MacroFont}{\normalsize\ttfamily}
\usepackage{emo-support}
\usepackage{enumitem}
\usepackage{parskip}
\usepackage{multicol}
\usepackage{xcolor}
\usepackage{hyperref}
%\usepackage{lua-visual-debug}
\definecolor{spot}{HTML}{353598}
\hypersetup{allcolors=spot}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\begin{document}
\DocInput{\jobname.dtx}
\end{document}
%</driver>
% ======================================================================================
% \fi
%
% \changes{0.1}{}{Make initial release}
% \changes{0.2}{}{Prefix font and graphic files with ``{\tt emo-}''}
% \changes{0.2}{}{Support {\tt pdftex} for extracting {\tt emo.dtx}}
% \changes{0.3}{}{Support TeX4ht for conversion to HTML}
% \changes{0.4}{}{Automate testing across engines with {\tt canary.tex}}
% \changes{1.0}{}{Use LaTeX hooks for handling engines and options}
%
% \GetFileInfo{\jobname.dtx}
%
% \newlist{inlinenum}{enumerate*}{1}
% \setlist[inlinenum]{label=(\alph{inlinenumi})}
% \newenvironment{verbatimish}{%
% \ttfamily%
% \obeylines%
% \obeyspaces%
% \vspace{\the\parskip}%
% \setlength{\parskip}{0pt}%
% \setlength{\parindent}{1em}%
% }{}
%
% \title{emo•ji for all\\(LaTeX engines)}
% \author{\href{https://apparebit.com}{Robert Grimm}}
% \date{Version \fileversion\ (\filedate)}
%
% \maketitle
%
% \begin{abstract}
% \noindent{}Emo implements the |\emo|\marg{emoji-name} command for including
% color emoji such as |\emo{desert-island}| for \emo{desert-island} or
% |\emo{parrot}| for \emo{parrot} in your documents independent of LaTeX engine.
% The implementation uses the Noto color emoji font if the engine supports it
% and includes PDF graphics otherwise. It also supports conversion to HTML with
% either LaTeXML or TeX4ht. Next, PDF graphics are automatically derived from
% Noto's SVG sources, so the visual appearance is very similar. The source
% repository is at \url{https://github.com/apparebit/emo}. Emo may come in
% particularly handy when dealing with academic publishers that provide only
% minimal support for non-Latin scripts (cough,
% \href{https://authors.acm.org/proceedings/production-information/accepted-latex-packages}{ACM},
% cough).
% \end{abstract}
%
% \tableofcontents
%
%
% ^^A ==================================================================================
% \section{Installation}
%
% The emo package is available through its
% \href{https://github.com/apparebit/emo}{source repository} or through
% \href{https://ctan.org/pkg/emo}{CTAN}. Installation is fairly
% straightforward, though it does involve a lot more files than usual.
%
% \begin{enumerate}
% \item Start by extracting this package's files from |emo.dtx| by running:
% \begin{verbatimish}
% \$ pdftex emo.dtx
% \end{verbatimish}
% Do \emph{not} use |tex|; it mangles the embedded |README.md|. |pdflatex| also
% extracts the files and then builds the documentation. Embedded files are
% |build.sh|, |emo.ins|, |emo.sty|, |emo.sty.ltxml|, |emo-support.sty|,
% |canary.tex|, |demo.tex|, and |README.md|. Extraction will overwrite existing
% files with the same name without asking.
%
% \item Test the package and build its documentation by making |build.sh|
% executable and then running it:
% \begin{verbatimish}
% \$ chmod +x build.sh; ./build.sh
% \end{verbatimish}
%
% The shell script does three things: First, it tests emo by compiling
% |canary.tex| with pdfTex, XeTeX, as well as LuaTeX and generating |canary.pdf|
% with the results from the three tests. Second, it tests emo by compiling
% |demo.tex| with LaTeXML as well as TeX4ht and generating |demo-latexml.html|
% as well as |demo-tex4ht.html|, which are framed together by |demo.html|.
% Third, it builds the package documentation in |emo.pdf| with all bells and
% indices.
%
% \item Get started reconfiguring supported emoji by running:
% \begin{verbatimish}
% \$ python config/emo.py -h
% \end{verbatimish}
% For more detailed instructions, see \S\ref{sec:config} below.
%
% \item Put the following files somewhere LaTeX can find them. In a pinch, your
% current project's directory will do. However, emo's installation potentially
% comprises thousands of files. So, you probably want to use a dedicated
% directory and add that to the search path for LaTeX, e.g., by setting the
% |TEXINPUTS| environment variable.
% \begin{enumerate}
% \item |emo.sty| with the package implementation;
% \item |emo.sty.ltxml| with the binding for
% \href{https://github.com/brucemiller/LaTeXML}{LaTeXML};
% \item |emo.def| with the emoji table;
% \item |emo-lingchi.ttf| with the two glyphs for |\lingchi|;
% \item |emo-graphics| with the fallback PDF graphics.
% \end{enumerate}
% TeX Live requires that each package's files have unique names. For that
% reason, the PDF graphics in the |emo-graphics| directory start with the |emo-|
% prefix as well.
%
% \end{enumerate}
%
% When running on the LuaLaTeX engine, the emo package also uses the Noto color
% emoji (|NotoColorEmoji.ttf|) and Linux Libertine (|LinLibertine_R.otf|) fonts,
% with the latter used for rendering |\YHWH| only. Neither file is included with
% emo's distribution, since both of them are distributed with major TeX
% distributions already. If they are not included with your LaTeX distribution,
% you can find them on CTAN. The |emo-lingchi.ttf| font distributed with emo is
% a two glyph subset of \texttt{Noto\-Serif-\TC-Regular.otf}, i.e., the
% traditional Chinese version of Noto serif.
%
%
% ^^A ==================================================================================
% \section{Usage}
%
% As usual, you declare your document's dependency on emo with
% |\usepackage{emo}|. In addition to the unadorned form, emo takes up to two
% options:
% \begin{description}
% \item[extra] Also define the |\lingchi| and |\YHWH| macros, which produce
% \lingchi\ and \YHWH.
% \item[index] Create an emoji index tagged |emo| with the |.edx| extension for
% the raw index and the |.end| extension for the processed index. This
% option relies on the |index| package, generates the raw |.edx| file,
% but does not build or use the processed index.
% \end{description}
%
%
% ^^A ----------------------------------------------------------------------------------
% \subsection{One Main Macro}
% \DescribeMacro{\emo}
% An |\emo|\marg{emoji-name} invocation expands to the named emoji. For
% LuaLaTeX, it uses the Noto color emoji font. For all other engines, it uses
% PDF graphics. That way, |\emo{desert-island}| results in~\emo{desert-island}
% and |\emo{parrot}| results in~\emo{parrot}.
%
% Since LaTeX tends to produce a lot of command line noise about underfull boxes
% and loaded fonts, it's a easy to miss meaningful warnings. For that reason,
% |\emo| expands to an attention-seeking error message upon undefined emoji
% names. For example, |\emo{boo}| produces \emo{boo}.
%
%
% ^^A ----------------------------------------------------------------------------------
% \subsubsection{Naming Scheme}
%
% With a few exceptions, emo's names for emoji are automatically derived from
% their Unicode names, with letters converted to lowercase, punctuation such as
% commas, colons, quotes, and parentheses stripped, and interword spaces
% replaced by dashes. Furthermore, instead of the rather verbose
% |dark-skin-tone|, |medium-dark-skin-tone|, etc modifiers, emo
% uses the more succinct |darkest|, |darker|, |medium|, |lighter|, and
% |lightest|.
%
% For some names, emo goes further by hard-coding shorter names. Those names are
% listed in Table~\ref{tab:special-names}.
%
% \begin{table}
% \caption{Exceptional emoji names}
% \label{tab:special-names}
% \small\vspace{1em}
% \begin{tabular}{ll}
% \textbf{Transformed Unicode Name} & \textbf{Emo Replacement Name} \\ \hline
% |a-button-blood-type| & |a-button| \\
% |ab-button-blood-type| & |ab-button| \\
% |b-button-blood-type| & |b-button| \\
% |o-button-blood-type| & |o-button| \\
% |bust-in-silhouette| & |bust| \\
% |busts-in-silhouette| & |busts| \\
% |flag-european-union| & |eu| \\
% |globe-showing-americas| & |globe-americas| \\
% |globe-showing-asia-australia| & |globe-asia-australia| \\
% |globe-showing-europe-africa| & |globe-africa-europe| \\
% |hear-no-evil-monkey| & |hear-no-evil| \\
% |index-pointing-at-the-viewer| & |index-pointing-at-viewer| \\
% |index-pointing-at-the-viewer-darkest| & |index-pointing-at-viewer-darkest| \\
% |index-pointing-at-the-viewer-darker| & |index-pointing-at-viewer-darker| \\
% |index-pointing-at-the-viewer-medium| & |index-pointing-at-viewer-medium| \\
% |index-pointing-at-the-viewer-lighter| & |index-pointing-at-viewer-lighter| \\
% |index-pointing-at-the-viewer-lightest| & |index-pointing-at-viewer-lightest| \\
% |keycap-*| & |keycap-star| \\
% |keycap-#| & |keycap-hash| \\
% |keycap-0| & |keycap-zero| \\
% |keycap-1| & |keycap-one| \\
% |keycap-2| & |keycap-two| \\
% |keycap-3| & |keycap-three| \\
% |keycap-4| & |keycap-four| \\
% |keycap-5| & |keycap-five| \\
% |keycap-6| & |keycap-six| \\
% |keycap-7| & |keycap-seven| \\
% |keycap-8| & |keycap-eight| \\
% |keycap-9| & |keycap-nine| \\
% |keycap-10| & |keycap-ten| \\
% |magnifying-glass-tilted-left| & |loupe-left| \\
% |magnifying-glass-tilted-right| & |loupe-right| \\
% |palm-down-hand| & |palm-down| \\
% |palm-down-hand-darkest| & |palm-down-darkest| \\
% |palm-down-hand-darker| & |palm-down-darker| \\
% |palm-down-hand-medium| & |palm-down-medium| \\
% |palm-down-hand-lighter| & |palm-down-lighter| \\
% |palm-down-hand-lightest| & |palm-down-lightest| \\
% |palm-up-hand| & |palm-up| \\
% |palm-up-hand-darkest| & |palm-up-darkest| \\
% |palm-up-hand-darker| & |palm-up-darker| \\
% |palm-up-hand-medium| & |palm-up-medium| \\
% |palm-up-hand-lighter| & |palm-up-lighter| \\
% |palm-up-hand-lightest| & |palm-up-lightest| \\
% |rolling-on-the-floor-laughing| & |rofl| \\
% |see-no-evil-monkey| & |see-no-evil| \\
% |speak-no-evil-monkey| & |speak-no-evil| \\
% \end{tabular}
% \end{table}
%
% Emo's |emo.def| contains the names and codepoints of all currently supported
% emoji in Unicode display order. Emo's distribution also includes the
% |emoji-test.txt| file, which is part of
% \href{https://unicode.org/reports/tr51/}{Unicode TR-51} and contains the names
% and codepoints of all \emph{potentially} supported emoji, i.e., all emoji,
% also in Unicode display order. It further organizes emoji into groups and
% subgroups, with the current (sub)group being the one named on the closest line
% above the emoji that starts with |# |(|sub|)|group:|. As described in the next
% section, the group and subgroup names can be used during configuration for
% concisely naming a large number of emoji.
%
%
% ^^A ----------------------------------------------------------------------------------
% \subsubsection{Inventory of Default Configuration}
%
% Emo's default configuration includes all emoji \emph{but} those in the
% \emph{people-and-body} Unicode group that modify gender, hair, or skin and
% those in the \emph{country-flag} subgroup of the \emph{flags} group other than
% the EU flag (which is included). As of Unicode 15.0, that's 1,415 out of 3,655
% emoji. There are another 257 flags, but the majority of excluded emoji are
% variations on already included emoji depicting people or body parts. As
% described in the next section, enabling additional emoji is as easy as running
% a Python script with the emoji names as arguments.
%
% With their names listed in Unicode display order and organized by Unicode
% group and subgroup, that's the following emoji.
%
% \listinventory
%
%
% ^^A ----------------------------------------------------------------------------------
% \subsection{Two Optional Macros}
%
% \DescribeMacro{\lingchi}
% \DescribeMacro{\YHWH}
% The |\lingchi| and |\YHWH| macros take no arguments and produce \lingchi\ and
% \YHWH. They are only available if emo is used with the |extra| option.
% The former renders the Chinese term for ``death by a thousand cuts.'' While
% originally an execution method, the term applies to surprisingly many software
% systems as well. The latter produces the Tetragrammaton, the Hebrew name for
% God. Observant Jews never utter what's written, not even in their thoughts,
% substituting Adonai (``My Lord''), Elohim (``God''), or HaShem (``The Name'')
% instead. In my mind, that nicely mirrors the very incomprehensibility of
% \YHWH. Both macros preserve a subsequent space as space, no backslash needed.
%
%
% ^^A ----------------------------------------------------------------------------------
% \subsection{Conversion to HTML}
%
% Emo supports conversion to HTML with either
% \href{https://github.com/brucemiller/LaTeXML}{LaTeXML} or
% \href{https://tug.org/tex4ht/}{TeX4ht}. LaTeXML support is implemented by a
% separate ``binding'' against LaTeXML's Perl API. I chronicled my exploration
% of suitable options leading to that less than ideal choice in a
% \href{https://github.com/brucemiller/LaTeXML/issues/2063}{GitHub issue}.
% TeX4ht support is implemented by the emo package itself. It requires
% processing with LuaLaTeX e.g., by passing |-l| or |--lua| to the |make4ht|
% tool.
%
%
% ^^A ==================================================================================
% \section{Configuration}
% \label{sec:config}
%
% Emo's implementation is actually split over two files: |emo.sty| is extracted
% from |emo.dtx| and defines the substance of the package, its options, its
% helper macros, and the user-visible |\emo|, |\lingchi|, and |\YHWH| macros.
% Currently supported emoji are defined by the emoji table in the second file,
% |emo.def|. For every supported emoji, the file contains an invocation of the
% |\DefineEmoji|\meta{emoji-name}\meta{emoji-codepoints} macro with the emoji's
% name and codepoints. With exception of the emoji listed in
% Table~\ref{tab:special-names}, all names are the Unicode names written with a
% dash instead of space and using only lowercase letters. The codepoints always
% are the fully qualified Unicode codepoints for the emoji.
%
% Configuration automates the regeneration of the emoji table for arbitrary
% numbers of emoji. |config/emo.py| is the script and |config/emoji-test.txt| is
% the list of all emoji from the Unicode standard.
%
%
% ^^A ----------------------------------------------------------------------------------
% \subsection{Running the Configuration Script}
%
% To update emo's configuration, invoke the |config/emo.py| script:
% \begin{verbatimish}
% \$ python3 config/emo.py \meta{selector} \meta{selector} $\ldots$
% \end{verbatimish}
%
% Each selector may be:
% \begin{itemize}
% \item The literal |ALL| (case-sensitive) for \emph{all} emoji.
% \item Name of a group in |emoji-test.txt| lowercased and with spaces replaced
% by dashes and ampersand |&| replaced by an |and|; e.g.,
% |travel-and-places|.
% \item Name of a group, a double colon |::|, and name of a subgroup, again
% lowercased and with spaces replaced by dashes and |&| by an |and|; e.g.,
% \texttt{travel-and-places::\-place\-geo\-graphic}.
% \item The name of an emoji; e.g., |desert-island|.
% \end{itemize}
% For conjunctive group names, such as ``Smileys \& Emotion'' (|emoji-test.txt|)
% or ``smileys-and-emotion'' (|emo.py|), the configuration script also accepts
% either of the two nouns as a shortcut, e.g., ``smileys'' or ``emotion.''
%
% For data safety, |emo.py| does not overwrite PDF graphics and hence can only
% \emph{add} emoji to the configuration. To remove emoji, simply remove their
% PDF graphics from |emo-graphics| and then run |emo.py| without selector
% arguments, which updates the emoji table accordingly.
%
% |emo.py| effectively treats |emoji-test.txt| as registry of all emoji and the
% filenames of PDF graphics in |emo-graphics| as emo's current inventory. For
% all emoji named by selector arguments but not in the inventory, |emo.py|
% converts the SVG source graphic from the Noto color emoji sources to a PDF
% file and deletes the |/Page| |/Group| object from the the PDF again, since
% that object trips up |pdflatex|. And yeah, |emo.py| automatically downloads
% the Noto color emoji sources if necessary.
%
%
% ^^A ==================================================================================
% \section{Copyright and Licensing}
%
% Since emo's distribution includes not only LaTeX code but also a substantial
% Python script, Unicode data about emoji, as well as graphics and fonts derived
% from Google's Noto project, a number of different licenses apply. All of them
% are \href{https://opensource.org/licenses/}{OSI approved} and non-copyleft:
% \begin{itemize}
% \item This package's LaTeX and also Perl code extracted from |emo.dtx|
% is © Copyright 2023 by Robert Grimm and has been released
% under the \href{https://www.latex-project.org/lppl/lppl-1-3c/}{LPPL v1.3c}
% or later.
% \item The |config/emo.py| script also is © Copyright 2023 by Robert Grimm but
% has been released under the
% \href{https://www.apache.org/licenses/LICENSE-2.0}{Apache 2.0 license}.
% \item The [config/emoji-test.txt] configuration file is a data file from
% \href{https://unicode.org/reports/tr51/}{Unicode TR-51} and hence subject
% to the \href{https://www.unicode.org/license.txt}{Unicode License}.
% \item The |emo-lingchi.ttf| font is a two-glyph subset of the traditional
% Chinese version of Google's
% \href{https://github.com/notofonts/noto-cjk}{Noto serif} and hence subject
% to the \href{https://scripts.sil.org/ofl}{SIL Open Font License v1.1}.
% \item The PDF graphics in the |emo-graphics| directory are derived from the
% sources for \href{https://github.com/googlefonts/noto-emoji}{Noto's color
% emoji} and hence subject to the Apache 2.0 license.
% \end{itemize}
%
%
% \StopEventually{^^A
% \PrintChanges^^A
% \setcounter{IndexColumns}{2}^^A
% \columnsep = 20pt^^A
% \PrintIndex}
%
%
% ^^A ==================================================================================
% \section{Implementation}
%
% Let's get started on emo's implementation:
% \begin{macrocode}
%<*package>
% \end{macrocode}
%
% Except, that implementation started near the top of this |emo.dtx| file, well
% before the documentation's preamble. For completeness, here is the package
% declaration again:
%
% \begin{verbatimish}
% |\NeedsTeXFormat{LaTeX2e}|
% |\ProvidesPackage{emo}|
% | |[\filedate\space\fileversion\space\fileinfo]
% \end{verbatimish}
%
% Unfortunately, emo's version number appears in triplicate in this file, which
% makes cutting a release a little more tricky than it should be. Alas, the
% above, faux package declaration is not one of those repeat offenders. Really.
%
%
% ^^A ----------------------------------------------------------------------------------
% \subsection{Package Options}
%
% \begin{macro}{\ifEmojiExtra}
% \begin{macro}{\ifemo@index}
% \begin{macro}{\ifemo@debug}
% \changes{0.4}{}{Add {\tt debug} option for drawing boundary boxes}
% Define a conditional flag for each package option.
% \begin{macrocode}
\newif\ifEmojiExtra
\newif\ifemo@index
\newif\ifemo@debug
% \end{macrocode}
%
% Wire each conditional to the package option and then process them all.
% \begin{macrocode}
\DeclareOption{extra}{\EmojiExtratrue}
\DeclareOption{index}{\emo@indextrue}
\DeclareOption{debug}{\emo@debugtrue}
\ProcessOptions\relax
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% ^^A ----------------------------------------------------------------------------------
% \subsection{Package Dependencies and Backend Selection}
%
% Require |inputenc| to declare this file's character encoding as UTF-8. XeTeX
% and LuaTeX already use that encoding by default and hence this line is
% redundant. But pdfTeX originates from darker, pre-Unicode times and thus needs
% to be told. Though thankfully, it too does support the encoding.
% \begin{macrocode}
\RequirePackage[utf8]{inputenc}
% \end{macrocode}
%
% \begin{macro}{\ifemo@use@unicode}
% \begin{macro}{\ifemo@use@font}
% \begin{macro}{\ifemo@use@pdf}
% Define a conditional flag for each major backend feature. They are \emph{not}
% orthogonal: |\ifemo@use@unicode| and |\ifemo@use@pdf| are mutually exclusive
% and determine whether emo generates Unicode text or PDF graphics. For
% |\ifemo@use@font| to be enabled, |\ifemo@use@unicode| must already be enabled
% as well.
% \begin{macrocode}
\newif\ifemo@use@unicode
\newif\ifemo@use@font
\newif\ifemo@use@pdf
% \end{macrocode}
%
% Inspect the runtime environment and accordingly set the just defined backend
% flags. |\HCode| is defined by TeX4ht. Since correctly converting to HTML with
% TeX4ht requires LuaTeX, print a helpful error message for other engines.
% \begin{macrocode}
\RequirePackage{iftex}
\ifdefined\HCode
\ifluatex\else
\PackageError{emo}{%
Use of TeX4ht for converting LaTeX to HTML requires LuaTeX.\MessageBreak
You may see ``Missing character'' messages or\MessageBreak
``Unicode character ... not set up'' errors.\MessageBreak
To fix, please pass the -l or --lua option to TeX4ht's make4ht tool}{%
Run TeX4ht with LuaTeX by passing -l or --lua option to make4ht}
\fi
\emo@use@unicodetrue
\else
\ifluatex
\emo@use@unicodetrue
\emo@use@fonttrue
\else
\emo@use@pdftrue
\fi
\fi
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% We need the backend flags to decide whether to load |fontspec| or not. We do
% that before requiring any other packages because, that way, the packages related
% to encoding and fonts are loaded first (together with |iftex|).
% \begin{macrocode}
\ifemo@use@font
\RequirePackage{fontspec}
\fi
% \end{macrocode}
%
% Require |xcolor| for formatting highly visible error messages within the
% generated document. Always including another package that is only used when
% there are errors is not ideal. But I couldn't get on-demand package loading to
% work. So we have to eagerly require the package.
% \begin{macrocode}
\RequirePackage{xcolor}
% \end{macrocode}
%
% The two remaining requirements depends on a package option and on the backend,
% respectively.
% \begin{macrocode}
\ifemo@index
\RequirePackage{index}
\fi
\ifemo@use@pdf
\RequirePackage{graphicx}
\fi
% \end{macrocode}
%
%
% ^^A ----------------------------------------------------------------------------------
% \subsection{The Emoji Table}
%
% \changes{0.3}{}{Include {\tt\char`\\lingchi} and {\tt\char`\\YHWH} in emoji table}
% \changes{1.0}{}{Drop {\tt\char`\\textdir} from emoji table entry for {\tt YHWH}}
% \changes{1.0}{}{Introduce high-level emoji table format that preserves Unicode
% grouping and order}
%
% The emoji table contains an entry for every emoji supported in the current
% configuration. To facilitate reuse of the same table definition for different
% purposes, including validating emoji names, determining emoji codepoints, and
% typesetting the currently supported inventory, emo abstracts over the table
% itself with the following five macros.
%
% \begin{macro}{\EmojiBeginGroup}
% \begin{macro}{\EmojiBeginSubroup}
% \begin{macro}{\DefineEmoji}
% \begin{macro}{\EmojiEndSubgroup}
% \begin{macro}{\EmojiEndGroup}
% The file format for |emo.def| relies on |\DefineEmoji| to associate emoji
% names with their Unicode codepoints, |\EmojiBeginGroup| and |\EmojiEndGroup|
% to organize emoji into groups, and on |\EmojiBeginSubgroup| and
% |\EmojiEndSubgroup| to organize emoji into subgroups. All definitions with
% |\DefineEmoji| are listed in Unicode display order and grouped in their
% Unicode group and subgroup. Subgroups are properly nested inside groups. The
% group and subgroup for |lingchi| and |YHWH| are both called |extra|.
%
% |\DefineEmoji|\marg{name}\marg{codepoints} takes an emoji's name and its
% Unicode codepoints as arguments---except for |keycap-hash|, which uses has the
% |\char|'ed codepoints as value because TeX gets very much confused by the
% leading hash character in that emoji's codepoints.
%
% |\EmojiBeginGroup|\marg{group} and |\EmojiEndGroup|\marg{group} take a group
% name as their only argument. In contrast,
% |\EmojiBeginSubgroup|\marg{group}\marg{subgroup} and
% |\EmojiEndSubgroup|\marg{group}\marg{subgroup} take both the group and
% subgroup names as their two arguments.
%
% If the |extra| option is enabled, |\lingchi| and |\YHWH| are treated just like
% emoji, and their names and Unicode codepoints (sans any group, font selection,
% or text direction) are included with the emoji table.
%
% The conversion from the abstract file format for |emo.def| to the concrete
% emoji table is simple enough, especially since four macros remain no-ops:
% \begin{macrocode}
\def\EmojiBeginGroup#1{}
\def\EmojiBeginSubgroup#1#2{}
\def\DefineEmoji#1#2{%
\expandafter\def\csname emo@emoji@#1\endcsname{#2}}
\def\EmojiEndSubgroup#1#2{}
\def\EmojiEndGroup#1{}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% With that, we are ready to read |emo.def|:
% \begin{macrocode}
\input{emo.def}
% \end{macrocode}
%
% The emoji table is automatically generated with the |config/emo.py| Python
% script. When invoked without arguments, that script simply recreates the emoji
% table based on the emoji present in the |emo-graphics| directory. If invoked
% with arguments naming Unicode emoji groups, groups and subgroups, or
% individual emoji, the script converts SVG graphics from the Noto emoji
% sources to PDF graphics compatible with LaTeX and then updates the inventory
% in |emo.def|. The Python script even downloads the Noto emoji sources if they
% haven't been already downloaded to the local machine.
%
%
% ^^A ----------------------------------------------------------------------------------
% \subsection{Internal Macros}
%
% \begin{macro}{\emo@error@fg}
% \begin{macro}{\emo@error@bg}
% \begin{macro}{\emo@error}
% Define two colors and the |\emo@error|\marg{emoji-name} macro. The latter uses
% the two colors for formatting an attention-grabbing error message. If you use
% an invalid emoji name and overlook the warning in the console, you \emph{will}
% notice the error messsage in the document thusly formatted.
% \begin{macrocode}
\definecolor{emo@error@fg}{rgb}{1,1,1}
\definecolor{emo@error@bg}{rgb}{.6824,.0863,.0863}
\def\emo@error#1{%
\colorbox{emo@error@bg}{%
\textcolor{emo@error@fg}{%
\textsf{Bad} \texttt{\char`\\emo\{#1\}}}}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\emo@ifdef}
% The |\emo@ifdef|\marg{name}\marg{code} macro validates the emoji name given as
% first argument. If the name is invalid, it expands to an error message. If the
% name is valid, it executes the code given as the second argument. The
% implementation critically relies on the emoji table being accurate.
% \begin{macrocode}
\def\emo@ifdef#1#2{%
\ifcsname emo@emoji@#1\endcsname#2\else%
\PackageWarning{emo}{Unknown emoji name in `\string\emo{#1}'}%
\emo@error{#1}%
\fi}
% \end{macrocode}
% \end{macro}
%
%
% ^^A ----------------------------------------------------------------------------------
% \subsection{Emo's Public Macros and Render Hooks}
%
% To support up to three macros across three LaTeX engines and two HTML
% conversion tools, emo's implementation originally defined the same macros
% twice or thrice, with some code duplication between them as well. As I gained
% experience with LaTeX, I settled on \emph{hooks} as a powerful means for
% avoiding extra macros as well as code duplication.
%
%
% \subsubsection{A Skeleton of Render Hooks}
%
% \begin{macro}{emo/render/before}
% \begin{macro}{emo/render/emoji}
% \begin{macro}{emo/render/chinese}
% \begin{macro}{emo/render/hebrew}
% \begin{macro}{emo/render/content}
% \begin{macro}{emo/render/after}
% To determine just those hooks, let's review emo's functional requirements and
% pay close attention to how those requirements converge and diverge between
% emo's three macros: