From c7b7660049da265e4f51817d79dde8434f06d842 Mon Sep 17 00:00:00 2001 From: GloamXun Date: Mon, 19 Oct 2026 14:10:59 +0800 Subject: [PATCH] Add an unnumbered heading for the abstract environment --- crates/texrra-core/src/document_parser.rs | 9 ++++++++ tests/typeset.rs | 25 +++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/crates/texrra-core/src/document_parser.rs b/crates/texrra-core/src/document_parser.rs index 2366614..754cd83 100644 --- a/crates/texrra-core/src/document_parser.rs +++ b/crates/texrra-core/src/document_parser.rs @@ -1842,6 +1842,15 @@ impl Parser { self.table_active = false; self.current_table_block = None; } + (true, "abstract") => { + self.flush_paragraph(); + let mut heading = Run::plain("Abstract".to_string()); + heading.bold = true; + self.push_block(Block::Centered { + runs: vec![heading], + }); + } + (false, "abstract") => self.flush_paragraph(), (true, "center") => { self.flush_paragraph(); if self.centered.is_none() { diff --git a/tests/typeset.rs b/tests/typeset.rs index 1552785..d78b579 100644 --- a/tests/typeset.rs +++ b/tests/typeset.rs @@ -871,3 +871,28 @@ After. "rules should not be painted as image XObjects" ); } + +#[test] +fn abstract_environment_gets_an_unumbered_heading() { + let source = r"\documentclass{article} +\begin{document} +\begin{abstract} +This is the abstract body. +\end{abstract} +\section{Introduction} +Body. +\end{document}"; + let preview = CompilerSession::default() + .preview_json(source, "abstract.tex") + .expect("abstract preview"); + let value: serde_json::Value = serde_json::from_str(&preview).expect("preview JSON"); + let svg = value["pages"][0]["svg"].as_str().expect("svg"); + assert!( + svg.contains(">Abstract"), + "missing abstract heading: {svg}" + ); + assert!( + svg.contains(">1"), + "section numbering changed: {svg}" + ); +}