Skip to content

Commit 1b50d4f

Browse files
committed
engine_xetex: plumb in specials used by spx2html
1 parent e84d828 commit 1b50d4f

4 files changed

Lines changed: 82 additions & 7 deletions

File tree

crates/engine_xetex/xetex/xetex-math.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,11 @@ void init_math(void)
323323
eq_word_define(INT_BASE + INT_PAR__pre_display_direction, x);
324324
eq_word_define(DIMEN_BASE + DIMEN_PAR__display_width, l);
325325
eq_word_define(DIMEN_BASE + DIMEN_PAR__display_indent, s);
326+
327+
/* Tectonic customization: flag canvas start */
328+
if (semantic_pagination_enabled)
329+
tt_insert_special("tdux:cs dmath");
330+
326331
if (LOCAL(every_display) != TEX_NULL)
327332
begin_token_list(LOCAL(every_display), EVERY_DISPLAY_TEXT);
328333
if (nest_ptr == 1)
@@ -335,6 +340,11 @@ void init_math(void)
335340
eq_word_define(INT_BASE + INT_PAR__cur_fam, -1);
336341
if ((insert_src_special_every_math))
337342
insert_src_special();
343+
344+
/* Tectonic customization: flag canvas start */
345+
if (semantic_pagination_enabled)
346+
tt_insert_special("tdux:cs math");
347+
338348
if (LOCAL(every_math) != TEX_NULL)
339349
begin_token_list(LOCAL(every_math), EVERY_MATH_TEXT);
340350
}
@@ -1037,6 +1047,11 @@ void after_math(void)
10371047
cur_list.tail = LLIST_link(cur_list.tail);
10381048
}
10391049
cur_list.aux.b32.s0 = 1000;
1050+
1051+
/* Tectonic customization: flag canvas end */
1052+
if (semantic_pagination_enabled)
1053+
tt_insert_special("tdux:ce math");
1054+
10401055
unsave();
10411056
} else {
10421057

@@ -1170,6 +1185,11 @@ void after_math(void)
11701185
cur_list.tail = LLIST_link(cur_list.tail);
11711186
}
11721187
flush_node_list(j);
1188+
1189+
/* Tectonic customization: flag canvas end */
1190+
if (semantic_pagination_enabled)
1191+
tt_insert_special("tdux:ce dmath");
1192+
11731193
resume_after_display();
11741194
}
11751195
}

crates/engine_xetex/xetex/xetex-pagebuilder.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,7 @@ fire_up(int32_t c)
347347
TOKEN_LIST_ref_count(cur_mark[TOP_MARK_CODE])++;
348348
}
349349

350-
/* Tectonic: in semantic pagination mode, ignore the output routine. */
351-
352-
if (LOCAL(output_routine) != TEX_NULL && !semantic_pagination_enabled) {
350+
if (LOCAL(output_routine) != TEX_NULL) {
353351
if (dead_cycles >= INTPAR(max_dead_cycles)) {
354352
/*1059: "Explain that too many dead cycles have happened in a row." */
355353
error_here_with_diagnostic("Output loop---");

crates/engine_xetex/xetex/xetex-xetex0.c

Lines changed: 59 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9108,6 +9108,9 @@ void pseudo_start(void)
91089108
}
91099109
}
91109110

9111+
/* "The token list created by str toks begins at `LLIST_link(TEMP_HEAD)` and
9112+
* ends at the value `p` that is returned. (If `p = temp head`, the list is
9113+
* empty.)" */
91119114
int32_t
91129115
str_toks_cat(pool_pointer b, small_number cat)
91139116
{
@@ -14670,37 +14673,48 @@ small_number norm_min(int32_t h)
1467014673
return h;
1467114674
}
1467214675

14673-
void new_graf(bool indented)
14676+
14677+
void
14678+
new_graf(bool indented)
1467414679
{
1467514680
cur_list.prev_graf = 0;
1467614681

14677-
if ((cur_list.mode == VMODE) || (cur_list.head != cur_list.tail)) {
14682+
if (cur_list.mode == VMODE || cur_list.head != cur_list.tail) {
1467814683
mem[cur_list.tail].b32.s1 = new_param_glue(GLUE_PAR__par_skip);
1467914684
cur_list.tail = LLIST_link(cur_list.tail);
1468014685
}
1468114686

1468214687
push_nest();
1468314688
cur_list.mode = HMODE;
1468414689
cur_list.aux.b32.s0 = 1000;
14690+
1468514691
if (INTPAR(language) <= 0)
1468614692
cur_lang = 0;
1468714693
else if (INTPAR(language) > BIGGEST_LANG)
1468814694
cur_lang = 0;
1468914695
else
1469014696
cur_lang = INTPAR(language);
14697+
1469114698
cur_list.aux.b32.s1 = cur_lang;
1469214699
cur_list.prev_graf =
1469314700
(norm_min(INTPAR(left_hyphen_min)) * 64 +
1469414701
norm_min(INTPAR(right_hyphen_min))) * 65536L + cur_lang;
14702+
1469514703
if (indented) {
1469614704
cur_list.tail = new_null_box();
1469714705
mem[cur_list.head].b32.s1 = cur_list.tail;
1469814706
mem[cur_list.tail + 1].b32.s1 = eqtb[DIMEN_BASE].b32.s1;
14699-
if ((insert_src_special_every_par))
14707+
if (insert_src_special_every_par)
1470014708
insert_src_special();
1470114709
}
14710+
14711+
/* Tectonic customization: insert <p> flagged as automatic */
14712+
if (semantic_pagination_enabled)
14713+
tt_insert_special("tdux:as p");
14714+
1470214715
if (LOCAL(every_par) != TEX_NULL)
1470314716
begin_token_list(LOCAL(every_par), EVERY_PAR_TEXT);
14717+
1470414718
if (nest_ptr == 1)
1470514719
build_page();
1470614720
}
@@ -14756,17 +14770,24 @@ void head_for_vmode(void)
1475614770
}
1475714771
}
1475814772

14759-
void end_graf(void)
14773+
void
14774+
end_graf(void)
1476014775
{
1476114776
if (cur_list.mode == HMODE) {
14777+
/* Tectonic customization: insert </p> flagged as automatic */
14778+
if (semantic_pagination_enabled)
14779+
tt_insert_special("tdux:ae p");
14780+
1476214781
if (cur_list.head == cur_list.tail)
1476314782
pop_nest();
1476414783
else
1476514784
line_break(false);
14785+
1476614786
if (cur_list.eTeX_aux != TEX_NULL) {
1476714787
flush_list(cur_list.eTeX_aux);
1476814788
cur_list.eTeX_aux = TEX_NULL;
1476914789
}
14790+
1477014791
normal_paragraph();
1477114792
error_count = 0;
1477214793
}
@@ -16567,6 +16588,40 @@ void append_src_special(void)
1656716588
}
1656816589

1656916590

16591+
/* Tectonic: insert a \special into the current token stream */
16592+
void
16593+
tt_insert_special(const char *ascii_text)
16594+
{
16595+
int32_t toklist_start, p, q;
16596+
pool_pointer start_pool_ptr = pool_ptr;
16597+
16598+
/* Copy the text into the string pool so that we can use str_toks() */
16599+
if (pool_ptr + strlen(ascii_text) >= (size_t) pool_size)
16600+
_tt_abort("string pool overflow");
16601+
16602+
while (*ascii_text)
16603+
str_pool[pool_ptr++] = *ascii_text++;
16604+
16605+
/* Create the linked list of inserted tokens */
16606+
p = toklist_start = get_avail();
16607+
LLIST_info(p) = CS_TOKEN_FLAG + FROZEN_SPECIAL;
16608+
16609+
q = get_avail();
16610+
LLIST_info(q) = LEFT_BRACE_TOKEN + '{';
16611+
LLIST_link(p) = q;
16612+
16613+
/* NB: str_toks creates a list starting at LLIST_link(TEMP_HEAD) and ending at `p` */
16614+
p = str_toks(start_pool_ptr);
16615+
LLIST_link(q) = LLIST_link(TEMP_HEAD);
16616+
16617+
q = get_avail();
16618+
LLIST_info(q) = RIGHT_BRACE_TOKEN + '}';
16619+
LLIST_link(p) = q;
16620+
16621+
/* Queue it up and we're done. */
16622+
begin_token_list(toklist_start, INSERTED);
16623+
}
16624+
1657016625
void
1657116626
handle_right_brace(void)
1657216627
{

crates/engine_xetex/xetex/xetex-xetexd.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,6 +1173,8 @@ cur_length(void) {
11731173
void tt_cleanup(void);
11741174
tt_history_t tt_run_engine(const char *dump_name, const char *input_file_name, time_t build_date);
11751175

1176+
void tt_insert_special(const char *ascii_text);
1177+
11761178

11771179
/* formerly xetex.h: */
11781180
/* additional declarations we want to slip in for xetex */

0 commit comments

Comments
 (0)