diff --git a/luamml-amsmath.lua b/luamml-amsmath.lua index 26b157b..48732f3 100644 --- a/luamml-amsmath.lua +++ b/luamml-amsmath.lua @@ -44,6 +44,48 @@ lua.get_functions_table()[funcid] = function() set_row_attribute('columnalign', token.scan_argument()) end +-- This function is used to add a intent :continued-row to +-- rows of a split environment. +-- we assume that the table is a mtable with mrow with mtd. +-- we check row 2..n. If the first cell has only one element and +-- for this element 'tex:ignore' has been set, we assume a continued row and +-- set the intent on the mrow. +local function add_intent_continued_row (table) + for index,rowtable in ipairs(table) do + if table[index][1] and table[index][1][1] then -- just for safety ... + if index > 1 and #table[index][1]==1 and table[index][1][1]['tex:ignore'] then + table[index]['intent']=':continued-row' + end + end + end +end + +-- This function add an intent =":pause-medium" on every second mtd in a table +-- currently it is also on the first (after the label) but this could be changed +-- used in __luamml_amsmath_finalize_table:n for +-- 'align' or 'alignat' or 'flalign' or 'xalignat' or 'xxalignat' +local function add_intent_pause (mmltable) + for mtrindex,mtrtable in ipairs(mmltable) do + for mtdindex,mtdtable in ipairs(mtrtable) do + if (mtdindex % 2 == 0) then + mtdtable['intent']=':pause-medium' + end + end + end +end + + +-- debug function for tables +-- activate with \directlua{debugmtable=2} or \directlua{debugmtable='split'} +local function debug_mtable (mtable,kind) + if debugmtable and (debugmtable==2) or (debugmtable==kind) then + texio.write_nl('==============') + texio.write_nl(kind) + texio.write_nl(table.serialize(mtable)) + texio.write_nl('==============') + end +end + do local saved funcid = luatexbase.new_luafunction'__luamml_amsmath_save_inner_table:n' @@ -51,9 +93,14 @@ do lua.get_functions_table()[funcid] = function() -- TODO: Error handling etc local kind = token.scan_argument() + kind = kind:gsub("*","") local mml_table = get_table() if not mml_table then return end mml_table.displaystyle = true + mml_table.class=kind + if kind=="split" then + add_intent_continued_row (mml_table) + end local columns = node.count(node.id'align_record', tex.lists.align_head)//2 mml_table.columnalign = kind == 'gathered' and 'center' or string.rep('right left', columns, ' ') local spacing = {} @@ -61,6 +108,7 @@ do spacing[#spacing+1] = n.width == 0 and '0' or string.format('%.3fpt', n.width/65781.76) end mml_table.columnspacing = #spacing > 3 and table.concat(spacing, ' ', 2, #spacing-2) or nil + debug_mtable(mml_table,kind) saved = mml_table end @@ -70,10 +118,12 @@ do -- TODO: Error handling etc local mml_table = get_table() mml_table.align = 'axis' + mml_table.class='smallmatrix' mml_table.columnalign = 'center' mml_table.columnspacing = '0.278em' mml_table.rowspacing = string.format('%.3fpt', tex.lineskip.width/65781.76) saved = {[0] = 'mpadded', width = '+0.333em', lspace = '0.167em', mml_table} + debug_mtable(mml_table,kind) saved = mml_table end @@ -97,18 +147,26 @@ token.set_lua('__luamml_amsmath_finalize_table:n', funcid) lua.get_functions_table()[funcid] = function() -- TODO: Error handling etc local kind = token.scan_argument() + kind = kind:gsub("*","") local mml_table = get_table() if not mml_table then return end mml_table.displaystyle = true + mml_table.class=kind + -- this should perhaps be configurable and extendable + if kind == 'align' or 'alignat' or 'flalign' or 'xalignat' or 'xxalignat' then + mml_table.intent=":system-of-equations" + add_intent_pause (mml_table) + end local columns = node.count(node.id'align_record', tex.lists.align_head)//2 - mml_table.columnalign = kind == 'align' and string.rep('right left', columns, ' ') or nil + mml_table.columnalign = kind == 'align' and 'left '..string.rep('right left', columns, ' ') or nil mml_table.width = kind == 'multline' and '100%' or nil -- mml_table.side = kind == 'multline' and 'rightoverlap' or nil local spacing = {} for n in node.traverse_id(node.id'glue', tex.lists.align_head) do spacing[#spacing+1] = n.width == 0 and '0' or '.8em' end - mml_table.columnspacing = #spacing > 3 and table.concat(spacing, ' ', 2, #spacing-2) or nil + mml_table.columnspacing = #spacing > 3 and "0 "..table.concat(spacing, ' ', 2, #spacing-2) or nil + debug_mtable(mml_table,kind) save_result(mml_table, true) end diff --git a/luamml-patches-amsmath.sty b/luamml-patches-amsmath.sty index ad2f468..8aeba03 100644 --- a/luamml-patches-amsmath.sty +++ b/luamml-patches-amsmath.sty @@ -7,6 +7,25 @@ % But they are almost identical to the original and only % add luamml commands in appropriate places, so they would % mostly disappear if there were enough hooks in amsmath. +\IfPackageAtLeastTF{latex-lab-testphase-math}{2025-02-24} + {} + { + \def\common@align@ending { + \math@cr \black@\totwidth@ + \UseExpandableTaggingSocket {math/luamml/mtable/finalize} {\@currenvir} + \egroup + \ifingather@ + \restorealignstate@ + \egroup + \nonumber + \ifnum0=`{\fi\iffalse}\fi + \else + $$% + \fi + \ignorespacesafterend + } + } + \IfPackageAtLeastTF{latex-lab-testphase-math}{2025-01-24} {} { diff --git a/testfiles-lua/test_struct.tpf b/testfiles-lua/test_struct.tpf index 034a986..21ec100 100644 --- a/testfiles-lua/test_struct.tpf +++ b/testfiles-lua/test_struct.tpf @@ -28,9 +28,9 @@ endobj << /Type /Filespec /AFRelationship /Supplement /Desc (mathml-3) /F (mathml-3.xml) /UF /EF<> >> endobj 28 0 obj -<< /Type /EmbeddedFile /Subtype /application#2Fmathml+xml /Params<> /Length 1014 >> +<< /Type /EmbeddedFile /Subtype /application#2Fmathml+xml /Params<> /Length 1203 >> stream - 𝑎 𝑏 𝑐 = 𝑑 𝑒 𝑓 𝑒 i 𝜋 = 1 ( 1 + 2 = 3 ) 5 + 𝑎 𝑏 𝑐 = 𝑑 𝑒 𝑓 𝑒 i 𝜋 = 1 ( 1 + 2 = 3 ) 5 endstream endobj 29 0 obj @@ -124,7 +124,7 @@ endobj << /O/NSO/NS 13 0 R/fence(true)/lspace(0)/maxsize(17.861pt)/minsize(17.861pt)/rspace(0)/symmetric(true) >> endobj 189 0 obj -<< /O/NSO/NS 13 0 R/columnalign(right left right left)/columnspacing(0 .8em 0)/displaystyle(true) >> +<< /O/NSO/NS 13 0 R/class(align)/columnalign(left right left right left)/columnspacing(0 0 .8em 0)/displaystyle(true)/intent(:system-of-equations) >> endobj 196 0 obj << /Subtype /application#2Fx-tex/Type /EmbeddedFile /Params<> /Length 27 >> @@ -1798,27 +1798,27 @@ endobj xref 0 254 0000000002 65535 f -0000028070 00000 n +0000028308 00000 n 0000000003 00000 f 0000000004 00000 f 0000000010 00000 f -0000053863 00000 n -0000028275 00000 n -0000032099 00000 n -0000034284 00000 n -0000032919 00000 n +0000054101 00000 n +0000028513 00000 n +0000032337 00000 n +0000034522 00000 n +0000033157 00000 n 0000000012 00000 f -0000032987 00000 n +0000033225 00000 n 0000000014 00000 f -0000033057 00000 n +0000033295 00000 n 0000000020 00000 f -0000033820 00000 n -0000033138 00000 n -0000034093 00000 n -0000033922 00000 n -0000034195 00000 n +0000034058 00000 n +0000033376 00000 n +0000034331 00000 n +0000034160 00000 n +0000034433 00000 n 0000000000 00000 f -0000034345 00000 n +0000034583 00000 n 0000000020 00000 n 0000000299 00000 n 0000000486 00000 n @@ -1826,233 +1826,233 @@ xref 0000001318 00000 n 0000001800 00000 n 0000001987 00000 n -0000003150 00000 n -0000003337 00000 n -0000004016 00000 n -0000034484 00000 n -0000034573 00000 n -0000034662 00000 n -0000034763 00000 n +0000003339 00000 n +0000003526 00000 n +0000004205 00000 n +0000034722 00000 n +0000034811 00000 n 0000034900 00000 n 0000035001 00000 n -0000004203 00000 n -0000004518 00000 n -0000035287 00000 n -0000035382 00000 n -0000035505 00000 n -0000035600 00000 n -0000035723 00000 n -0000035818 00000 n -0000035941 00000 n -0000036036 00000 n -0000036159 00000 n -0000036254 00000 n -0000036377 00000 n -0000036472 00000 n -0000036595 00000 n -0000036690 00000 n -0000036814 00000 n -0000036909 00000 n -0000037033 00000 n -0000037128 00000 n -0000037252 00000 n -0000037347 00000 n -0000037471 00000 n -0000037607 00000 n -0000037719 00000 n -0000037843 00000 n -0000004718 00000 n -0000037978 00000 n -0000038102 00000 n -0000038197 00000 n -0000038292 00000 n -0000038416 00000 n -0000038543 00000 n -0000038638 00000 n -0000004789 00000 n -0000038761 00000 n -0000038887 00000 n -0000004843 00000 n -0000039021 00000 n -0000004930 00000 n -0000039120 00000 n -0000004985 00000 n -0000039230 00000 n -0000039344 00000 n -0000039455 00000 n -0000039566 00000 n -0000039677 00000 n -0000039776 00000 n -0000039911 00000 n -0000040046 00000 n -0000040158 00000 n -0000040293 00000 n -0000040403 00000 n -0000040510 00000 n -0000040614 00000 n -0000040718 00000 n -0000005057 00000 n -0000040817 00000 n -0000040918 00000 n -0000005111 00000 n -0000005327 00000 n -0000041170 00000 n -0000041304 00000 n -0000041429 00000 n -0000041565 00000 n -0000041674 00000 n -0000041799 00000 n -0000005527 00000 n -0000041937 00000 n -0000042063 00000 n -0000005593 00000 n -0000042201 00000 n +0000035138 00000 n +0000035239 00000 n +0000004392 00000 n +0000004707 00000 n +0000035525 00000 n +0000035620 00000 n +0000035743 00000 n +0000035838 00000 n +0000035961 00000 n +0000036056 00000 n +0000036179 00000 n +0000036274 00000 n +0000036397 00000 n +0000036492 00000 n +0000036615 00000 n +0000036710 00000 n +0000036833 00000 n +0000036928 00000 n +0000037052 00000 n +0000037147 00000 n +0000037271 00000 n +0000037366 00000 n +0000037490 00000 n +0000037585 00000 n +0000037709 00000 n +0000037845 00000 n +0000037957 00000 n +0000038081 00000 n +0000004907 00000 n +0000038216 00000 n +0000038340 00000 n +0000038435 00000 n +0000038530 00000 n +0000038654 00000 n +0000038781 00000 n +0000038876 00000 n +0000004978 00000 n +0000038999 00000 n +0000039125 00000 n +0000005032 00000 n +0000039259 00000 n +0000005119 00000 n +0000039358 00000 n +0000005174 00000 n +0000039468 00000 n +0000039582 00000 n +0000039693 00000 n +0000039804 00000 n +0000039915 00000 n +0000040014 00000 n +0000040149 00000 n +0000040284 00000 n +0000040396 00000 n +0000040531 00000 n +0000040641 00000 n +0000040748 00000 n +0000040852 00000 n +0000040956 00000 n +0000005246 00000 n +0000041055 00000 n +0000041156 00000 n +0000005300 00000 n +0000005516 00000 n +0000041408 00000 n +0000041542 00000 n +0000041667 00000 n +0000041803 00000 n +0000041912 00000 n +0000042037 00000 n +0000005716 00000 n +0000042175 00000 n 0000042301 00000 n -0000042434 00000 n -0000042543 00000 n -0000042669 00000 n -0000042795 00000 n -0000042933 00000 n -0000043059 00000 n -0000043185 00000 n -0000043311 00000 n -0000043420 00000 n -0000043546 00000 n -0000043672 00000 n -0000005665 00000 n -0000043809 00000 n -0000043912 00000 n -0000005725 00000 n -0000005930 00000 n -0000044132 00000 n -0000044268 00000 n -0000044379 00000 n -0000006133 00000 n -0000044517 00000 n -0000044643 00000 n -0000044754 00000 n -0000044880 00000 n -0000044966 00000 n -0000045076 00000 n -0000045202 00000 n -0000006219 00000 n -0000045340 00000 n -0000045449 00000 n -0000045575 00000 n -0000006274 00000 n -0000045713 00000 n -0000045816 00000 n -0000006334 00000 n -0000006563 00000 n -0000046119 00000 n -0000046235 00000 n -0000046361 00000 n -0000046487 00000 n -0000046613 00000 n -0000046737 00000 n -0000046874 00000 n -0000047000 00000 n -0000047126 00000 n -0000047252 00000 n -0000047350 00000 n -0000047459 00000 n -0000047585 00000 n -0000047694 00000 n -0000047832 00000 n -0000047958 00000 n -0000048074 00000 n -0000006766 00000 n -0000048212 00000 n -0000048350 00000 n -0000048476 00000 n -0000048603 00000 n -0000048727 00000 n -0000006832 00000 n -0000048865 00000 n -0000048991 00000 n -0000049129 00000 n -0000049255 00000 n -0000049371 00000 n -0000049508 00000 n -0000049634 00000 n -0000049772 00000 n -0000049859 00000 n -0000049946 00000 n -0000050073 00000 n -0000050171 00000 n -0000050297 00000 n -0000050384 00000 n -0000050471 00000 n -0000050558 00000 n -0000050685 00000 n -0000050795 00000 n -0000006956 00000 n -0000050926 00000 n -0000051050 00000 n -0000051174 00000 n -0000051298 00000 n -0000051401 00000 n -0000051588 00000 n -0000007074 00000 n -0000007245 00000 n -0000051787 00000 n -0000051992 00000 n -0000052130 00000 n -0000007448 00000 n -0000052268 00000 n -0000052394 00000 n -0000052532 00000 n -0000052670 00000 n -0000052808 00000 n -0000052946 00000 n -0000053072 00000 n -0000053210 00000 n -0000053336 00000 n -0000053462 00000 n -0000053600 00000 n -0000053737 00000 n -0000007524 00000 n -0000027966 00000 n -0000027827 00000 n -0000019308 00000 n -0000068957 00000 n -0000064688 00000 n -0000058364 00000 n -0000055682 00000 n -0000069317 00000 n -0000028117 00000 n -0000028154 00000 n -0000029021 00000 n -0000029933 00000 n -0000030886 00000 n -0000031848 00000 n -0000032036 00000 n -0000032678 00000 n -0000054002 00000 n -0000054711 00000 n -0000054034 00000 n -0000054934 00000 n -0000055838 00000 n -0000056040 00000 n -0000057300 00000 n -0000056113 00000 n -0000057531 00000 n -0000058527 00000 n -0000058736 00000 n -0000063194 00000 n -0000059021 00000 n -0000063424 00000 n -0000064851 00000 n -0000065060 00000 n -0000067742 00000 n -0000065246 00000 n -0000067965 00000 n -0000069114 00000 n -0000069381 00000 n -0000069427 00000 n -0000069561 00000 n +0000005782 00000 n +0000042439 00000 n +0000042539 00000 n +0000042672 00000 n +0000042781 00000 n +0000042907 00000 n +0000043033 00000 n +0000043171 00000 n +0000043297 00000 n +0000043423 00000 n +0000043549 00000 n +0000043658 00000 n +0000043784 00000 n +0000043910 00000 n +0000005854 00000 n +0000044047 00000 n +0000044150 00000 n +0000005914 00000 n +0000006119 00000 n +0000044370 00000 n +0000044506 00000 n +0000044617 00000 n +0000006322 00000 n +0000044755 00000 n +0000044881 00000 n +0000044992 00000 n +0000045118 00000 n +0000045204 00000 n +0000045314 00000 n +0000045440 00000 n +0000006408 00000 n +0000045578 00000 n +0000045687 00000 n +0000045813 00000 n +0000006463 00000 n +0000045951 00000 n +0000046054 00000 n +0000006523 00000 n +0000006752 00000 n +0000046357 00000 n +0000046473 00000 n +0000046599 00000 n +0000046725 00000 n +0000046851 00000 n +0000046975 00000 n +0000047112 00000 n +0000047238 00000 n +0000047364 00000 n +0000047490 00000 n +0000047588 00000 n +0000047697 00000 n +0000047823 00000 n +0000047932 00000 n +0000048070 00000 n +0000048196 00000 n +0000048312 00000 n +0000006955 00000 n +0000048450 00000 n +0000048588 00000 n +0000048714 00000 n +0000048841 00000 n +0000048965 00000 n +0000007021 00000 n +0000049103 00000 n +0000049229 00000 n +0000049367 00000 n +0000049493 00000 n +0000049609 00000 n +0000049746 00000 n +0000049872 00000 n +0000050010 00000 n +0000050097 00000 n +0000050184 00000 n +0000050311 00000 n +0000050409 00000 n +0000050535 00000 n +0000050622 00000 n +0000050709 00000 n +0000050796 00000 n +0000050923 00000 n +0000051033 00000 n +0000007145 00000 n +0000051164 00000 n +0000051288 00000 n +0000051412 00000 n +0000051536 00000 n +0000051639 00000 n +0000051826 00000 n +0000007312 00000 n +0000007483 00000 n +0000052025 00000 n +0000052230 00000 n +0000052368 00000 n +0000007686 00000 n +0000052506 00000 n +0000052632 00000 n +0000052770 00000 n +0000052908 00000 n +0000053046 00000 n +0000053184 00000 n +0000053310 00000 n +0000053448 00000 n +0000053574 00000 n +0000053700 00000 n +0000053838 00000 n +0000053975 00000 n +0000007762 00000 n +0000028204 00000 n +0000028065 00000 n +0000019546 00000 n +0000069195 00000 n +0000064926 00000 n +0000058602 00000 n +0000055920 00000 n +0000069555 00000 n +0000028355 00000 n +0000028392 00000 n +0000029259 00000 n +0000030171 00000 n +0000031124 00000 n +0000032086 00000 n +0000032274 00000 n +0000032916 00000 n +0000054240 00000 n +0000054949 00000 n +0000054272 00000 n +0000055172 00000 n +0000056076 00000 n +0000056278 00000 n +0000057538 00000 n +0000056351 00000 n +0000057769 00000 n +0000058765 00000 n +0000058974 00000 n +0000063432 00000 n +0000059259 00000 n +0000063662 00000 n +0000065089 00000 n +0000065298 00000 n +0000067980 00000 n +0000065484 00000 n +0000068203 00000 n +0000069352 00000 n +0000069619 00000 n +0000069665 00000 n +0000069799 00000 n trailer << /Size 254 /Root 252 0 R /Info 253 0 R /ID [ <2350CAD05F8A7AF0AA4058486855344F> <2350CAD05F8A7AF0AA4058486855344F> ] >> startxref -69694 +69932 %%EOF diff --git a/testfiles-lua/test_xml.mlr b/testfiles-lua/test_xml.mlr index 703a9a0..e1aa986 100644 --- a/testfiles-lua/test_xml.mlr +++ b/testfiles-lua/test_xml.mlr @@ -125,14 +125,14 @@ - + 𝑎 𝑏 𝑐 - + = 𝑑 𝑒 @@ -147,7 +147,7 @@ - + = 1 @@ -160,21 +160,21 @@ + 2 - + = 3 ) - + 5 + - - +