summaryrefslogtreecommitdiff
path: root/tex
diff options
context:
space:
mode:
authorMarius <mariausol@gmail.com>2011-07-20 15:20:14 +0300
committerMarius <mariausol@gmail.com>2011-07-20 15:20:14 +0300
commit68370bca95774296cb8890136f563b902022e6db (patch)
tree2dfe343bc0e9d47f92d83e28481eaa38ae015c48 /tex
parent4b73db70e44825563db88d9f5943551af419e457 (diff)
downloadcontext-68370bca95774296cb8890136f563b902022e6db.tar.gz
beta 2011.07.20 14:10
Diffstat (limited to 'tex')
-rw-r--r--tex/context/base/cont-new.mkii2
-rw-r--r--tex/context/base/cont-new.mkiv2
-rw-r--r--tex/context/base/context.mkii2
-rw-r--r--tex/context/base/context.mkiv2
-rw-r--r--tex/context/base/font-con.lua8
-rw-r--r--tex/context/base/m-markdown.lua704
-rw-r--r--tex/context/base/m-markdown.mkiv82
-rw-r--r--tex/context/base/math-act.lua7
-rw-r--r--tex/context/base/math-dim.lua3
-rw-r--r--tex/context/base/meta-imp-dum.mkiv68
-rw-r--r--tex/context/base/status-files.pdfbin23757 -> 23798 bytes
-rw-r--r--tex/context/base/status-lua.pdfbin162151 -> 162154 bytes
-rw-r--r--tex/context/base/strc-lev.lua14
-rw-r--r--tex/context/base/strc-lev.mkiv15
-rw-r--r--tex/context/base/strc-lst.mkiv26
-rw-r--r--tex/context/base/symb-mvs.mkii2
-rw-r--r--tex/context/base/type-one.mkii2
-rw-r--r--tex/context/base/type-otf.mkii2
-rw-r--r--tex/generic/context/luatex/luatex-fonts-merged.lua10
19 files changed, 894 insertions, 57 deletions
diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii
index f9f6051c0..3c18bc96d 100644
--- a/tex/context/base/cont-new.mkii
+++ b/tex/context/base/cont-new.mkii
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2011.07.19 11:22}
+\newcontextversion{2011.07.20 14:10}
%D This file is loaded at runtime, thereby providing an
%D excellent place for hacks, patches, extensions and new
diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv
index 3ea2ee162..1d44c51c3 100644
--- a/tex/context/base/cont-new.mkiv
+++ b/tex/context/base/cont-new.mkiv
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2011.07.19 11:22}
+\newcontextversion{2011.07.20 14:10}
%D This file is loaded at runtime, thereby providing an
%D excellent place for hacks, patches, extensions and new
diff --git a/tex/context/base/context.mkii b/tex/context/base/context.mkii
index 6224cc9b7..cd8d1c540 100644
--- a/tex/context/base/context.mkii
+++ b/tex/context/base/context.mkii
@@ -20,7 +20,7 @@
%D your styles an modules.
\edef\contextformat {\jobname}
-\edef\contextversion{2011.07.19 11:22}
+\edef\contextversion{2011.07.20 14:10}
%D For those who want to use this:
diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv
index a63d89bf9..ee369b8c5 100644
--- a/tex/context/base/context.mkiv
+++ b/tex/context/base/context.mkiv
@@ -20,7 +20,7 @@
%D your styles an modules.
\edef\contextformat {\jobname}
-\edef\contextversion{2011.07.19 11:22}
+\edef\contextversion{2011.07.20 14:10}
%D For those who want to use this:
diff --git a/tex/context/base/font-con.lua b/tex/context/base/font-con.lua
index 45bb5ee59..a7df34199 100644
--- a/tex/context/base/font-con.lua
+++ b/tex/context/base/font-con.lua
@@ -364,10 +364,10 @@ function constructors.scale(tfmdata,specification)
targetparameters.descender = delta * descender
end
-- copies, might disappear
- targetparameters.xheight = targetparameters.xheight or parameters.x_height
- targetparameters.extraspace = targetparameters.extraspace or parameters.extra_space
- targetparameters.spacestretch = targetparameters.spacestretch or parameters.space_stretch
- targetparameters.spaceshrink = targetparameters.spaceshrink or parameters.space_shrink
+ targetparameters.xheight = targetparameters.xheight or targetparameters.x_height or parameters.x_height
+ targetparameters.extraspace = targetparameters.extraspace or targetparameters.extra_space or parameters.extra_space
+ targetparameters.spacestretch = targetparameters.spacestretch or targetparameters.space_stretch or parameters.space_stretch
+ targetparameters.spaceshrink = targetparameters.spaceshrink or targetparameters.space_shrink or parameters.space_shrink
--
local protrusionfactor = (targetquad ~= 0 and 1000/targetquad) or 0
local scaledwidth = defaultwidth * hdelta
diff --git a/tex/context/base/m-markdown.lua b/tex/context/base/m-markdown.lua
new file mode 100644
index 000000000..552e046ef
--- /dev/null
+++ b/tex/context/base/m-markdown.lua
@@ -0,0 +1,704 @@
+if not modules then modules = { } end modules ['x-markdown'] = {
+ version = 1.001,
+ comment = "companion to x-markdown.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "see below",
+ license = "see context related readme files"
+}
+
+--[[
+Copyright (C) 2009 John MacFarlane / Khaled Hosny / Hans Hagen
+
+The main parser is derived from the lunamark parser written by John MacFarlane. You
+can download lunamark from:
+
+ http://github.com/jgm/lunamark.git
+
+Khaled Hosny provided the context writer for lunamark and that was used as starting
+point for the mapping. The original code can be fetched from the above location.
+
+While playing with the original code I got the feeling that lpeg could perform better.
+The slowdown was due to the fact that the parser's lpeg was reconstructed each time a
+nested parse was needed. After changing that code a bit I could bring down parsing of
+some test code from 2 seconds to less than 0.1 second so I decided to stick to this
+parser instead of writing my own. After all, the peg code looks pretty impressive and
+visiting Johns pandoc pages is worth the effort:
+
+ http://johnmacfarlane.net/pandoc/
+
+The code here is mostly meant for processing snippets embedded in a context
+documents and is no replacement for pandoc at all. Therefore an alternative is to use
+pandoc in combination with Aditya's filter module.
+
+As I changed (and optimized) the original code, it will be clear that all errors
+are mine. Eventually I might also adapt the parser code a bit more. When I ran into of
+closure stack limitations I decided to flatten the code. The following implementation
+seems to be a couple of hundred times faster than what I started with which is not that
+bad.
+]]--
+
+-- todo: we have better quote and tag scanners in ctx
+-- todo: provide an xhtml mapping
+
+local type, next = type, next
+local lower, upper, gsub, rep, gmatch, format, length = string.lower, string.upper, string.gsub, string.rep, string.gmatch, string.format, string.len
+local concat = table.concat
+local P, R, S, V, C, Ct, Cg, Cb, Cmt, Cc, Cf, Cs = lpeg.P, lpeg.R, lpeg.S, lpeg.V, lpeg.C, lpeg.Ct, lpeg.Cg, lpeg.Cb, lpeg.Cmt, lpeg.Cc, lpeg.Cf, lpeg.Cs
+local lpegmatch = lpeg.match
+local utfbyte = utf.byte
+
+moduledata.markdown = moduledata.markdown or { }
+local markdown = moduledata.markdown
+
+local nofruns, nofbytes, nofhtmlblobs = 0, 0, 0
+
+local function process(func,t)
+ for i=1,#t do
+ t[i] = func(t[i])
+ end
+ return t
+end
+
+local function traverse_tree(t,buffer,n)
+ for k, v in next, t do
+ if type(v) == "string" then
+ n = n + 1
+ buffer[n] = v
+ else
+ n = traverse_tree(v,buffer,n)
+ end
+ end
+ return n
+end
+
+local function to_string(t)
+ local buffer = { }
+ traverse_tree(t, buffer, 0)
+ return concat(buffer)
+end
+
+local function normalize_label(a)
+ return upper(gsub(a, "[\n\r\t ]+", " "))
+end
+
+-- generic
+
+local blocktags = table.tohash {
+ "address", "blockquote" , "center", "dir", "div", "p", "pre",
+ "li", "ol", "ul", "dl", "dd",
+ "form", "fieldset", "isindex", "menu", "noframes", "frameset",
+ "h1", "h2", "h3", "h4", "h5", "h6",
+ "hr", "ht", "script", "noscript",
+ "table", "tbody", "tfoot", "thead", "th", "td", "tr",
+}
+
+local asterisk = P("*")
+local dash = P("-")
+local plus = P("+")
+local underscore = P("_")
+local period = P(".")
+local hash = P("#")
+local ampersand = P("&")
+local backtick = P("`")
+local less = P("<")
+local more = P(">")
+local space = P(" ")
+local squote = P("'")
+local dquote = P('"')
+local lparent = P("(")
+local rparent = P(")")
+local lbracket = P("[")
+local rbracket = P("]")
+local slash = P("/")
+local equal = P("=")
+local colon = P(":")
+local semicolon = P(";")
+
+local digit = R("09")
+local hexdigit = R("09","af","AF")
+local alphanumeric = R("AZ","az","09")
+
+local doubleasterisks = P("**")
+local doubleunderscores = P("__")
+local fourspaces = P(" ")
+
+local any = P(1)
+local always = P("")
+
+local tab = P("\t")
+local spacechar = S("\t ")
+local newline = P("\r")^-1 * P("\n")
+local spaceornewline = spacechar + newline
+local nonspacechar = any - spaceornewline
+local optionalspace = spacechar^0
+local spaces = spacechar^1
+local eof = - any
+local nonindentspace = space^-3
+local blankline = optionalspace * C(newline)
+local blanklines = blankline^0
+local skipblanklines = (optionalspace * newline)^0
+local linechar = P(1 - newline)
+local indent = fourspaces + (nonindentspace * tab) / ""
+local indentedline = indent * C(linechar^1 * (newline + eof))
+local optionallyindentedline = indent^-1 * C(linechar^1 * (newline + eof))
+local spnl = optionalspace * (newline * optionalspace)^-1
+local specialchar = S("*_`*&[]<!\\")
+local normalchar = any - (specialchar + spaceornewline)
+local line = C((any - newline)^0 * newline)
+ + C(any^1 * eof)
+local nonemptyline = (any - newline)^1 * newline
+local htmlattributevalue = squote * C((any - (blankline + squote))^0) * squote
+ + dquote * C((any - (blankline + dquote))^0) * dquote
+ + (any - S("\t >"))^1 -- any - tab - space - more
+local htmlattribute = (alphanumeric + S("_-"))^1 * spnl * (equal * spnl * htmlattributevalue)^-1 * spnl
+local htmlcomment = P("<!--") * (any - P("-->"))^0 * P("-->")
+local htmltag = less * spnl * slash^-1 * alphanumeric^1 * spnl * htmlattribute^0 * slash^-1 * spnl * more
+
+local function lineof(c)
+ return (nonindentspace * (P(c) * optionalspace)^3 * newline * blankline^1)
+end
+
+local lineof_asterisks = lineof(asterisk)
+local lineof_dashes = lineof(dash)
+local lineof_underscores = lineof(underscore)
+
+local bullet = nonindentspace * (plus + (asterisk - lineof_asterisks) + (dash - lineof_dashes)) * spaces
+local enumerator = nonindentspace * digit^1 * period * spaces
+
+local openticks = Cg(backtick^1, "ticks")
+local closeticks = space^-1 * Cmt(C(backtick^1) * Cb("ticks"), function(s,i,a,b) return #a == #b and i end)
+local intickschar = (any - S(" \n\r`"))
+ + (newline * -blankline)
+ + (space - closeticks)
+ + (backtick^1 - closeticks)
+local inticks = openticks * space^-1 * C(intickschar^1) * closeticks
+
+local blocktag = Cmt(C(alphanumeric^1), function(s,i,a) return blocktags[lower(a)] and i, a end)
+
+local openblocktag = less * spnl * Cg(blocktag, "opentag") * spnl * htmlattribute^0 * more
+local closeblocktag = less * spnl * slash * Cmt(C(alphanumeric^1) * Cb("opentag"), function(s,i,a,b) return lower(a) == lower(b) and i end) * spnl * more
+local selfclosingblocktag = less * spnl * slash^-1 * blocktag * spnl * htmlattribute^0 * slash * spnl * more
+
+-- yields a blank line unless we're at the beginning of the document -- can be made more efficient
+
+interblockspace = Cmt(blanklines, function(s,i) if i == 1 then return i, "" else return i, "\n" end end)
+
+-- helper stuff
+
+local escaped = {
+ ["{" ] = "",
+ ["}" ] = "",
+ ["$" ] = "",
+ ["&" ] = "",
+ ["#" ] = "",
+ ["~" ] = "",
+ ["|" ] = "",
+ ["%%"] = "",
+ ["\\"] = "",
+}
+
+for k, v in next, escaped do
+ escaped[k] = "\\char" .. utfbyte(k) .. " "
+end
+
+local itemsignal = "\001"
+
+local itemsplitter = lpeg.tsplitat(itemsignal)
+
+-- what is lab.inline
+
+local c_linebreak = "\\crlf\n" -- is this ok?
+local c_entity = "?" -- todo, no clue of usage (use better entity handler)
+local c_space = " "
+
+local function c_string(s)
+ return (gsub(s,".",escaped))
+end
+
+local function c_paragraph(c)
+ return { c, "\n" } -- { "\\startparagraph ", c, " \\stopparagraph\n" }
+end
+
+-- local function c_plain(c)
+-- return c
+-- end
+
+-- itemize
+
+local function listitem(c)
+ return {
+ "\\startitem\n",
+ process(parser, lpegmatch(itemsplitter,c)),
+ "\n\stopitem\n"
+ }
+end
+
+local function c_tightbulletlist(c)
+ return {
+ "\\startmarkdownitemize[packed]\n",
+ process(listitem, c),
+ "\\stopmarkdownitemize\n"
+ }
+end
+
+local function c_loosebulletlist(c)
+ return {
+ "\\startmarkdownitemize\n",
+ process(listitem, c),
+ "\\stopmarkdownitemize\n"
+ }
+end
+
+local function c_tightorderedlist(c)
+ return {
+ "\\startmarkdownitemize[n,packed]\n",
+ process(listitem, c),
+ "\\stopmarkdownitemize\n"
+ }
+end
+
+local function c_looseorderedlist(c)
+ return {
+ "\\startmarkdownitemize[n]\n",
+ process(listitem, c),
+ "\\stopmarkdownitemize\n"
+ }
+end
+
+-- html
+
+local showhtml = false
+
+local function c_inline_html(c)
+ nofhtmlblobs = nofhtmlblobs + 1
+ if showhtml then
+ local x = xml.convert(c)
+ return {
+ "\\type{",
+ xml.tostring(x),
+ "}"
+ }
+ else
+ return ""
+ end
+end
+
+local function c_display_html(c)
+ nofhtmlblobs = nofhtmlblobs + 1
+ if showhtml then
+ local x = xml.convert(c)
+ return {
+ "\\starttyping\n",
+ xml.tostring(x),
+ "\\stoptyping\n"
+ }
+ else
+ return ""
+ end
+end
+
+-- highlight
+
+local function c_emphasis(c)
+ return {
+ "\\markdownemphasis{",
+ c,
+ "}"
+ }
+end
+
+local function c_strong(c)
+ return {
+ "\\markdownstrong{",
+ c,
+ "}"
+ }
+end
+
+-- blockquote
+
+local function c_blockquote(c)
+ return {
+ "\\startmarkdownblockquote\n",
+ parser(concat(c,"\n")),
+ "\\stopmarkdownblockquote\n"
+ }
+end
+
+-- verbatim
+
+local function c_verbatim(c)
+ return {
+ "\\startmarkdowntyping\n",
+ concat(c),
+ "\\stopmarkdowntyping\n"
+ }
+end
+
+local function c_code(c)
+ return {
+ "\\markdowntype{",
+ c,
+ "}"
+ }
+end
+
+-- sectioning (only relative, so no # -> ###)
+
+local levels = { "", "", "", "", "", "" }
+
+local function c_start_document()
+ levels = { "", "", "", "", "", "" }
+ return ""
+end
+
+local function c_stop_document()
+ return concat(levels,"\n") or ""
+end
+
+local function c_heading(level,c)
+ if level > #levels then
+ level = #levels
+ end
+ local finish = concat(levels,"\n",level+1) or ""
+ for i=level+1,#levels do
+ levels[level] = ""
+ end
+ levels[level] = "\\stopstructurelevel"
+ return {
+ finish,
+ "\\startstructurelevel[markdown][title={",
+ c,
+ "}]\n"
+ }
+end
+
+--
+
+local function c_hrule()
+ return "\\markdownrule\n"
+end
+
+local function c_link(lab,src,tit)
+ return {
+ "\\goto{",
+ lab.inlines,
+ "}[url(",
+ src,
+ ")]"
+ }
+end
+
+local function c_image(lab,src,tit)
+ return {
+ "\\externalfigure[",
+ src,
+ "]"
+ }
+end
+
+local function c_email_link(addr)
+ return c_link(addr,"mailto:"..addr)
+end
+
+-- Instead of local lpeg definitions we defne the nested parser first (this trick
+-- could be backported to the original code if needed).
+
+local references = { }
+
+local function f_reference_set(lab,src,tit)
+ return {
+ key = normalize_label(lab.raw),
+ label = lab.inlines,
+ source = src,
+ title = tit
+ }
+end
+
+local function f_reference_link_double(s,i,l)
+ local key = normalize_label(l.raw)
+ if references[key] then
+ return i, references[key].source, references[key].title
+ else
+ return false
+ end
+end
+
+local function f_reference_link_single(s,i,l)
+ local key = normalize_label(l.raw)
+ if references[key] then
+ return i, l, references[key].source, references[key].title
+ else
+ return false
+ end
+end
+
+local function f_label_collect(a)
+ return { "[", a.inlines, "]" }
+end
+
+local function f_label(a,b)
+ return {
+ raw = a,
+ inlines = b
+ }
+end
+
+local function f_pack_list(a)
+ return itemsignal .. concat(a)
+end
+
+local function f_reference(ref)
+ references[ref.key] = ref
+end
+
+local function f_append(a,b)
+ return a .. b
+end
+
+local function f_level_one_heading(c)
+ return c_heading(1,c)
+end
+
+local function f_level_two_heading(c)
+ return c_heading(2,c)
+end
+
+local function f_link(a)
+ return c_link({ inlines = c_string(a) }, a, "")
+end
+
+local syntax
+local nestedparser = function(inp) return to_string(lpegmatch(syntax,inp)) end
+
+syntax = { "Document", -- still rather close to the original but reformatted etc etc
+
+ Document = #(Cmt(V("References"), function(s,i,a) return i end)) -- what does this do
+ * Ct((interblockspace * V("Block"))^0)
+ * blanklines * eof,
+
+ References = (V("Reference") / f_reference + (nonemptyline^1 * blankline^1) + line)^0
+ * blanklines * eof,
+
+ Block = V("Blockquote")
+ + V("Verbatim")
+ + V("Reference") / { }
+ + V("HorizontalRule")
+ + V("Heading")
+ + V("OrderedList")
+ + V("BulletList")
+ + V("HtmlBlock")
+ + V("Para")
+ + V("Plain"),
+
+ Heading = V("AtxHeading")
+ + V("SetextHeading"),
+
+ AtxStart = C(hash * hash^-5) / length,
+
+ AtxInline = V("Inline") - V("AtxEnd"),
+
+ AtxEnd = optionalspace * hash^0 * optionalspace * newline * blanklines,
+
+ AtxHeading = V("AtxStart") * optionalspace * Ct(V("AtxInline")^1) * V("AtxEnd") / c_heading,
+
+ SetextHeading = V("SetextHeading1")
+ + V("SetextHeading2"),
+
+ SetextHeading1 = Ct((V("Inline") - V("Endline"))^1) * newline * equal^3 * newline * blanklines / f_level_one_heading,
+ SetextHeading2 = Ct((V("Inline") - V("Endline"))^1) * newline * dash ^3 * newline * blanklines / f_level_two_heading,
+
+ BulletList = V("BulletListTight")
+ + V("BulletListLoose"),
+
+ BulletListTight = Ct((bullet * V("ListItem"))^1) * blanklines * -bullet / c_tightbulletlist,
+
+ BulletListLoose = Ct((bullet * V("ListItem") * C(blanklines) / f_append)^1) / c_loosebulletlist, -- just Cs
+
+ OrderedList = V("OrderedListTight") + V("OrderedListLoose"),
+
+ OrderedListTight = Ct((enumerator * V("ListItem"))^1) * blanklines * -enumerator / c_tightorderedlist,
+
+ OrderedListLoose = Ct((enumerator * V("ListItem") * C(blanklines) / f_append)^1) / c_looseorderedlist, -- just Cs
+
+ ListItem = Ct(V("ListBlock") * (V("NestedList") + V("ListContinuationBlock")^0)) / concat,
+
+ ListBlock = Ct(line * V("ListBlockLine")^0) / concat,
+
+ ListContinuationBlock = blanklines * indent * V("ListBlock"),
+
+ NestedList = Ct((optionallyindentedline - (bullet + enumerator))^1) / f_pack_list,
+
+ ListBlockLine = -blankline * -(indent^-1 * (bullet + enumerator)) * optionallyindentedline,
+
+ InBlockTags = openblocktag * (V("HtmlBlock") + (any - closeblocktag))^0 * closeblocktag,
+
+ HtmlBlock = C(V("InBlockTags") + selfclosingblocktag + htmlcomment) * blankline^1 / c_display_html,
+
+ BlockquoteLine = ((nonindentspace * more * space^-1 * C(linechar^0) * newline)^1 * ((C(linechar^1) - blankline) * newline)^0 * C(blankline)^0 )^1,
+
+ Blockquote = Ct((V("BlockquoteLine"))^1) / c_blockquote,
+
+ VerbatimChunk = blanklines * (indentedline - blankline)^1,
+
+ Verbatim = Ct(V("VerbatimChunk")^1) * (blankline^1 + eof) / c_verbatim,
+
+ Label = lbracket * Cf(Cc("") * #((C(V("Label") + V("Inline")) - rbracket)^1), f_append) *
+ Ct((V("Label") / f_label_collect + V("Inline") - rbracket)^1) * rbracket / f_label,
+
+ RefTitle = dquote * C((any - (dquote ^-1 * blankline))^0) * dquote +
+ squote * C((any - (squote ^-1 * blankline))^0) * squote +
+ lparent * C((any - (rparent * blankline))^0) * rparent +
+ Cc(""),
+
+ RefSrc = C(nonspacechar^1),
+
+ Reference = nonindentspace * V("Label") * colon * spnl * V("RefSrc") * spnl * V("RefTitle") * blanklines / f_reference_set,
+
+ HorizontalRule = (lineof_asterisks + lineof_dashes + lineof_underscores) / c_hrule,
+
+ Para = nonindentspace * Ct(V("Inline")^1) * newline * blankline^1 / c_paragraph,
+
+ Plain = Ct(V("Inline")^1), -- / c_plain,
+
+ Inline = V("Str")
+ + V("Endline")
+ + V("UlOrStarLine")
+ + V("Space")
+ + V("Strong")
+ + V("Emphasis")
+ + V("Image")
+ + V("Link")
+ + V("Code")
+ + V("RawHtml")
+ + V("Entity")
+ + V("EscapedChar")
+ + V("Symbol"),
+
+ RawHtml = C(htmlcomment + htmltag) / c_inline_html,
+
+ EscapedChar = P("\\") * C(P(1 - newline)) / c_string,
+
+ -- we will use the regular entity handler
+
+ Entity = V("HexEntity")
+ + V("DecEntity")
+ + V("CharEntity") / c_entity,
+
+ HexEntity = C(ampersand * hash * S("Xx") * hexdigit^1 * semicolon),
+ DecEntity = C(ampersand * hash * digit^1 * semicolon),
+ CharEntity = C(ampersand * alphanumeric^1 * semicolon),
+
+ --
+
+ Endline = V("LineBreak")
+ + V("TerminalEndline")
+ + V("NormalEndline"),
+
+ NormalEndline = optionalspace * newline * -(
+ blankline
+ + more
+ + V("AtxStart")
+ + ( line * (P("===")^3 + P("---")^3) * newline )
+ ) / c_space,
+
+ TerminalEndline = optionalspace * newline * eof / "",
+
+ LineBreak = P(" ") * V("NormalEndline") / c_linebreak,
+
+ Code = inticks / c_code,
+
+ -- This keeps the parser from getting bogged down on long strings of '*' or '_'
+ UlOrStarLine = asterisk^4
+ + underscore^4
+ + (spaces * S("*_")^1 * #spaces) / c_string,
+
+ Emphasis = V("EmphasisStar")
+ + V("EmphasisUl"),
+
+ EmphasisStar = asterisk * -spaceornewline * Ct((V("Inline") - asterisk )^1) * asterisk / c_emphasis,
+ EmphasisUl = underscore * -spaceornewline * Ct((V("Inline") - underscore)^1) * underscore / c_emphasis,
+
+ Strong = V("StrongStar")
+ + V("StrongUl"),
+
+ StrongStar = doubleasterisks * -spaceornewline * Ct((V("Inline") - doubleasterisks )^1) * doubleasterisks / c_strong,
+ StrongUl = doubleunderscores * -spaceornewline * Ct((V("Inline") - doubleunderscores)^1) * doubleunderscores / c_strong,
+
+ Image = P("!") * (V("ExplicitLink") + V("ReferenceLink")) / c_image,
+
+ Link = V("ExplicitLink") / c_link
+ + V("ReferenceLink") / c_link
+ + V("AutoLinkUrl")
+ + V("AutoLinkEmail"),
+
+ ReferenceLink = V("ReferenceLinkDouble")
+ + V("ReferenceLinkSingle"),
+
+ ReferenceLinkDouble = V("Label") * spnl * Cmt(V("Label"), f_reference_link_double),
+
+ ReferenceLinkSingle = Cmt(V("Label"), f_reference_link_single) * (spnl * P("[]"))^-1,
+
+ AutoLinkUrl = less * C(alphanumeric^1 * P("://") * (any - (newline + more))^1) * more / f_link,
+
+ AutoLinkEmail = less * C((alphanumeric + S("-_+"))^1 * P("@") * (any - (newline + more))^1) * more / c_email_link,
+
+ BasicSource = (nonspacechar - S("()>"))^1 + (lparent * V("Source") * rparent)^1 + always,
+
+ AngleSource = less * C(V("BasicSource")) * more,
+
+ Source = V("AngleSource")
+ + C(V("BasicSource")),
+
+ LinkTitle = dquote * C((any - (dquote * optionalspace * rparent))^0) * dquote +
+ squote * C((any - (squote * optionalspace * rparent))^0) * squote +
+ Cc(""),
+
+ ExplicitLink = V("Label") * spnl * lparent * optionalspace * V("Source") * spnl * V("LinkTitle") * optionalspace * rparent,
+
+ Str = normalchar^1 / c_string,
+ Space = spacechar^1 / c_space,
+ Symbol = specialchar / c_string,
+}
+
+local function convert(str)
+ nofruns = nofruns + 1
+ nofbytes = nofbytes + #str
+ statistics.starttiming(markdown)
+ local result = c_start_document() .. nestedparser(str) .. c_stop_document()
+ statistics.stoptiming(markdown)
+ return result
+end
+
+markdown.convert = convert
+
+function markdown.typesetstring(data)
+ if data and data ~= "" then
+ local result = convert(data)
+ context.viafile(result)
+ end
+end
+
+function markdown.typesetbuffer(name)
+ markdown.typesetstring(buffers.getcontent(name))
+end
+
+function markdown.typesetfile(name)
+ local fullname = findctxfile(name)
+ if fullname and fullname ~= "" then
+ markdown.typesetstring(io.loaddata(fullname))
+ end
+end
+
+statistics.register("markdown",function()
+ if nofruns > 0 then
+ return format("%s bytes converted, %s runs, %s html blobs, %s seconds used",
+ nofbytes, nofruns, nofhtmlblobs, statistics.elapsedtime(markdown))
+ end
+end)
+
+-- test
+
+--~ context.starttext()
+--~ moduledata.markdown.convert(str)
+--~ context.stoptext()
diff --git a/tex/context/base/m-markdown.mkiv b/tex/context/base/m-markdown.mkiv
new file mode 100644
index 000000000..ac862abaa
--- /dev/null
+++ b/tex/context/base/m-markdown.mkiv
@@ -0,0 +1,82 @@
+%D \module
+%D [ file=x-markdown,
+%D version=2011.07.19,
+%D title=\CONTEXT\ Modules,
+%D subtitle=processign MarkDown,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Modules / MarkDown Renderer}
+
+%D This module deals with markdown which is a document encoding that
+%D some \CONTEXT\ like much. It reminds me of the kind of minimal coding
+%D we used before we ran into \TEX\ and were using a somewhat simple
+%D rendering (pagination, etc) of documents. As I'm no user myself, it
+%D is up to others to provide documentation and examples.
+
+\registerctxluafile{m-markdown}{1.001}
+
+\unprotect
+
+% basic interface
+
+\definebuffer[markdown]
+
+\unexpanded\def\stopmarkdown
+ {\ctxlua{moduledata.markdown.typesetbuffer("\thedefinedbuffer{markdown}")}}
+
+\unexpanded\def\processmarkdownfile#1% maybe [] or both
+ {\ctxlua{moduledata.markdown.typesetfile("#1")}}
+
+\unexpanded\def\markdown#1% maybe [] or both
+ {\ctxlua{moduledata.markdown.typesetstring(\!!bs#1\!!es)}}
+
+% commands
+
+\defineitemgroup
+ [markdownitemize]
+
+\definetyping
+ [markdowntyping]
+
+\definetype
+ [markdowntype]
+
+\definedelimitedtext
+ [markdownblockquote]
+ [markdownquotation]
+
+\definehighlight
+ [markdownemphasis]
+ [style=\em]
+
+\definehighlight
+ [markdownstrong]
+ [style=\bf]
+
+\definestructurelevels
+ [markdown]
+ [\v!chapter,
+ \v!section,
+ \v!subsection,
+ \v!subsubsection,
+ \v!subsubsubsection,
+ \v!subsubsubsubsection]
+
+\unexpanded\def\markdownrule
+ {\hairline\par}
+
+\protect
+
+\continueifinputfile{m-markdown.mkiv}
+
+\starttext
+ \startmarkdown
+ % some examples needed
+ \stopmarkdown
+\stoptext
diff --git a/tex/context/base/math-act.lua b/tex/context/base/math-act.lua
index 4016c3172..5b87fe69f 100644
--- a/tex/context/base/math-act.lua
+++ b/tex/context/base/math-act.lua
@@ -76,8 +76,7 @@ sequencers.appendaction(mathactions,"system","mathematics.scaleparameters")
function mathematics.checkaccentbaseheight(target,original)
local mathparameters = target.mathparameters
if mathparameters and mathparameters.AccentBaseHeight == 0 then
- mathparameters.AccentBaseHeight = original.parameters.x_height or 0
---~ mathparameters.AccentBaseHeight = target.parameters.vfactor * mathparameters.AccentBaseHeight
+ mathparameters.AccentBaseHeight = target.parameters.x_height -- needs checking
end
end
@@ -87,10 +86,10 @@ function mathematics.checkprivateparameters(target,original)
local mathparameters = target.mathparameters
if mathparameters then
if not mathparameters.FractionDelimiterSize then
- mathparameters.FractionDelimiterSize = 0
+ mathparameters.FractionDelimiterSize = 1.01 * target.parameters.size
end
if not mathparameters.FractionDelimiterDisplayStyleSize then
- mathparameters.FractionDelimiterDisplayStyleSize = 0
+ mathparameters.FractionDelimiterDisplayStyleSize = 2.40 * target.parameters.size
end
end
end
diff --git a/tex/context/base/math-dim.lua b/tex/context/base/math-dim.lua
index 861e768b7..65b70cf92 100644
--- a/tex/context/base/math-dim.lua
+++ b/tex/context/base/math-dim.lua
@@ -139,8 +139,7 @@ function mathematics.dimensions(dimens) -- beware, dimens get spoiled
dimens["7*default_rule_thickness"] = 7 * default_rule_thickness
dimens["(5/18)*quad"] = (math_quad * 5) / 18
dimens["(-10/18)*quad"] = - (math_quad * 10) / 18
- dimens["math_x_height*2"] = math_x_height * 2 -- needs checking
- dimens["math_x_height*3"] = math_x_height * 3 -- needs checking
+dimens["math_x_height*3"] = math_x_height * 3 -- needs checking
dimens["abs(math_x_height*4)/5"] = abs(math_x_height * 4) / 5
dimens["default_rule_thickness+(abs(default_rule_thickness)/4)"] = default_rule_thickness+(abs(default_rule_thickness) / 4)
dimens["default_rule_thickness+(abs(math_x_height)/4)"] = default_rule_thickness+(abs(math_x_height) / 4)
diff --git a/tex/context/base/meta-imp-dum.mkiv b/tex/context/base/meta-imp-dum.mkiv
index 98538bd87..852ed1ef1 100644
--- a/tex/context/base/meta-imp-dum.mkiv
+++ b/tex/context/base/meta-imp-dum.mkiv
@@ -96,7 +96,11 @@
\let\normalexternalfigurereplacement\externalfigurereplacement
-\def\externalfigurereplacement#1#2#3%
+% \weightGRAYfalse % monochrome anyway
+% \MPcmykcolorsfalse
+% \MPspotcolorsfalse
+
+\unexpanded\def\externalfigurereplacement#1#2#3%
{\getpaletsize[placeholder]%
\ifx\figurereplacementcycle\relax
\getrandomnumber \figurereplacementcycle \!!plusone \paletsize
@@ -107,9 +111,6 @@
\ifnum\figurereplacementcycle>\paletsize
\globallet\figurereplacementcycle\!!plusone
\fi
- \weightGRAYfalse % monochrome anyway
- \MPcmykcolorsfalse
- \MPspotcolorsfalse
\defineoverlay
[\s!dummy]
[\useMPgraphic
@@ -128,20 +129,63 @@
\c!foregroundcolor=\s!white]}%
{\doif\@@eftext\v!yes
{\infofont \setupinterlinespace \dohyphens % \nohyphens
- \doifelse{#1}\s!dummy \!!doneafalse\!!doneatrue
- \doifelse{#2}\s!dummy \!!donebfalse\!!donebtrue
- \doifelse{#3}\s!unknown\!!donecfalse\!!donectrue
- \if!!donea
+ \edef\tempa{#1}\ifx\tempa\s!dummy\let\tempa\empty\fi
+ \edef\tempb{#2}\ifx\tempb\s!dummy\let\tempb\empty\fi
+ \edef\tempc{#3}\ifx\tempc\s!dummy\let\tempc\empty\fi
+ \ifx\tempa\empty\else
name: \expanded{\verbatimstring{#1}}\strut\endgraf
\fi
- \if!!doneb
- \if!!donea file: \else \if!!donec file: \fi \fi
+ \ifx\tempb\empty\else
+ \ifx\tempa\empty\ifx\tempc\empty\else file: \fi\else file: \fi
\expanded{\verbatimstring{#2}}\strut\endgraf
\fi
- \if!!donec
+ \ifx\tempc\empty\else
state: \expanded{\verbatimstring{#3}}\strut\endgraf
\fi}}}
-\def\dummyfigure{\externalfigure[placeholder]}
+\unexpanded\def\dummyfigure
+ {\externalfigure[placeholder]}
+
+%D \starttyping
+%D \externalfigure[mediashow.swf][comment={Alas, we have no nice preview},background=figure:comment]
+%D \externalfigure[mediashow.swf][comment={Alas, we have no nice preview},background=figure:dummy]
+%D \externalfigure[mediashow.swf][background=figure:dummy]
+%D \stoptyping
+
+\defineframed
+ [figurecomment]
+ [\c!background=\v!color,
+ \c!backgroundcolor=\v!gray,
+ \c!frame=\v!off,
+ \c!foregroundstyle=\ttbf,
+ \c!align={\v!middle,\v!lohi},
+ \c!height=\figureheight,
+ \c!width=\figurewidth]
+
+\defineframed
+ [figuredummy]
+ [\c!background=figure:placeholder,
+ \c!foregroundcolor=white,
+ \c!backgroundcolor=\v!gray,
+ \c!frame=\v!off,
+ \c!foregroundstyle=\ttbf,
+ \c!align={\v!middle,\v!lohi},
+ \c!height=\figureheight,
+ \c!width=\figurewidth]
+
+\defineoverlay
+ [figure:placeholder]
+ [\externalfigurereplacement{}{}{}]
+
+\defineoverlay
+ [figure:comment]
+ [\figurecomment{\@@efcomment}]
+
+\defineoverlay
+ [figure:dummy]
+ [\figuredummy{\@@efcomment}]
+
+\setupexternalfigures
+ [comment=]
\protect \endinput
diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf
index 89e7900b7..def98ab1d 100644
--- a/tex/context/base/status-files.pdf
+++ b/tex/context/base/status-files.pdf
Binary files differ
diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf
index ec09248dd..897c36fd7 100644
--- a/tex/context/base/status-lua.pdf
+++ b/tex/context/base/status-lua.pdf
Binary files differ
diff --git a/tex/context/base/strc-lev.lua b/tex/context/base/strc-lev.lua
index 2c4743dc4..b5580940c 100644
--- a/tex/context/base/strc-lev.lua
+++ b/tex/context/base/strc-lev.lua
@@ -36,11 +36,15 @@ end
function sections.stopautolevel()
local category = remove(categories)
- local lc = levels[category]
- if not lc or level > #lc then
- context.nostophead { format("%s:%s",category,level) }
+ if category then
+ local lc = levels[category]
+ if not lc or level > #lc then
+ context.nostophead { format("%s:%s",category,level) }
+ else
+ context.dostophead { lc[level] }
+ end
+ level = level - 1
else
- context.dostophead { lc[level] }
+ -- error
end
- level = level - 1
end
diff --git a/tex/context/base/strc-lev.mkiv b/tex/context/base/strc-lev.mkiv
index 7d0543ecc..e25f549a2 100644
--- a/tex/context/base/strc-lev.mkiv
+++ b/tex/context/base/strc-lev.mkiv
@@ -60,15 +60,15 @@
\protect \endinput
% \starttext
-
+%
% \definehead[xxxxxxsection][subsubsection]
% \setuphead [xxxxxxsection][color=red]
-
+%
% \definestructurelevels[main][chapter,section,subsection,subsubsection]
% \definestructurelevels[next][chapter,section,subsection,xxxxxxsection]
-
+%
% \startstructurelevel [main] [title=first top level]
-
+%
% \startstructurelevel [main] [title=first lower level]
% \startstructurelevel [main] [title=second lower level]
% \startstructurelevel [main] [title=third lower level]
@@ -76,7 +76,7 @@
% \stopstructurelevel
% \stopstructurelevel
% \stopstructurelevel
-
+%
% \startstructurelevel [main] [title=first lower level]
% \startstructurelevel [main] [title=second lower level]
% \startstructurelevel [next] [title=third lower level]
@@ -84,9 +84,8 @@
% \stopstructurelevel
% \stopstructurelevel
% \stopstructurelevel
-
+%
% \stopstructurelevel
-
-
+%
% \stoptext
diff --git a/tex/context/base/strc-lst.mkiv b/tex/context/base/strc-lst.mkiv
index c532f0ae7..bf97333b4 100644
--- a/tex/context/base/strc-lst.mkiv
+++ b/tex/context/base/strc-lst.mkiv
@@ -797,18 +797,24 @@
\fi
\parindent\zeropoint\relax
\leavevmode
+% % topaligned
+%
+% \dontleavehmode
+% \scratchdimen\wd2
+% \setbox2\hbox to \hsize{\box2\hss\box4}%
+% \wd2\scratchdimen
+%
\box2\relax
\hskip\dimen2
-\domakelistelement\v!text{#2}\firstofoneargument{%
- \bgroup
- \donestedlistattributes\c!textstyle\c!textcolor
- {\let\\=\newlineinlist
- \dontconvertfont
- %\listparameter\c!textcommand{#4}}%
- \limitatedlistentry{#4}}%
- %\carryoverpar % new otherwise wrong linespacing
- \egroup
-}%
+ \domakelistelement\v!text{#2}\firstofoneargument
+ {\bgroup
+ \donestedlistattributes\c!textstyle\c!textcolor
+ {\let\\=\newlineinlist
+ \dontconvertfont
+ %\listparameter\c!textcommand{#4}}%
+ \limitatedlistentry{#4}}%
+ %\carryoverpar % new otherwise wrong linespacing
+ \egroup}%
\ifdim\wd4=\zeropoint\relax % \ifvoid4
% \ifdim\!!widtha<\hsize \hfill\strut \fi % spoils align
\else
diff --git a/tex/context/base/symb-mvs.mkii b/tex/context/base/symb-mvs.mkii
index 5f4b724aa..aae4e92d6 100644
--- a/tex/context/base/symb-mvs.mkii
+++ b/tex/context/base/symb-mvs.mkii
@@ -43,7 +43,7 @@
\loadmapfile[original-base.map] % \loadmapfile[original-vogel-symbol]
-\definefontsynonym [MartinVogel] [fmvr8x]
+\definefontsynonym [MartinVogel] [umvs]
\def\MartinVogelSymbol#1{\getglyph{MartinVogel}{\char#1}}
diff --git a/tex/context/base/type-one.mkii b/tex/context/base/type-one.mkii
index dfdbd2c17..b8a582d83 100644
--- a/tex/context/base/type-one.mkii
+++ b/tex/context/base/type-one.mkii
@@ -1912,7 +1912,7 @@
\starttypescript
\definefontsynonym [ZapfDingbats] [uzdr]
\definefontsynonym [RalfSmithFormalScript] [rsfs10]
- \definefontsynonym [MartinVogel] [fmvr8x]
+ \definefontsynonym [MartinVogel] [umvs]
\stoptypescript
\stoptypescriptcollection
diff --git a/tex/context/base/type-otf.mkii b/tex/context/base/type-otf.mkii
index 3bc082695..d15994f6a 100644
--- a/tex/context/base/type-otf.mkii
+++ b/tex/context/base/type-otf.mkii
@@ -1698,7 +1698,7 @@
\starttypescript
\definefontsynonym [ZapfDingbats] [uzdr]
\definefontsynonym [RalfSmithFormalScript] [rsfs10]
- \definefontsynonym [MartinVogel] [fmvr8x]
+ \definefontsynonym [MartinVogel] [umvs]
\stoptypescript
\stoptypescriptcollection
diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua
index 046532dd8..5d19f5649 100644
--- a/tex/generic/context/luatex/luatex-fonts-merged.lua
+++ b/tex/generic/context/luatex/luatex-fonts-merged.lua
@@ -1,6 +1,6 @@
-- merged file : luatex-fonts-merged.lua
-- parent file : luatex-fonts.lua
--- merge date : 07/19/11 11:22:19
+-- merge date : 07/20/11 14:10:55
do -- begin closure to overcome local limits and interference
@@ -3482,10 +3482,10 @@ function constructors.scale(tfmdata,specification)
targetparameters.descender = delta * descender
end
-- copies, might disappear
- targetparameters.xheight = targetparameters.xheight or parameters.x_height
- targetparameters.extraspace = targetparameters.extraspace or parameters.extra_space
- targetparameters.spacestretch = targetparameters.spacestretch or parameters.space_stretch
- targetparameters.spaceshrink = targetparameters.spaceshrink or parameters.space_shrink
+ targetparameters.xheight = targetparameters.xheight or targetparameters.x_height or parameters.x_height
+ targetparameters.extraspace = targetparameters.extraspace or targetparameters.extra_space or parameters.extra_space
+ targetparameters.spacestretch = targetparameters.spacestretch or targetparameters.space_stretch or parameters.space_stretch
+ targetparameters.spaceshrink = targetparameters.spaceshrink or targetparameters.space_shrink or parameters.space_shrink
--
local protrusionfactor = (targetquad ~= 0 and 1000/targetquad) or 0
local scaledwidth = defaultwidth * hdelta