From 4e1f4ca586bd51ccf70343411162103dfc96e1e0 Mon Sep 17 00:00:00 2001
From: Philipp Gesang <phg42.2a@gmail.com>
Date: Thu, 20 Mar 2014 07:17:33 +0100
Subject: [doc] make inline code work consistently with both formats

---
 doc/luaotfload-context.tex | 38 +++++++++++++++++++++++++++++++++-----
 1 file changed, 33 insertions(+), 5 deletions(-)

(limited to 'doc/luaotfload-context.tex')

diff --git a/doc/luaotfload-context.tex b/doc/luaotfload-context.tex
index aeca7cb..6c8d4b2 100644
--- a/doc/luaotfload-context.tex
+++ b/doc/luaotfload-context.tex
@@ -83,8 +83,8 @@
 \definefontfeature [monospace]           [liga=no,tlig=no,onum=no]
 
 \definefontfamily [mainface] [serif] [Linux Libertine O] [features=default]
-%\definefontfamily [mainface] [serif] [Liberation Serif] [feature=default]
-%\definefontfamily [mainface] [sans]  [Iwona]             [feature=default]
+%definefontfamily [mainface] [serif] [Liberation Serif] [feature=default]
+%definefontfamily [mainface] [sans]  [Iwona]             [feature=default]
 \definefontfamily [mainface] [sans]  [Iwona Medium] [
   feature=default,
   it=file:IwonaMedium-Italic.otf,
@@ -128,7 +128,9 @@
 \definetype [luafunction] [style=typing:luafunction]
 \setuptyping [style=ttx]
 
-\definebodyfontenvironment [8pt]
+\definebodyfontenvironment  [8pt]
+\definebodyfontenvironment [10pt]
+\definebodyfontenvironment [12pt]
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %% headings
@@ -196,7 +198,26 @@
 %% Context offers both \type{…} and \type<<…>>, but not an unbalanced
 %% one that we could map directly onto Latex’s \verb|…|.
 
-\definetype [inlinecode] [style=emphasis:nonproportional]
+\definetype [inlinecode_indeed] [style=emphasis:nonproportional]
+
+%% The listings macros don’t seem to handle backslashes and braces
+%% well. We emulate this behavior by handling the escaping in Lua.
+
+\startluacode
+  local lpeg           = require "lpeg"
+  local Cs, P, S       = lpeg.Cs, lpeg.P, lpeg.S
+  local lpegmatch      = lpeg.match
+  local unescape_char  = S[[\letterbackslash\letterleftbrace\letterrightbrace]]
+  local backslash      = P[[\letterbackslash]]
+  local unescape       = Cs (((backslash / "" * unescape_char) + 1)^0)
+  commands.unescape_things = function (str)
+    context.type (lpegmatch (unescape, str))
+  end
+\stopluacode
+
+\unexpanded \def \inlinecode #content{%
+  \ctxcommand {unescape_things \!!bs \detokenize {#content}\!!es}%
+}
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %% codelistings
@@ -209,6 +230,7 @@
 
 \unexpanded \def \endlisting {\typebuffer [listing]}
 
+
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %% enumerations and lists
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -308,7 +330,13 @@
 %% special elements
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-\def \meta #1{<{\italic #1}>}
+\definefont [lmromantenregular] [file:lmroman10-regular.otf*default]
+
+\def \meta #1{%
+  {\lmromantenregular<}%
+  {\italic #1}%
+  {\lmromantenregular>}%
+}
 
 \def \beginabstractcontent {%
   \grabbufferdatadirect{abstractcontent}{beginabstractcontent}{endabstractcontent}%
-- 
cgit v1.2.3

