TiCL: the prototype Programmatic Star T EX: the Next Generation - - PowerPoint PPT Presentation

ticl the prototype
SMART_READER_LITE
LIVE PREVIEW

TiCL: the prototype Programmatic Star T EX: the Next Generation - - PowerPoint PPT Presentation

TiCL Didier Verna Introduction TiCL: the prototype Programmatic Star T EX: the Next Generation (Season 2) Textual Extensions Conclusion Didier Verna didier@lrde.epita.fr @didierverna facebook/didier.verna


slide-1
SLIDE 1

TiCL Didier Verna Introduction Programmatic Textual Extensions Conclusion

TiCL: the prototype

Star T EX: the Next Generation (Season 2) Didier Verna

didier@lrde.epita.fr @didierverna facebook/didier.verna http://www.lrde.epita.fr/˜didier

TUG 2013, October 23 – 26

1/23

slide-2
SLIDE 2

TiCL Didier Verna Introduction Programmatic Textual Extensions Conclusion

T EX The [final] frontier. These are the voyages, Of a software enterprise. Its continuing mission: To explore new tokens, To seek out a new life, New forms of implementation. . .

2/23

slide-3
SLIDE 3

TiCL Didier Verna Introduction Programmatic Textual Extensions Conclusion

A modernized T EX

Previously, on Star T EX TNG. . .

T EX’s strength is in the quality of its typesetting, not in its programmatic interface. Keep the typesetting functionality but provide. . . A more modern and consistent API Real programming capabilities Still simple to use (at least for simple things) Extensibility / customizability

4/23

slide-4
SLIDE 4

TiCL Didier Verna Introduction Programmatic Textual Extensions Conclusion

Fitness of Lisp

Previously, on Star T EX TNG. . .

Existing approaches are heterogeneous What about a fully integrated approach ? Industrial-scale general purpose language

◮ Multi-paradigm ◮ Highly optimizable ◮ Pletora of libraries

Scripting / extension language

◮ Highly dynamic ◮ Highly reflexive ◮ Easy to learn (no syntax) 5/23

slide-5
SLIDE 5

TiCL Didier Verna Introduction Programmatic Textual Extensions Conclusion

TiCL: the prototype

Current architecture

6/23

slide-6
SLIDE 6

TiCL Didier Verna Introduction Programmatic Textual Extensions Conclusion

This is where we start

Not very T

  • EXy. . .

cl-typesetting Hello World

( defun first−document (&key ( f i l e "/tmp/texput.pdf" ) ) ( t t : with−document ( ) ( l e t ( ( content ( t t : compile−text ( ) ( t t : paragraph ( ) "This is some text." ) ) ) ) ( t t : draw−pages content ) (when pdf :∗page∗ ( typeset : finalize−page pdf :∗page ∗)) ( t t : write−document f i l e ) ) ) ) 8/23

slide-7
SLIDE 7

TiCL Didier Verna Introduction Programmatic Textual Extensions Conclusion

L

A

T EX-like programmatic layer: step 1

Still full of Lisp idioms

Global variables: *title*, *author* etc. Functions: document-class, make-title etc.

Note: keywords arguments

Macros: with-document, with-section etc.

9/23

slide-8
SLIDE 8

TiCL Didier Verna Introduction Programmatic Textual Extensions Conclusion

L

A

T EX-like programmatic layer: step 2

Less full of Lisp idioms

Non lispy accessors (although for constants) Non lispy function (macro) names Raw symbols instead of keywords

◮ for constant arguments ◮ Requires a macro layer

Example

; ; Before : ( document−class : a r t i c l e : paper : l e t t e r : pt 12) ; ; After : ( documentclass a r t i c l e : paper l e t t e r : pt 12) 10/23

slide-9
SLIDE 9

TiCL Didier Verna Introduction Programmatic Textual Extensions Conclusion

L

A

T EX-like programmatic layer: step 3

Even less full of Lisp idioms

Symbol macros Turning 0-ary function calls into mere symbols More non lispy function (macro) names Example

; ; Before : ( make−title ) ( table−of−contents ) ; ; After : maketitle tableofcontents 11/23

slide-10
SLIDE 10

TiCL Didier Verna Introduction Programmatic Textual Extensions Conclusion

L

A

T EX-like programmatic layer: step 4

Getting rid of some with-* idioms

A (par) command instead of the with-par macro And the par symbol macro that goes with it. Example

; ; Before : ( with−par "bla bla bla") ( with−par "bla bla bla") ; ; After : "bla bla bla" par "bla bla bla" 12/23

slide-11
SLIDE 11

TiCL Didier Verna Introduction Programmatic Textual Extensions Conclusion

L

A

T EX-like programmatic layer: step 5

Getting rid of some other with-* idioms

Standalone sectionning commands Need to get rid of underlying macros Require explicit state management

e.g. PDF outline levels

Example

; ; Before : ( with−section "Title" "bla bla bla" par "bla bla bla") ; ; After : ( section "Title") "bla bla bla" par "bla bla bla" 13/23

slide-12
SLIDE 12

TiCL Didier Verna Introduction Programmatic Textual Extensions Conclusion

L

A

T EX-like programmatic layer: step 6

The “empty lines” trick

Replacing par with empty lines in Lisp strings Requires overriding cl-typesetting’s behavior But that’s easy (it’s Lisp) ! Example

; ; Before : ( section "Title") "bla bla bla" par "bla bla bla") ; ; After : ( section "Title") "bla bla bla bla bla bla" 14/23

slide-13
SLIDE 13

TiCL Didier Verna Introduction Programmatic Textual Extensions Conclusion

L

A

T EX-like programmatic layer: step 7

L

AT

EX-like named environments

When impossible to get rid of the macro layer Syntax extension through (read-time) macro characters Example

; ; Before : ( with−document "bla bla bla" "bla bla bla") ; ; After : { begin document } "bla bla bla" "bla bla bla" { end document } 15/23

slide-14
SLIDE 14

TiCL Didier Verna Introduction Programmatic Textual Extensions Conclusion

L

A

T EX-like textual layer

The ultimate goal

Idea

◮ Remain text-driven instead of program-driven ◮ Convert automatically to the programmatic layer

Implementation

◮ Use \ as an escape (to Lisp) character ◮ Everything else is accumulated into Lisp strings

Example

; ; Before : ( section "Lorem Ipsum") "Lorem " ( t e x t b f "ipsum") " " ( t e x t i t "dolor") " sit amet, ... ;; After: \(section "Lorem Ipsum") Lorem \(textbf "ipsum") \(textit "dolor") sit amet, ... 17/23

slide-15
SLIDE 15

TiCL Didier Verna Introduction Programmatic Textual Extensions Conclusion

The merits of extensibility

By example

Rivers detection

◮ Requires introspection (boxes internal representation) ◮ But that’s easy (it’s Lisp, and OO) !

Implementation

◮ New kind of box (subclass of vbox) ◮ Collects content subject to rivers detection ◮ Additional stroking method for this new box ◮ User-level “rivers” environment 19/23

slide-16
SLIDE 16

TiCL Didier Verna Introduction Programmatic Textual Extensions Conclusion

Conclusion

Last year: fitness of Lisp for a T EX implementation This year: proof of concept Remember the objectives ?

◮ A more modern and consistent API ◮ Real programming capabilities ◮ Still simple to use (at least for simple things) ◮ Extensibility / customizability 21/23

slide-17
SLIDE 17

TiCL Didier Verna Introduction Programmatic Textual Extensions Conclusion

These were the voyages, Of a software enterprise. Its continuing mission: To explore new tokens, To seek out a new life, New forms of implementation. To \textbf{go}, Where no T EX has gone before!

22/23

slide-18
SLIDE 18

TiCL Didier Verna Introduction Programmatic Textual Extensions Conclusion

Live long and prosper!

Questions?

23/23