@@ -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.)" */
91119114int32_t
91129115str_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+
1657016625void
1657116626handle_right_brace(void)
1657216627{
0 commit comments