\load:nxtxorg:package(list-of-contents) \load:nxtxorg:package(bibliography) \load:nxtxorg:package(acronyms) \load:nxtxorg:package(styling) \load:nxtxorg:package(layout) \load:nxtxorg:package(plot) \load:nxtxorg:package(basic-formatting) \title(NxTx Demo) \set-google-font-family('Merriweather', 'mono') \ac:define(AST, 'Abstract Syntax Tree') \ac:define(DOM, 'Document Object Model') \loc-print \chapter(Two-pass rendering) NxTx utilises two-pass rendering to provide enough flexibility to support needed things, such as list of contents. \section(First pass) First pass executes the preprocessors invoked in the document source code. The return values from these preprocessors replaces the invocation node if no command is registered to the same name. \section(Second pass) Second pass renders the nodes in document \ac(AST). \ac(DOM) elements, such as \text:tt(#text) \text:tt(img) nodes, are placed directly on the \dquote(paper) and commands are executed and their return values are then placed in the document. The NxTx rendering engine automatically detects when the \dquote(paper) has overflown and insert a new piece a paper, and moves the element that is out of bounds to the new page. \chapter(Concurrency) All preprocessors that are in the same paragraph are executed in concurrently using \text:tt(Promise.all). The same applies to all commands used in the same paragraph. This is useful for quickly loading the packages needed for a document, as all the packages are fetched at the same time insted of one by one. \chapter(Commands) Commands are executed recursively; if they return a command node (or an array containing command nodes), those nodes are executed as well and the return value replaces the executed node. Commands typically return a string or a \ac(DOM) element, but can also return arrays of these. \section(Syntax) In NxTx, commands are invoked similarly to LaTeX; starting with a backslash (\text:tt(\)) followed by the name of the command and then the input arguments, enclosed in parentheses. Example: \text:tt("\text:tt('Hello World')") The NxTx language does not contain syntax for defining commands, nor is it planned. Instead ES/JS is used, as that seemed more fitting than the (La)TeX approach. JavaScript is a (debately) nice, turing complete programming language that runs (fast) in the browser. Why not use this fitting tool? \chapter(Preprocessors) Preprocessors are invoked in exactly the same way as commands. Both a command and a preprocessor can be registered to the same name. The difference between the two is that preprocessors are executed during the first pass of rendering a document, and commands in the second. The return value from preprocessors are only used if no command is registered to the same name, and is not rendered straight away, but instead replaces the invocation node in the AST. \chapter(Packages) NxTx comes as a barebones parser and renderer, the rest is up to packages! Packages can contain a number of preprocessors and commands that extend the rendering capabilities of NxTx. This architecture allows for only downloading/using the packages needed to render your document. Packages \section(Package demos) Here are some demos of some packages \subsection(Plot package) \plot({ y:{ values:[3,45,6,34,4,5,5,4,35,34] }, lines:[ { x:[0,100], y:[0,100] } ] })