mirror of
https://github.com/storytold/wordcraft.git
synced 2026-11-10 04:09:53 -06:00
ODT: custom styles with an outline level keep their name when edited (gap 19) (#5770)
* ODT gap 19: custom styles with an outline level keep their name when edited A paragraph in a custom style with style:default-outline-level was read as WordCraft's Heading 1 or whichever level it named. Unedited, it was written as read. Edited, it was saved as Heading_20_1, so LibreOffice showed WordCraft's blue heading instead of the file's look, and WordCraft drew it that way too. Read such a style as a custom style that carries the outline level. The paragraph stays a heading at that level in WordCraft, is numbered with the file's outline as LibreOffice numbers it, and is saved as <text:h text:style-name="Head" text:outline-level="1">. The level comes from the style, not the paragraph kind, because kinds stop at Heading 6. The writer dropped a custom style's name on any heading, title, quotation or code paragraph, so custom styles based on those lost their look when edited too. It now keeps the name for every kind. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ODT: a heading's own outline level gives its number (gap 19) LibreOffice numbers a heading by its text:outline-level. WordCraft took the number from the style's level, so a heading stating another showed the wrong number, or one on a level the outline doesn't number. A heading in a list stays the list's. Found by CodeRabbit on this PR, as was the Title-based style test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ODT: a heading in a list of its own keeps it, and an unnumbered level takes no number (gap 19) Any list whose first level was linked to a style counted as the outline's, so a heading deeper in one lost its list on save. Now only the number the outline itself gives counts. A style based on a numbered heading, at a level the outline doesn't number, took its parent's number. Found by CodeRabbit on this PR. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ODT: a heading past level 6 keeps its list (gap 19) The written outline has no number past Heading 6, so counting such a heading's list as the outline's lost its number. Found by CodeRabbit on this PR. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ODT: a style with a heading numbered by its own level stays on the outline (gap 19) Writing it with no list style took the number from that heading in LibreOffice. Written so, the numbers match the file's. Found by CodeRabbit on this PR. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ODT: a heading past level six numbered through its style keeps its list (gap 19) The written outline numbers only six levels, and the list was dropped for a heading numbered only through its style, so at levels 7 to 9 it lost its number once its style was rewritten. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Gap 19: docs status lines are main's, with this change in front Merging main had kept this branch's older status lines in ROADMAP.md and docs/file-format-parity.md, which set main's 2026-11-08 date back and dropped main's newer entries and the parity doc's CLI path note. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: FredApps <FredApps@users.noreply.github.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
FredApps
parent
bd9e726cda
commit
29a5abf3e7
+3
-1
File diff suppressed because one or more lines are too long
@@ -182,6 +182,9 @@ fn para_extra(doc: &Document, p: &wordcraft_doc::props::ParaProps) -> Option<Box
|
||||
tabs
|
||||
});
|
||||
let style = p.style.clone().filter(|id| is_custom_style(doc, id));
|
||||
// Its own, else its custom style's: the kind doesn't say (it stops at Heading 6, and is the
|
||||
// heading style's where the style is based on one).
|
||||
let outline_level = p.outline_level.or_else(|| style.as_ref().and_then(|_| doc.styles.resolve_para(p).outline_level));
|
||||
let x = wordcraft_doc::props::ParaProps {
|
||||
tabs,
|
||||
shading: p.shading,
|
||||
@@ -191,7 +194,7 @@ fn para_extra(doc: &Document, p: &wordcraft_doc::props::ParaProps) -> Option<Box
|
||||
drop_cap: p.drop_cap.filter(|l| *l > 1),
|
||||
drop_cap_distance: p.drop_cap_distance.filter(|_| p.drop_cap.is_some_and(|l| l > 1)),
|
||||
keep_lines: p.keep_lines.filter(|k| *k),
|
||||
outline_level: p.outline_level,
|
||||
outline_level,
|
||||
widow_control: p.widow_control.filter(|w| !*w),
|
||||
// Hyphenated (the document hyphenates and the paragraph doesn't opt out): `Some(false)`.
|
||||
suppress_hyphens: (doc.settings.auto_hyphenation && p.suppress_hyphens != Some(true)).then_some(false),
|
||||
@@ -413,14 +416,25 @@ fn flow_comment(doc: &Document, c: &wordcraft_doc::Comment, parent: Option<u32>,
|
||||
FComment { author: c.author.clone(), initials: c.initials.clone(), date: c.date.clone(), resolved: c.resolved, parent, blocks }
|
||||
}
|
||||
|
||||
/// Whether `li`, the list of heading `p`, is the number its outline level has from its heading
|
||||
/// style's list, not a list of its own: it states that level, and the heading style of that level
|
||||
/// numbers with that list there. Past Heading 6 no such style gives the written outline a number.
|
||||
fn numbered_by_outline(doc: &Document, p: &Paragraph, li: &ListInfo) -> bool {
|
||||
use wordcraft_doc::props::NumRef;
|
||||
p.props.outline_level == Some(li.level)
|
||||
&& li.level < 6
|
||||
&& doc.styles.para_style_props(&format!("Heading{}", li.level + 1)).0.numbering == Some(NumRef { num: li.list, level: li.level })
|
||||
}
|
||||
|
||||
/// A paragraph's list membership as the flow keeps it: without the list's identity and label
|
||||
/// unless `opts` asks for them, and none for a heading numbered only through its style, which a
|
||||
/// format with heading numbering of its own (ODT's outline style) numbers instead.
|
||||
fn flow_list(kind: Kind, list: Option<ListInfo>, p: &Paragraph, opts: FlowOpts) -> Option<ListInfo> {
|
||||
/// unless `opts` asks for them, and none for a heading numbered only through its style or
|
||||
/// [`numbered_by_outline`], which a format with heading numbering of its own (ODT's outline style)
|
||||
/// numbers instead, in its first six levels.
|
||||
fn flow_list(doc: &Document, kind: Kind, list: Option<ListInfo>, p: &Paragraph, opts: FlowOpts) -> Option<ListInfo> {
|
||||
let mut li = list?;
|
||||
if !opts.lists {
|
||||
(li.list, li.label) = (0, None);
|
||||
} else if matches!(kind, Kind::Heading(_)) && p.props.numbering.is_none() {
|
||||
} else if matches!(kind, Kind::Heading(_)) && li.level < 6 && (p.props.numbering.is_none() || numbered_by_outline(doc, p, &li)) {
|
||||
return None;
|
||||
}
|
||||
Some(li)
|
||||
@@ -458,7 +472,7 @@ pub fn flow_paras(doc: &Document, p: &Paragraph) -> Vec<Para> {
|
||||
fn flow_paras_in(doc: &Document, p: &Paragraph, opts: FlowOpts) -> Vec<Para> {
|
||||
let tracked = opts.tracked;
|
||||
let (kind, list) = para_kind(doc, p);
|
||||
let list = flow_list(kind, list, p, opts);
|
||||
let list = flow_list(doc, kind, list, p, opts);
|
||||
let mut done: Vec<Para> = Vec::new();
|
||||
let borders = if kind == Kind::Rule { None } else { p.props.borders.filter(|b| b.takes_room()) };
|
||||
let mut out = Para {
|
||||
|
||||
@@ -296,6 +296,8 @@ fn add_custom_styles(doc: &mut Document, named: &[super::styles::NamedStyle], od
|
||||
}),
|
||||
contextual_spacing: look.contextual,
|
||||
bidi: look.rtl.filter(|r| *r),
|
||||
// The document's nine levels; ODF's tenth is the last of them.
|
||||
outline_level: def.outline.map(|o| o.clamp(1, 9) - 1),
|
||||
..Default::default()
|
||||
};
|
||||
let name = super::writer::generating_style(name).map_or_else(|| def.name.clone(), |(_, n)| n);
|
||||
@@ -362,7 +364,7 @@ fn apply_look(doc: &mut Document, kind: model::Kind, look: &super::styles::ParaL
|
||||
fn number_headings(doc: &mut Document, levels: &[super::styles::ListLevel]) {
|
||||
use wordcraft_doc::numbering::{AbstractNum, ListKind, Num, levels_for};
|
||||
use wordcraft_doc::props::NumRef;
|
||||
let numbered: Vec<bool> = (0..6).map(|i| levels.get(i).is_some_and(|l| l.ordered)).collect();
|
||||
let numbered: Vec<bool> = (0..9).map(|i| levels.get(i).is_some_and(|l| l.ordered)).collect();
|
||||
if !numbered.contains(&true) {
|
||||
return;
|
||||
}
|
||||
@@ -395,11 +397,62 @@ fn number_headings(doc: &mut Document, levels: &[super::styles::ListLevel]) {
|
||||
numbering.abstracts.push(AbstractNum { id: aid, name: None, levels: out, ..Default::default() });
|
||||
let nid = numbering.nums.iter().map(|n| n.id + 1).max().unwrap_or(1).max(1);
|
||||
numbering.nums.push(Num { id: nid, abstract_id: aid, ..Default::default() });
|
||||
let styles = Arc::make_mut(&mut doc.styles);
|
||||
for (i, on) in numbered.iter().enumerate() {
|
||||
if *on && let Some(st) = Arc::make_mut(&mut doc.styles).get_mut(&format!("Heading{}", i + 1)) {
|
||||
if *on && let Some(st) = styles.get_mut(&format!("Heading{}", i + 1)) {
|
||||
st.para.numbering = Some(NumRef { num: nid, level: i as u8 });
|
||||
}
|
||||
}
|
||||
// LibreOffice numbers a custom style at an outline level along with that level's headings.
|
||||
for st in &mut styles.styles {
|
||||
if let Some(l) = st.para.outline_level.filter(|l| numbered.get(usize::from(*l)) == Some(&true)) {
|
||||
st.para.numbering = Some(NumRef { num: nid, level: l });
|
||||
}
|
||||
}
|
||||
// A style at a level the outline doesn't number doesn't take its parent's number from it.
|
||||
let of_outline = |st: &wordcraft_doc::styles::Style| {
|
||||
let at = wordcraft_doc::props::ParaProps { style: Some(st.id.clone()), ..Default::default() };
|
||||
st.para.numbering.is_none()
|
||||
&& st.para.outline_level.is_some_and(|l| numbered.get(usize::from(l)) != Some(&true))
|
||||
&& styles.resolve_para(&at).numbering.is_some_and(|n| n.num == nid)
|
||||
};
|
||||
let unnumbered: Vec<String> = styles.styles.iter().filter(|st| of_outline(st)).map(|st| st.id.clone()).collect();
|
||||
for id in unnumbered {
|
||||
if let Some(st) = styles.get_mut(&id) {
|
||||
// (`num: 0` switches the number off.)
|
||||
st.para.numbering = Some(NumRef { num: 0, level: 0 });
|
||||
}
|
||||
}
|
||||
// A heading's own outline level goes before its style's: LibreOffice numbers it by that level.
|
||||
// A heading in a list is that list's.
|
||||
let styles = doc.styles.clone();
|
||||
each_body_para(&mut doc.body, 0, &mut |p| {
|
||||
let Some(l) = p.props.outline_level.filter(|_| p.props.numbering.is_none()) else { return };
|
||||
let style = styles.resolve_para(&wordcraft_doc::props::ParaProps { style: p.props.style.clone(), ..Default::default() });
|
||||
if style.outline_level.is_none() {
|
||||
return;
|
||||
}
|
||||
let own = (numbered.get(usize::from(l)) == Some(&true)).then_some(NumRef { num: nid, level: l });
|
||||
if own != style.numbering {
|
||||
// (`num: 0` switches the style's number off.)
|
||||
p.props.numbering = Some(own.unwrap_or(NumRef { num: 0, level: 0 }));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// Each paragraph of `blocks`, those in tables too (to 16 levels deep).
|
||||
fn each_body_para(blocks: &mut [Arc<wordcraft_doc::Block>], depth: usize, f: &mut dyn FnMut(&mut wordcraft_doc::Paragraph)) {
|
||||
for b in blocks {
|
||||
match Arc::make_mut(b) {
|
||||
wordcraft_doc::Block::Para(p) => f(p),
|
||||
wordcraft_doc::Block::Table(t) if depth < 16 => {
|
||||
for cell in t.rows.iter_mut().flat_map(|r| r.cells.iter_mut()) {
|
||||
each_body_para(&mut cell.blocks, depth + 1, f);
|
||||
}
|
||||
}
|
||||
wordcraft_doc::Block::Table(_) => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The boolean configuration item `name` of `settings.xml` (ODF 1.3 §3.10), when it has one.
|
||||
|
||||
@@ -29,7 +29,7 @@ fn columns_xml(c: &Columns) -> String {
|
||||
/// Preformatted Text), each with the look of the document's own style: font, size, bold,
|
||||
/// italic, colour and the rest of its text formatting, spacing, indents, alignment and keep with
|
||||
/// next, written out in full so other programs show them as WordCraft does.
|
||||
fn kind_styles(doc: &Document) -> String {
|
||||
fn kind_styles(doc: &Document, on_outline: &std::collections::BTreeSet<String>) -> String {
|
||||
let mut s = String::new();
|
||||
let mut kinds: Vec<(String, String, String, Option<u8>, &str)> =
|
||||
(1..=6).map(|n| (format!("Heading_20_{n}"), format!("Heading {n}"), format!("Heading{n}"), Some(n), "text")).collect();
|
||||
@@ -63,14 +63,7 @@ fn kind_styles(doc: &Document) -> String {
|
||||
if let Some(c) = pp.contextual_spacing {
|
||||
para.push_str(&format!(" style:contextual-spacing=\"{c}\""));
|
||||
}
|
||||
// A heading level the outline doesn't number names no list style: LibreOffice would
|
||||
// otherwise give it the outline's (unnumbered) level, and its indent.
|
||||
let numbered = pp
|
||||
.numbering
|
||||
.and_then(|r| doc.numbering.level(r.num, r.level))
|
||||
.is_some_and(|l| !matches!(l.format, wordcraft_doc::section::NumFormat::None | wordcraft_doc::section::NumFormat::Bullet));
|
||||
let detach = if outline.is_some() && !numbered { " style:list-style-name=\"\"" } else { "" };
|
||||
let outline = outline.map(|n| format!(" style:default-outline-level=\"{n}\"{detach}")).unwrap_or_default();
|
||||
let outline = outline.map(|n| outline_attrs(doc, n, &pp, on_outline.contains(&id))).unwrap_or_default();
|
||||
s.push_str(&format!(
|
||||
"<style:style style:name=\"{name}\" style:display-name=\"{display}\" style:family=\"paragraph\" style:parent-style-name=\"Standard\" style:next-style-name=\"Standard\"{outline} style:class=\"{class}\"><style:paragraph-properties{para}/><style:text-properties{}/></style:style>",
|
||||
props_text(&cp)
|
||||
@@ -79,6 +72,42 @@ fn kind_styles(doc: &Document) -> String {
|
||||
s
|
||||
}
|
||||
|
||||
/// The styles of the headings in `blocks` (and their tables, to 16 levels deep) with a number by
|
||||
/// their own outline level.
|
||||
fn styles_numbered_by_own_level(blocks: &[std::sync::Arc<wordcraft_doc::Block>], depth: usize, out: &mut std::collections::BTreeSet<String>) {
|
||||
for b in blocks {
|
||||
match &**b {
|
||||
wordcraft_doc::Block::Para(p) => {
|
||||
if p.props.outline_level.is_some()
|
||||
&& p.props.numbering.is_some_and(|n| n.num != 0)
|
||||
&& let Some(s) = &p.props.style
|
||||
{
|
||||
out.insert(s.clone());
|
||||
}
|
||||
}
|
||||
wordcraft_doc::Block::Table(t) if depth < 16 => {
|
||||
for cell in t.rows.iter().flat_map(|r| r.cells.iter()) {
|
||||
styles_numbered_by_own_level(&cell.blocks, depth + 1, out);
|
||||
}
|
||||
}
|
||||
wordcraft_doc::Block::Table(_) => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A paragraph style's outline level `n` (`style:default-outline-level`), its properties being `pp`.
|
||||
fn outline_attrs(doc: &Document, n: u8, pp: &wordcraft_doc::props::ParaProps, on_outline: bool) -> String {
|
||||
// A level the outline doesn't number names no list style: LibreOffice would otherwise give
|
||||
// it the outline's (unnumbered) level, and its indent. Unless a heading in the style has a
|
||||
// number by its own level (`on_outline`), which that would take from it.
|
||||
let numbered = pp
|
||||
.numbering
|
||||
.and_then(|r| doc.numbering.level(r.num, r.level))
|
||||
.is_some_and(|l| !matches!(l.format, wordcraft_doc::section::NumFormat::None | wordcraft_doc::section::NumFormat::Bullet));
|
||||
let detach = if numbered || on_outline { "" } else { " style:list-style-name=\"\"" };
|
||||
format!(" style:default-outline-level=\"{n}\"{detach}")
|
||||
}
|
||||
|
||||
/// The ODF parent of document style `id`: Standard for Normal, the kinds' styles for theirs, a
|
||||
/// custom style by its id.
|
||||
fn odf_parent(doc: &Document, id: Option<&str>) -> String {
|
||||
@@ -98,7 +127,7 @@ fn odf_parent(doc: &Document, id: Option<&str>) -> String {
|
||||
/// The custom paragraph styles in `named` and the custom styles they are based on, as common
|
||||
/// styles (ODF 1.3 §16.2): named by their document id, shown by their name, each with its own
|
||||
/// paragraph and text formatting over its parent's.
|
||||
fn custom_styles(doc: &Document, named: &std::collections::BTreeSet<String>) -> String {
|
||||
fn custom_styles(doc: &Document, named: &std::collections::BTreeSet<String>, on_outline: &std::collections::BTreeSet<String>) -> String {
|
||||
let mut todo: Vec<String> = named.iter().cloned().collect();
|
||||
let mut done = std::collections::BTreeSet::new();
|
||||
let mut s = String::new();
|
||||
@@ -146,8 +175,9 @@ fn custom_styles(doc: &Document, named: &std::collections::BTreeSet<String>) ->
|
||||
})
|
||||
.unwrap_or_default();
|
||||
let parent = odf_parent(doc, st.based_on.as_deref());
|
||||
let outline = pp.outline_level.filter(|l| *l < 9).map(|l| outline_attrs(doc, l + 1, pp, on_outline.contains(&id))).unwrap_or_default();
|
||||
s.push_str(&format!(
|
||||
"<style:style style:name=\"{}\" style:display-name=\"{}\" style:family=\"paragraph\" style:parent-style-name=\"{parent}\"><style:paragraph-properties{attrs}>{tabs}</style:paragraph-properties><style:text-properties{}/></style:style>",
|
||||
"<style:style style:name=\"{}\" style:display-name=\"{}\" style:family=\"paragraph\" style:parent-style-name=\"{parent}\"{outline}><style:paragraph-properties{attrs}>{tabs}</style:paragraph-properties><style:text-properties{}/></style:style>",
|
||||
super::writer::odf_name(&id),
|
||||
x(&super::writer::generated_style(&id).map_or_else(|| st.name.clone(), |(_, d)| d)),
|
||||
props_text(&st.chr)
|
||||
@@ -365,9 +395,11 @@ fn styles_xml(
|
||||
scripts = super::writer::script_attrs(&doc.styles.default_chr)
|
||||
));
|
||||
s.push_str("<style:style style:name=\"Standard\" style:family=\"paragraph\" style:class=\"text\"/>");
|
||||
s.push_str(&kind_styles(doc));
|
||||
let mut on_outline = std::collections::BTreeSet::new();
|
||||
styles_numbered_by_own_level(&doc.body, 0, &mut on_outline);
|
||||
s.push_str(&kind_styles(doc, &on_outline));
|
||||
s.push_str(&outline_style(doc));
|
||||
s.push_str(&custom_styles(doc, named));
|
||||
s.push_str(&custom_styles(doc, named, &on_outline));
|
||||
// The note text styles, as WordCraft's Footnote Text and Endnote Text: 10 pt, no spacing.
|
||||
for (name, class) in [("Footnote", "extra"), ("Endnote", "extra")] {
|
||||
s.push_str(&format!(
|
||||
|
||||
@@ -465,6 +465,8 @@ pub(super) struct NamedStyle {
|
||||
/// What it turns off, which a style it is based on may turn on: bold, italic, underline,
|
||||
/// strike-through (`fo:font-weight="normal"`…).
|
||||
pub(super) off: [bool; 4],
|
||||
/// Its outline level, 1–10 (`style:default-outline-level`).
|
||||
pub(super) outline: Option<u8>,
|
||||
}
|
||||
|
||||
/// Reads date and time styles (`number:date-style`, `number:time-style`) as Word pictures.
|
||||
@@ -1560,13 +1562,16 @@ impl Styles {
|
||||
};
|
||||
let name = s.display.clone().unwrap_or_else(|| odt.replace("_20_", " "));
|
||||
let off = [s.fmt.bold, s.fmt.italic, s.fmt.underline, s.fmt.strike].map(|v| v == Some(false));
|
||||
Some(NamedStyle { name: name.chars().take(super::super::model::MAX_FONT_NAME).collect(), parent, look, off })
|
||||
let outline = s.outline.filter(|o| (1..=10).contains(o));
|
||||
Some(NamedStyle { name: name.chars().take(super::super::model::MAX_FONT_NAME).collect(), parent, look, off, outline })
|
||||
}
|
||||
|
||||
pub(super) fn para(&self, name: &str) -> ParaLook {
|
||||
let chain = self.chain(name);
|
||||
let mut kind = Kind::Normal;
|
||||
let mut kind_at = chain.len();
|
||||
// The nearest outline level; a style with one is no kind's style: its look is its own.
|
||||
let mut outline = None;
|
||||
for (i, (n, s)) in chain.iter().enumerate() {
|
||||
kind_at = i;
|
||||
let dn = s.display.as_deref().unwrap_or(n).to_ascii_lowercase().replace("_20_", " ");
|
||||
@@ -1585,12 +1590,12 @@ impl Styles {
|
||||
if kind != Kind::Normal {
|
||||
break;
|
||||
}
|
||||
if let Some(o) = s.outline.filter(|o| (1..=10).contains(o)) {
|
||||
kind = Kind::Heading(o.min(6));
|
||||
break;
|
||||
}
|
||||
outline = outline.or(s.outline.filter(|o| (1..=10).contains(o)));
|
||||
kind_at = chain.len();
|
||||
}
|
||||
if let Some(o) = outline {
|
||||
kind = Kind::Heading(o.min(6));
|
||||
}
|
||||
// The nearest custom style: its formatting stays in it; the automatic styles over it give
|
||||
// the paragraph's own.
|
||||
let named_at = chain.iter().take(kind_at).position(|(n, _)| self.is_named(n));
|
||||
|
||||
@@ -112,3 +112,327 @@ fn a_heading_looks_as_its_style_and_has_the_level_its_element_gives() {
|
||||
let back = import(&saved).unwrap();
|
||||
assert_eq!((props(&back, 0).style.as_deref(), props(&back, 0).outline_level), (Some("Heading2"), Some(0)));
|
||||
}
|
||||
|
||||
/// A document with these common `styles` and this `body`.
|
||||
fn in_custom_style(styles: &str, body: &str) -> Document {
|
||||
let styles = format!(
|
||||
r#"<office:document-styles {NS_T}><office:styles><style:style style:name="Standard" style:family="paragraph"/>{styles}</office:styles></office:document-styles>"#
|
||||
);
|
||||
let content =
|
||||
format!(r#"<office:document-content {NS_T}><office:body><office:text>{body}</office:text></office:body></office:document-content>"#);
|
||||
import(&package(&content, Some(&styles))).unwrap()
|
||||
}
|
||||
|
||||
const HEAD: &str = r#"<style:style style:name="Head" style:family="paragraph" style:parent-style-name="Standard" style:default-outline-level="1" style:class="text"><style:text-properties fo:font-size="26pt" fo:font-weight="bold"/></style:style>"#;
|
||||
|
||||
fn saved_after_an_edit(d: &mut Document) -> Vec<u8> {
|
||||
d.insert_text(&wordcraft_doc::Pos::body(0, 0), "Yearly ", &Default::default()).unwrap();
|
||||
export(d).unwrap()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_custom_style_with_an_outline_level_stays_the_paragraphs_style() {
|
||||
// The outline level is the style's; the look stays the file's own, not Heading 1's.
|
||||
let mut d = in_custom_style(HEAD, r#"<text:p text:style-name="Head">Annual report edition</text:p>"#);
|
||||
let p = d.body[0].as_para().unwrap().props.clone();
|
||||
assert_eq!(p.style.as_deref(), Some("Head"));
|
||||
assert_eq!(d.styles.resolve_para(&p).outline_level, Some(0), "still a heading in WordCraft");
|
||||
let look = d.styles.resolve_char(p.style.as_deref(), &Default::default());
|
||||
assert_eq!((look.size, look.bold), (26.0, true));
|
||||
let r = d.body[0].as_para().unwrap().runs.first().unwrap().props.clone();
|
||||
assert!(r.size.is_none() && r.bold.is_none(), "the look stays in the style: {r:?}");
|
||||
|
||||
// Edited, it is written from the model, under its own name, at its level.
|
||||
let saved = saved_after_an_edit(&mut d);
|
||||
let c = crate::odt::tests::content_of(&saved);
|
||||
assert!(c.contains(r#"<text:h text:style-name="Head" text:outline-level="1">Yearly Annual"#), "{c}");
|
||||
let s = crate::odt::tests::styles_of(&saved);
|
||||
let head = s.split("<style:style ").find(|x| x.starts_with(r#"style:name="Head""#)).unwrap_or("");
|
||||
assert!(head.contains(r#"style:default-outline-level="1""#) && head.contains(r#"fo:font-size="26pt""#), "{head}");
|
||||
|
||||
// And read back, it is the same heading.
|
||||
let back = import(&saved).unwrap();
|
||||
let p = back.body[0].as_para().unwrap().props.clone();
|
||||
assert_eq!((p.style.as_deref(), back.styles.resolve_para(&p).outline_level), (Some("Head"), Some(0)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_unedited_paragraph_in_such_a_style_is_written_as_read() {
|
||||
let body = r#"<text:p text:style-name="Head">Annual report edition</text:p>"#;
|
||||
let saved = export(&in_custom_style(HEAD, body)).unwrap();
|
||||
assert!(crate::odt::tests::content_of(&saved).contains(body));
|
||||
let s = crate::odt::tests::styles_of(&saved);
|
||||
assert_eq!(s.matches(r#"style:name="Head""#).count(), 1, "{s}");
|
||||
assert!(s.contains(r#"style:default-outline-level="1""#), "{s}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn every_level_of_such_a_style_is_written_as_it_is() {
|
||||
// The paragraph kinds stop at Heading 6; the outline levels go on, and a style based on another
|
||||
// heading has its own.
|
||||
let styles = r#"<style:style style:name="Heading_20_2" style:display-name="Heading 2" style:family="paragraph"/><style:style style:name="Deep" style:family="paragraph" style:default-outline-level="8"/><style:style style:name="Under" style:family="paragraph" style:parent-style-name="Heading_20_2" style:default-outline-level="3"/><style:style style:name="Child" style:family="paragraph" style:parent-style-name="Deep"/>"#;
|
||||
let body =
|
||||
r#"<text:p text:style-name="Deep">deep</text:p><text:p text:style-name="Under">under</text:p><text:p text:style-name="Child">child</text:p>"#;
|
||||
let d = in_custom_style(styles, body);
|
||||
let level = |d: &Document, i: usize| d.styles.resolve_para(&d.body[i].as_para().unwrap().props).outline_level;
|
||||
assert_eq!([level(&d, 0), level(&d, 1), level(&d, 2)], [Some(7), Some(2), Some(7)]);
|
||||
let saved = crate::odt::tests::export_model(&d).unwrap();
|
||||
let c = crate::odt::tests::content_of(&saved);
|
||||
assert!(c.contains(r#"<text:h text:style-name="Deep" text:outline-level="8">deep"#), "{c}");
|
||||
assert!(c.contains(r#"<text:h text:style-name="Under" text:outline-level="3">under"#), "{c}");
|
||||
assert!(c.contains(r#"<text:h text:style-name="Child" text:outline-level="8">child"#), "{c}");
|
||||
let back = import(&saved).unwrap();
|
||||
assert_eq!([level(&back, 0), level(&back, 1), level(&back, 2)], [Some(7), Some(2), Some(7)]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_paragraphs_own_level_and_formatting_stay_over_such_a_style() {
|
||||
let styles = format!(r#"<office:document-styles {NS_T}><office:styles>{HEAD}</office:styles></office:document-styles>"#);
|
||||
let content = format!(
|
||||
r#"<office:document-content {NS_T}><office:automatic-styles><style:style style:name="P1" style:family="paragraph" style:parent-style-name="Head"><style:paragraph-properties fo:text-align="center"/></style:style></office:automatic-styles><office:body><office:text><text:h text:style-name="P1" text:outline-level="2">Moved</text:h></office:text></office:body></office:document-content>"#
|
||||
);
|
||||
let d = import(&package(&content, Some(&styles))).unwrap();
|
||||
let p = d.body[0].as_para().unwrap().props.clone();
|
||||
assert_eq!((p.style.as_deref(), p.outline_level, p.align), (Some("Head"), Some(1), Some(wordcraft_doc::Align::Center)));
|
||||
let c = crate::odt::tests::content_of(&crate::odt::tests::export_model(&d).unwrap());
|
||||
assert!(c.contains(r#"text:outline-level="2">Moved"#), "{c}");
|
||||
assert!(c.contains(r#"style:parent-style-name="Head""#) && c.contains(r#"fo:text-align="center""#), "{c}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_hostile_outline_level_on_a_custom_style_is_no_heading() {
|
||||
for bad in ["0", "11", "255", "999", "-1", "x", ""] {
|
||||
let styles = format!(r#"<style:style style:name="Head" style:family="paragraph" style:default-outline-level="{bad}"/>"#);
|
||||
let d = in_custom_style(&styles, r#"<text:p text:style-name="Head">Plain</text:p>"#);
|
||||
let p = d.body[0].as_para().unwrap().props.clone();
|
||||
assert_eq!((p.style.as_deref(), d.styles.resolve_para(&p).outline_level), (Some("Head"), None), "{bad}");
|
||||
let c = crate::odt::tests::content_of(&crate::odt::tests::export_model(&d).unwrap());
|
||||
assert!(c.contains(r#"<text:p text:style-name="Head">Plain"#), "{bad}: {c}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn such_a_style_is_numbered_with_its_level() {
|
||||
// LibreOffice numbers it through the outline style, one list with the level's headings.
|
||||
let d = in_custom_style(
|
||||
&format!(
|
||||
r#"{HEAD}<style:style style:name="Heading_20_1" style:display-name="Heading 1" style:family="paragraph" style:default-outline-level="1"/>{NUMBERED}"#
|
||||
),
|
||||
r#"<text:p text:style-name="Head">First</text:p><text:h text:style-name="Heading_20_1" text:outline-level="1">Second</text:h>"#,
|
||||
);
|
||||
let num = |d: &Document, i: usize| d.styles.resolve_para(&d.body[i].as_para().unwrap().props).numbering;
|
||||
assert!(num(&d, 0).is_some());
|
||||
assert_eq!(num(&d, 0), num(&d, 1));
|
||||
let saved = crate::odt::tests::export_model(&d).unwrap();
|
||||
let c = crate::odt::tests::content_of(&saved);
|
||||
assert!(!c.contains("<text:list"), "the outline numbers it: {c}");
|
||||
assert!(c.contains(r#"<text:h text:style-name="Head" text:outline-level="1">First"#), "{c}");
|
||||
// A numbered level stays attached to the outline; an unnumbered one doesn't take its indent.
|
||||
let head = |xml: String| xml.split("<style:style ").find(|x| x.starts_with(r#"style:name="Head""#)).map(String::from).unwrap_or_default();
|
||||
assert!(!head(crate::odt::tests::styles_of(&saved)).contains("style:list-style-name"));
|
||||
let back = import(&saved).unwrap();
|
||||
assert!(num(&back, 0).is_some());
|
||||
assert_eq!(num(&back, 0), num(&back, 1));
|
||||
let plain = in_custom_style(HEAD, r#"<text:p text:style-name="Head">First</text:p>"#);
|
||||
let s = crate::odt::tests::styles_of(&crate::odt::tests::export_model(&plain).unwrap());
|
||||
assert!(head(s).contains(r#"style:list-style-name="""#));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn custom_styles_based_on_any_kinds_style_keep_their_name_when_edited() {
|
||||
// The kind's style took their place, without their own look.
|
||||
let styles = r##"<style:style style:name="Title" style:family="paragraph"/><style:style style:name="Quotations" style:family="paragraph"/><style:style style:name="Preformatted_20_Text" style:display-name="Preformatted Text" style:family="paragraph"/><style:style style:name="Heading_20_2" style:display-name="Heading 2" style:family="paragraph"/><style:style style:name="Banner" style:family="paragraph" style:parent-style-name="Title"><style:text-properties fo:color="#cc6600"/></style:style><style:style style:name="Aside" style:family="paragraph" style:parent-style-name="Quotations"/><style:style style:name="Listing" style:family="paragraph" style:parent-style-name="Preformatted_20_Text"/><style:style style:name="Plaque" style:family="paragraph" style:parent-style-name="Heading_20_2"/>"##;
|
||||
let body = r#"<text:p text:style-name="Banner">b</text:p><text:p text:style-name="Aside">a</text:p><text:p text:style-name="Listing">l</text:p><text:p text:style-name="Plaque">p</text:p>"#;
|
||||
let saved = crate::odt::tests::export_model(&in_custom_style(styles, body)).unwrap();
|
||||
let c = crate::odt::tests::content_of(&saved);
|
||||
for want in [
|
||||
r#"<text:p text:style-name="Banner">b"#,
|
||||
r#"<text:p text:style-name="Aside">a"#,
|
||||
r#"<text:p text:style-name="Listing">l"#,
|
||||
r#"<text:h text:style-name="Plaque" text:outline-level="2">p"#,
|
||||
] {
|
||||
assert!(c.contains(want), "{want} in {c}");
|
||||
}
|
||||
let s = crate::odt::tests::styles_of(&saved);
|
||||
assert!(s.contains(r#"style:name="Banner" style:display-name="Banner" style:family="paragraph" style:parent-style-name="Title""#), "{s}");
|
||||
}
|
||||
|
||||
/// A heading's number is its own outline level's, as in LibreOffice, not its style's: `(level)` of
|
||||
/// each paragraph's number, as layout takes it.
|
||||
fn number_levels(d: &Document) -> Vec<Option<u8>> {
|
||||
d.body
|
||||
.iter()
|
||||
.filter_map(|b| b.as_para())
|
||||
.map(|p| p.props.numbering.or(d.styles.resolve_para(&p.props).numbering).filter(|n| n.num != 0).map(|n| n.level))
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_headings_own_outline_level_gives_its_number() {
|
||||
let outline = r#"<text:outline-style style:name="Outline"><text:outline-level-style text:level="1" style:num-format="1" style:num-suffix="."/><text:outline-level-style text:level="2" style:num-format="1" text:display-levels="2" style:num-suffix="."/><text:outline-level-style text:level="3" style:num-format=""/></text:outline-style>"#;
|
||||
let styles = format!(
|
||||
r#"{HEAD}<style:style style:name="Low" style:family="paragraph" style:parent-style-name="Standard" style:default-outline-level="3"/><style:style style:name="Heading_20_1" style:display-name="Heading 1" style:family="paragraph" style:default-outline-level="1"/>{outline}"#
|
||||
);
|
||||
let h = |style: &str, level: u8| format!(r#"<text:h text:style-name="{style}" text:outline-level="{level}">{style} {level}</text:h>"#);
|
||||
let body = [h("Head", 1), h("Head", 2), h("Head", 3), h("Low", 3), h("Low", 1), h("Low", 2), h("Heading_20_1", 2), h("Heading_20_1", 3)].concat();
|
||||
let d = in_custom_style(&styles, &body);
|
||||
let want = vec![Some(0), Some(1), None, None, Some(0), Some(1), Some(1), None];
|
||||
assert_eq!(number_levels(&d), want);
|
||||
let nums: std::collections::BTreeSet<u32> = d
|
||||
.body
|
||||
.iter()
|
||||
.filter_map(|b| b.as_para())
|
||||
.filter_map(|p| p.props.numbering.or(d.styles.resolve_para(&p.props).numbering))
|
||||
.map(|n| n.num)
|
||||
.filter(|n| *n != 0)
|
||||
.collect();
|
||||
assert_eq!(nums.len(), 1, "one list with the headings': {nums:?}");
|
||||
// Written from the model the outline still numbers them, by the levels stated, and read back
|
||||
// they are as they were.
|
||||
let saved = crate::odt::tests::export_model(&d).unwrap();
|
||||
let c = crate::odt::tests::content_of(&saved);
|
||||
assert!(!c.contains("<text:list"), "{c}");
|
||||
for (style, level) in [("Head", 2), ("Low", 1), ("Heading_20_1", 3)] {
|
||||
assert!(c.contains(&format!(r#"<text:h text:style-name="{style}" text:outline-level="{level}">{style} {level}"#)), "{c}");
|
||||
}
|
||||
assert_eq!(number_levels(&import(&saved).unwrap()), want);
|
||||
}
|
||||
|
||||
/// A heading in a list is that list's, whatever its outline level would number.
|
||||
#[test]
|
||||
fn a_heading_in_a_list_keeps_the_lists_number() {
|
||||
let styles = format!(
|
||||
r#"{HEAD}{NUMBERED}<text:list-style style:name="L"><text:list-level-style-number text:level="1" style:num-format="a"/></text:list-style>"#
|
||||
);
|
||||
let d = in_custom_style(
|
||||
&styles,
|
||||
r#"<text:list text:style-name="L"><text:list-item><text:h text:style-name="Head" text:outline-level="2">x</text:h></text:list-item></text:list>"#,
|
||||
);
|
||||
let p = d.body[0].as_para().unwrap();
|
||||
let n = p.props.numbering.expect("its list");
|
||||
assert_eq!(d.numbering.level(n.num, n.level).map(|l| l.format), Some(NumFormat::LowerLetter));
|
||||
}
|
||||
|
||||
/// A style based on Title with an outline level is a heading at that level, in its own name.
|
||||
#[test]
|
||||
fn a_title_based_style_with_an_outline_level_stays_a_heading() {
|
||||
let styles = r#"<style:style style:name="Title" style:family="paragraph"/><style:style style:name="Banner" style:family="paragraph" style:parent-style-name="Title" style:default-outline-level="1"/>"#;
|
||||
let mut d = in_custom_style(styles, r#"<text:p text:style-name="Banner">report</text:p>"#);
|
||||
let p = d.body[0].as_para().unwrap().props.clone();
|
||||
assert_eq!((p.style.as_deref(), d.styles.resolve_para(&p).outline_level), (Some("Banner"), Some(0)));
|
||||
let saved = saved_after_an_edit(&mut d);
|
||||
let c = crate::odt::tests::content_of(&saved);
|
||||
assert!(c.contains(r#"<text:h text:style-name="Banner" text:outline-level="1">Yearly report"#), "{c}");
|
||||
}
|
||||
|
||||
/// A style based on a numbered heading, at a level the outline doesn't number, has no number: as
|
||||
/// in LibreOffice, not its parent's.
|
||||
#[test]
|
||||
fn a_style_at_an_unnumbered_level_has_no_number_from_its_parent() {
|
||||
let outline = r#"<text:outline-style style:name="Outline"><text:outline-level-style text:level="1" style:num-format="1" style:num-suffix="."/><text:outline-level-style text:level="2" style:num-format=""/><text:outline-level-style text:level="3" style:num-format="1" style:num-suffix="."/></text:outline-style>"#;
|
||||
let styles = format!(
|
||||
r#"<style:style style:name="Heading_20_1" style:display-name="Heading 1" style:family="paragraph" style:parent-style-name="Standard" style:default-outline-level="1"/><style:style style:name="Child" style:family="paragraph" style:parent-style-name="Heading_20_1" style:default-outline-level="2"/><style:style style:name="Grand" style:family="paragraph" style:parent-style-name="Heading_20_1" style:default-outline-level="3"/>{outline}"#
|
||||
);
|
||||
let body = r#"<text:h text:style-name="Heading_20_1" text:outline-level="1">One</text:h><text:p text:style-name="Child">As p</text:p><text:h text:style-name="Child" text:outline-level="2">As h</text:h><text:p text:style-name="Grand">Third</text:p><text:h text:style-name="Heading_20_1" text:outline-level="1">Two</text:h>"#;
|
||||
let d = in_custom_style(&styles, body);
|
||||
let want = vec![Some(0), None, None, Some(2), Some(0)];
|
||||
assert_eq!(number_levels(&d), want);
|
||||
let saved = crate::odt::tests::export_model(&d).unwrap();
|
||||
let written = crate::odt::tests::styles_of(&saved);
|
||||
let child = written.split("<style:style ").find(|x| x.starts_with(r#"style:name="Child""#)).unwrap_or_default();
|
||||
assert!(child.contains(r#"style:list-style-name="""#), "LibreOffice gives it no number: {child}");
|
||||
assert_eq!(number_levels(&import(&saved).unwrap()), want);
|
||||
}
|
||||
|
||||
/// A heading in a list of its own stays in it, whatever the list's levels are linked to: only the
|
||||
/// number the outline itself gives a heading goes with the outline.
|
||||
#[test]
|
||||
fn a_heading_in_a_list_linked_to_a_style_stays_in_it() {
|
||||
use std::sync::Arc;
|
||||
use wordcraft_doc::props::NumRef;
|
||||
let mut d = Document::new();
|
||||
let numbering = Arc::make_mut(&mut d.numbering);
|
||||
let num = numbering.add_list(wordcraft_doc::numbering::ListKind::Numbered);
|
||||
let first = numbering.abstracts.last_mut().and_then(|a| a.levels.first_mut()).unwrap();
|
||||
first.style = Some("Heading1".into());
|
||||
let mut p = wordcraft_doc::Paragraph::with_text("x", Default::default());
|
||||
p.props.style = Some("Heading2".into());
|
||||
p.props.numbering = Some(NumRef { num, level: 1 });
|
||||
let has_list = |d: &Document| crate::odt::tests::content_of(&crate::odt::tests::export_model(d).unwrap()).contains("<text:list");
|
||||
// At a deeper level than the link, no level of its own stated.
|
||||
d.body = vec![wordcraft_doc::para_block(p.clone())];
|
||||
assert!(has_list(&d), "a list of its own");
|
||||
// At its own level too, but its heading style isn't numbered: the outline wouldn't number it.
|
||||
p.props.outline_level = Some(1);
|
||||
d.body = vec![wordcraft_doc::para_block(p)];
|
||||
assert!(has_list(&d), "the outline has no number for it");
|
||||
// Its heading style numbered there by this list: the outline's number.
|
||||
Arc::make_mut(&mut d.styles).get_mut("Heading2").unwrap().para.numbering = Some(NumRef { num, level: 1 });
|
||||
assert!(!has_list(&d), "the outline's");
|
||||
}
|
||||
|
||||
/// Past Heading 6 the outline written has no number to give, so a heading there keeps its list.
|
||||
#[test]
|
||||
fn a_heading_past_level_six_keeps_its_list() {
|
||||
use std::sync::Arc;
|
||||
use wordcraft_doc::props::NumRef;
|
||||
let mut d = Document::new();
|
||||
let num = Arc::make_mut(&mut d.numbering).add_list(wordcraft_doc::numbering::ListKind::Numbered);
|
||||
Arc::make_mut(&mut d.styles).get_mut("Heading1").unwrap().para.numbering = Some(NumRef { num, level: 0 });
|
||||
for level in 6..=8 {
|
||||
let mut p = wordcraft_doc::Paragraph::with_text("x", Default::default());
|
||||
p.props.style = Some("Heading6".into());
|
||||
p.props.outline_level = Some(level);
|
||||
p.props.numbering = Some(NumRef { num, level });
|
||||
d.body = vec![wordcraft_doc::para_block(p)];
|
||||
let c = crate::odt::tests::content_of(&crate::odt::tests::export_model(&d).unwrap());
|
||||
assert!(c.contains("<text:list"), "level {level}: {c}");
|
||||
}
|
||||
}
|
||||
|
||||
/// A heading past level six numbered through its style keeps its list too, as the outline written
|
||||
/// numbers only six: read, written from the model and with its style edited.
|
||||
#[test]
|
||||
fn a_heading_past_level_six_numbered_by_its_style_keeps_its_list() {
|
||||
use std::sync::Arc;
|
||||
for level in 7..=9u8 {
|
||||
let styles = format!(
|
||||
r#"<style:style style:name="Deep" style:family="paragraph" style:parent-style-name="Standard" style:default-outline-level="{level}"/><text:outline-style style:name="Outline"><text:outline-level-style text:level="{level}" style:num-format="1" style:num-suffix="."/></text:outline-style>"#
|
||||
);
|
||||
let body = format!(r#"<text:h text:style-name="Deep" text:outline-level="{level}">x</text:h>"#);
|
||||
let mut d = in_custom_style(&styles, &body);
|
||||
let check = |saved: &[u8], what: &str| {
|
||||
let c = crate::odt::tests::content_of(saved);
|
||||
assert!(c.contains("<text:list"), "level {level}, {what}: {c}");
|
||||
};
|
||||
check(&crate::odt::tests::export_model(&d).unwrap(), "from the model");
|
||||
let id = d.body[0].as_para().unwrap().props.style.clone().unwrap();
|
||||
Arc::make_mut(&mut d.styles).get_mut(&id).unwrap().chr.italic = Some(true);
|
||||
let saved = export(&d).unwrap();
|
||||
check(&saved, "style edited");
|
||||
let back = import(&saved).unwrap();
|
||||
let p = back.body[0].as_para().unwrap();
|
||||
let n = p.props.numbering.or_else(|| back.styles.para_style_props(p.props.style.as_deref().unwrap_or("Normal")).0.numbering);
|
||||
assert_eq!(n.map(|n| n.level), Some(level - 1), "level {level}, reopened");
|
||||
}
|
||||
}
|
||||
|
||||
/// A style at an unnumbered level with a heading numbered by its own level stays on the outline,
|
||||
/// or LibreOffice shows that heading no number; with none, it comes off, for the level's indent.
|
||||
#[test]
|
||||
fn a_style_with_a_heading_numbered_by_its_own_level_stays_on_the_outline() {
|
||||
let styles = format!(
|
||||
r#"<style:style style:name="Low" style:family="paragraph" style:parent-style-name="Standard" style:default-outline-level="3"/><style:style style:name="Heading_20_3" style:display-name="Heading 3" style:family="paragraph" style:default-outline-level="3"/>{NUMBERED}"#
|
||||
);
|
||||
let saved = |body: &str| crate::odt::tests::styles_of(&crate::odt::tests::export_model(&in_custom_style(&styles, body)).unwrap());
|
||||
let style_of = |xml: &str, name: &str| {
|
||||
xml.split("<style:style ").find(|x| x.starts_with(&format!(r#"style:name="{name}""#))).map(String::from).unwrap_or_default()
|
||||
};
|
||||
let xml = saved(
|
||||
r#"<text:h text:style-name="Low" text:outline-level="1">a</text:h><text:h text:style-name="Heading_20_3" text:outline-level="2">b</text:h>"#,
|
||||
);
|
||||
assert!(!style_of(&xml, "Low").contains("style:list-style-name"), "{xml}");
|
||||
assert!(!style_of(&xml, "Heading_20_3").contains("style:list-style-name"), "{xml}");
|
||||
let xml = saved(r#"<text:h text:style-name="Low" text:outline-level="3">a</text:h>"#);
|
||||
assert!(style_of(&xml, "Low").contains(r#"style:list-style-name="""#), "{xml}");
|
||||
}
|
||||
|
||||
@@ -322,7 +322,7 @@ impl Writer {
|
||||
/// The paragraph style of `p`; `start` makes it begin a page of that master page (ODF 1.3
|
||||
/// §19.471 `style:master-page-name`), restarting page numbering where asked (§20.322).
|
||||
fn para_style_at(&mut self, p: &Para, start: Option<&SecStart>) -> String {
|
||||
let named = p.extra.as_ref().and_then(|x| x.style.as_deref()).filter(|_| matches!(p.kind, Kind::Normal | Kind::Rule));
|
||||
let named = p.extra.as_ref().and_then(|x| x.style.as_deref());
|
||||
let parent = match (p.kind, self.note_parent, named) {
|
||||
// A custom style: written as a common style of the same name (see `custom_styles`).
|
||||
(_, _, Some(id)) => {
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user