Skip to content

Instantly share code, notes, and snippets.

View phi-gamma's full-sized avatar
💤
Does nothing unless polled.

Philipp Gesang phi-gamma

💤
Does nothing unless polled.
View GitHub Profile
local traverse_nodes = node.traverse
local iowrite = io.write
local tableconcat = table.concat
local utfchar = unicode.utf8.char
local stringformat = string.format
local stringrep = string.rep
local nodelength = node.length
local count_nodes = node.count
local nodecodes = table.mirrored (node.types())
@phi-gamma
phi-gamma / Makefile
Last active July 7, 2017 18:20 — forked from brentp/Makefile
lua binary module example
LUA_CFLAGS=-I/usr/include/lua
LUA_CFLAGS+=-Wall -Werror
all: stringext.so
stringext.so: stringext.c
$(CC) $(LUA_CFLAGS) -O3 -fPIC -o stringext.o -c stringext.c
$(CC) -shared -O3 stringext.o -o stringext.so
clean:
@phi-gamma
phi-gamma / someinputfile.tex
Last active December 24, 2015 04:49
Collecting info about tokens with Luatex (http://tex.stackexchange.com/q/135319/14066)
current file: \printcurrentfile, line \printcurrentpos \par
This token is going to be listed: \collecttoken \jobname %% collect “\jobname”
\setupregister [index] [symbol=n,]
\setupbodyfont [serif,10pt]
\starttext
\placeindex
\page [yes]
\startchapter[title={Everything Buns},]
\index{all-purpose flour+Everything Buns}
@phi-gamma
phi-gamma / devanagari-test.tex
Last active December 22, 2015 14:58
test for Devanagari in Context MkIV (ad http://tex.stackexchange.com/q/132228/14066)
\definefont [DevaOne] [file:chandas.ttf*devanagari-one at 18pt]
\definefont [DevaTwo] [file:uttara.ttf*devanagari-two at 18pt]
\def \devanagaritest #1{%
\detokenize {#1}:\crlf
\bgroup#1
श्रेयो हि ज्ञानमभ्यासाज्ज्ञानाद्ध्यानं विशिष्यते । \crlf
ध्यानात्कर्मफलत्यागस्त्यागाच्छन्तिरनन्तरम् ॥
\egroup
\endgraf
@phi-gamma
phi-gamma / import-typo-dir.lua
Last active December 22, 2015 14:49
import the bidi code from Context (http://tex.stackexchange.com/q/132241); DON’T DO THIS AT HOME, use Context instead!
-----------------------------------------------------------------------
-- FILE: import-typo-dir.lua
-- DESCRIPTION: fake enough of Context to load typo-dir.lua
-- REQUIREMENTS: Context MkIV, Luoatfload, Lualibs etc.
-- AUTHOR: Philipp Gesang (Phg), <phg42.2a@gmail.com>
-- VERSION: 0.0
-- CREATED: 2013-09-08 19:58:40+0200
-----------------------------------------------------------------------
--
@phi-gamma
phi-gamma / beegradients.lua
Last active September 28, 2016 06:06
bee gradients for TeX documents: http://tex.stackexchange.com/q/131883/14066
packagedata = packagedata or { }
packagedata.beegradients = { }
local beegradients = packagedata.beegradients
local processorid = "beegradients" --- name of callback
local err, warn, info
if luatexbase then
err, warn, info = luatexbase.provides_module {
name = "beegradients",
@phi-gamma
phi-gamma / ltx-gdocs-spreadsheet.tex
Created September 6, 2013 18:19
typeset google spreadsheets directly in Luatex
%% http://tex.stackexchange.com/q/131500
\documentclass {scrartcl}
\usepackage {luatexbase}
\RequireLuaModule {lualibs}
\usepackage {luaotfload} %% recommended, in that order!
\RequireLuaModule {spreadsheet}
\makeatletter
-----------------------------------------------------------------------
-- FILE: sidebearings.lua
-- USAGE: ./sidebearings.lua
-- DESCRIPTION: access sidebearings with Luatex
-- REQUIREMENTS: luaotfload version >= 2.2
-- AUTHOR: Philipp Gesang (Phg), <phg42.2a@gmail.com>
-- VERSION: 1.0
-- CREATED: 2013-08-27 15:27:20+0200
-----------------------------------------------------------------------
--
if not modules then modules = { } end modules ['luaotfload-database'] = {
version = "2.3b",
comment = "companion to luaotfload.lua",
author = "Khaled Hosny, Elie Roux, Philipp Gesang",
copyright = "Luaotfload Development Team",
license = "GNU GPL v2"
}
--- TODO: if the specification is an absolute filename with a font not in the
--- database, add the font to the database and load it. There is a small