Skip to content

Commit

Permalink
Merge pull request #26 from lemzwerg/direction
Browse files Browse the repository at this point in the history
Show direction for 'dir' nodes
  • Loading branch information
Josef-Friedrich committed Jul 26, 2023
2 parents 735d132 + bdc5d95 commit 9075c40
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 13 deletions.
3 changes: 1 addition & 2 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1349,7 +1349,6 @@ <h3>Returns:</h3>
<ul>
<li><code>ins</code> (3)</li>
<li><code>local_par</code> (9)</li>
<li><code>dir</code> (10)</li>
<li><code>penalty</code> (14)</li>
<li><code>unset</code> (15)</li>
<li><code>style</code> (16)</li>
Expand Down Expand Up @@ -2408,7 +2407,7 @@ <h3>Returns:</h3>
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/lunarmodules/LDoc">LDoc 1.5.0</a></i>
<i style="float:right;">Last updated 2023-07-25 13:00:13 </i>
<i style="float:right;">Last updated 2023-07-26 07:26:27 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
Expand Down
14 changes: 14 additions & 0 deletions nodetree-doc.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1167,13 +1167,27 @@ \subsection{Node types}
Office
\end{NodetreeEmbedEnv}

%%
%
%%

\TmpNodeTypeSub{whatsit}{8}{pdfaction}{22}
\TmpNodeTypeSub{whatsit}{8}{pdfcolorstack}{28}

%%
%
%%

\TmpHeadingNodeType{dir}{10}

\begin{NodetreeEmbedEnv}[showmarkup=true,verbosity=0]
\textdir TRT nur {\textdir TLT run \textdir TRT NUR} nur
\end{NodetreeEmbedEnv}

%%
%
%%

\TmpHeadingNodeTypeSub{glue}{12}{baselineskip}{2}

\NodetreeReset
Expand Down
36 changes: 25 additions & 11 deletions nodetree.lua
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ local template = {
field_abbrevs = {
char = {''},
depth = {'dp'},
dir = {'', 'dir'},
dir = {'()', 'dir'},
height = {'ht'},
kern = {''},
mark = {''},
Expand Down Expand Up @@ -436,7 +436,7 @@ local template = {
elseif character_index < 0x110000 then
textual = utfchar(character_index)
else
textual = string.format("^^^^^^%06X", character_index)
textual = string.format('^^^^^^%06X', character_index)
end
return character_index .. ' (' .. string.format('0x%x', character_index) .. ', \''.. textual .. '\')'
end,
Expand Down Expand Up @@ -773,7 +773,6 @@ end
--
-- * `ins` (3)
-- * `local_par` (9)
-- * `dir` (10)
-- * `penalty` (14)
-- * `unset` (15)
-- * `style` (16)
Expand Down Expand Up @@ -808,7 +807,7 @@ end
--
---@return table
local function get_node_subtypes()
local subtypes = {
local subtypes = {
-- hlist (0)
hlist = {
[0] = 'unknown',
Expand Down Expand Up @@ -878,14 +877,21 @@ local function get_node_subtypes()
[3] = 'word',
},
-- disc (7)
disc = {
disc = {
[0] = 'discretionary',
[1] = 'explicit',
[2] = 'automatic',
[3] = 'regular',
[4] = 'first',
[5] = 'second',
},
-- dir (10)
-- This is an internal detail, see luatex source code file
-- `texnodes.h`.
-- dir = {
-- [0] = 'normal_dir',
-- [1] = 'cancel_dir',
-- },
-- math (11)
math = {
[0] = 'beginmath',
Expand Down Expand Up @@ -1049,15 +1055,22 @@ local tree = {}
---@return string
function tree.format_field(head, field)
local output
local typ = node.type(head.id)

-- Print subtypes with ID 0.
if head[field] ~= nil and field == "subtype" then
return template.key_value(field, format.underscore(node_extended.subtype(head)))
-- Print subtypes also for nodes with ID=0. However, suppress the
-- internal 'subtype' field for 'dir' nodes.
if field == 'subtype' then
if typ == 'dir' then
return ''
elseif head[field] ~= nil then
return template.key_value(field,
format.underscore(node_extended.subtype(head)))
end
end

-- Character 0 should be printed in a tree because the corresponding slot
-- zero in a TeX font usually contains a symbol.
if head[field] == nil or (head[field] == 0 and field ~= "char") then
if head[field] == nil or (head[field] == 0 and field ~= 'char') then
return ''
end

Expand All @@ -1068,7 +1081,8 @@ function tree.format_field(head, field)
field == 'right' or
field == 'uchyph' or
-- hlist
field == 'dir' or
-- Don't drop the 'dir' field of the 'dir' node.
(field == 'dir' and typ ~= 'dir') or
field == 'glue_order' or
field == 'glue_sign' or
field == 'glue_set' or
Expand Down Expand Up @@ -1752,7 +1766,7 @@ local export = {
-- Compile the temporary LuaTeX or LuaLaTeX file.
os.spawn({ 'latexmk', '-cd', '-pdflua', absolute_path_tex })
local include_file = assert(io.open(parent_path .. '/' .. example_counter .. '.nttex', 'r'))
local include_content = include_file:read("*all")
local include_content = include_file:read('*all')
include_file:close()
-- To make the newline character be handled properly by the TeX engine
-- it would be necessary to set up its correct catcode. However, it is
Expand Down

0 comments on commit 9075c40

Please sign in to comment.