Honour the centering paragraph declaration
This commit is contained in:
1 parent
2c8d5e12d8
commit
1b0ce27ed3
8 files changed
+55
-10
No files matched your search
@@ -31,7 +31,6 @@ const PRELUDE: &str = r#"
|
||||
\def\hfil{\hskip0pt plus 1fil\relax}
|
||||
\def\allowbreak{\penalty0}
|
||||
\def\nobreak{\penalty10000}
|
||||
\def\centering{}
|
||||
\def\bibliographystyle#1{}
|
||||
\def\textbf#1{\texrrastylestart{bold}#1\texrrastyleend{bold}}
|
||||
\def\emph#1{\texrrastylestart{italic}#1\texrrastyleend{italic}}
|
||||
|
||||
@@ -1392,6 +1392,7 @@ pub(super) fn build_positioned_pages(
|
||||
|
||||
let paragraph_alignment = runs.iter().find_map(|run| run.alignment);
|
||||
let ragged = paragraph_alignment.is_some();
|
||||
let centered = paragraph_alignment == Some(ParagraphAlignment::Centered);
|
||||
let x = match (paragraph_alignment, &line.content) {
|
||||
(
|
||||
Some(ParagraphAlignment::RaggedLeft),
|
||||
@@ -1420,7 +1421,7 @@ pub(super) fn build_positioned_pages(
|
||||
content: line.content,
|
||||
y: cursor,
|
||||
x,
|
||||
centered: false,
|
||||
centered,
|
||||
ragged,
|
||||
}));
|
||||
cursor = cursor.saturating_add(line_height);
|
||||
|
||||
@@ -1738,6 +1738,18 @@ fn ragged_left_primitive(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn centering_primitive(
|
||||
token: token::Token,
|
||||
input: &mut vm::ExecutionInput<CompilerState>,
|
||||
) -> texlang::prelude::Result<()> {
|
||||
write_event(
|
||||
input,
|
||||
token,
|
||||
FrontendEventKind::ParagraphAlignment(texrra_core::document::ParagraphAlignment::Centered),
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn table_of_contents_primitive(
|
||||
token: token::Token,
|
||||
input: &mut vm::ExecutionInput<CompilerState>,
|
||||
@@ -6801,6 +6813,10 @@ fn built_in_commands() -> HashMap<&'static str, texlang::command::BuiltIn<Compil
|
||||
"raggedleft",
|
||||
texlang::command::BuiltIn::new_execution(ragged_left_primitive),
|
||||
);
|
||||
built_ins.insert(
|
||||
"centering",
|
||||
texlang::command::BuiltIn::new_execution(centering_primitive),
|
||||
);
|
||||
built_ins.insert(
|
||||
"pagestyle",
|
||||
texlang::command::BuiltIn::new_execution(page_style_primitive),
|
||||
|
||||
Reference in new issue
Block a user