[NTG-context] post_linebreak_filter in context

Patrick Gundlach patrick at gundla.ch
Fri Feb 25 12:28:58 CET 2011


Hi,

how do I install a custom post_linebreak_filter in ConTeXt? I have this LaTeX file:

------------------------------------------------------------------------------------
\documentclass[12pt,a4paper]{scrartcl}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{fontspec}
\directlua{
show_hyph = function(head)
  while head do
    if head.id == 0 or head.id == 1 then % hlist, vlist
      show_hyph(head.list) % should be head.head in a newer luatex than 0.64
    elseif head.id == 7 then             % disc
      local n = node.new("whatsit","pdf_literal")
      n.mode = 0
      n.data = "q 0.3 w 0 2 m 0 7 l S Q"
      n.next = head.next
      n.prev = head
      head.next = n
      head = n
    end
  head = head.next
  end
  return true
end
luatexbase.add_to_callback("post_linebreak_filter",show_hyph,"show_hyph")

}

\begin{document}
\begin{minipage}{5cm}
\blindtext
\end{minipage}
\end{document}
------------------------------------------------------------------------------------

which registers a function "show_hyph" as the post_linebreak_filter (the rest is not really interesting). How would I do this in ConTeXt?

(also asked on tex.se: http://tex.stackexchange.com/questions/11960/how-to-register-a-callback-in-context)

Thanks

Patrick



More information about the ntg-context mailing list