Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

This code writes the subtype of disc nodes to the log file.

\documentclass{minimal}
\usepackage{fontspec}
\directlua{
show_hyph = function(head)
  while head do
    if head.id == 0 or head.id == 1 then % hlist, vlist
      show_hyph(head.head)
    elseif head.id == 7 then             % disc
      texio.write_nl("Subtype " .. head.subtype)
    end
  head = head.next
  end
  return true
end
luatexbase.add_to_callback("post_linebreak_filter",show_hyph,"show_hyph")

}

\begin{document}
\begin{minipage}{1pt}
  discretionary
\end{minipage}
\end{document}

The LuaTeX reference manual says in section 8.1.2.7 “disc nodes”

pre <node> pointer to the pre-break text

How do I access this?

share|improve this question
add comment

1 Answer

up vote 7 down vote accepted

How do I access this?

This is very simple and straightforward: use head.pre to access the list pointing to the pre part of the discretionary.

Now the question you might ask next is "why is the pre-part nil?" This is because you call your function show_hyph() on the post_linebreak_filter. At that point the pre part is already inserted before that disc node and thus the pre part is empty. The same is with post and replace. What I can't tell you is why the disc node stays in the node list.

share|improve this answer
    
OK. I was hoping to use this to review the hyphenations, but it seems it is not that simple. –  Håkon Malmedal Jun 19 '12 at 17:57
    
@HåkonMalmedal Just ask another question on "how to review ... " and I'll think of a solution :) –  topskip Jun 19 '12 at 18:03
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.