mirror of
https://github.com/storytold/deckcraft.git
synced 2026-10-24 18:46:57 -06:00
Keep multi-paragraph slide titles on one line in outline export
Found while testing crates/format/src/lib.rs:490 Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Haiku 5.5
parent
1b64de3499
commit
b6af19ae35
@@ -492,7 +492,8 @@ pub fn markdown_to_slides(p: &mut Presentation, text: &str) -> usize {
|
||||
pub fn slides_to_outline(p: &Presentation) -> String {
|
||||
let mut out = String::new();
|
||||
for s in &p.slides {
|
||||
out.push_str(&s.title());
|
||||
// One line per title: a newline would start another slide on re-import.
|
||||
out.push_str(&s.title().replace('\n', " "));
|
||||
out.push('\n');
|
||||
for sh in &s.shapes {
|
||||
if sh.ph_type().is_some_and(|k| k.is_title()) {
|
||||
@@ -832,6 +833,18 @@ mod tests {
|
||||
assert!(o.contains("-5 °C tonight\n\t--verbose flag\n\t*args and **kwargs\nBullets\n\tPoint\n\tOther"), "{o}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn outline_export_keeps_multi_paragraph_title_on_one_line() {
|
||||
let mut p = defaults::blank_presentation(defaults::WIDE, Default::default(), false);
|
||||
assert_eq!(outline_to_slides(&mut p, "Intro\n\tPoint one\nSecond\n\tMore"), 2);
|
||||
let title = Arc::make_mut(&mut p.slides[0]).shapes.iter_mut().find(|s| s.ph_type().is_some_and(|k| k.is_title())).expect("title placeholder");
|
||||
title.text = Some(TextBody::from_text("Line one\nLine two"));
|
||||
let o = slides_to_outline(&p);
|
||||
assert_eq!(o, "Line one Line two\n\tPoint one\nSecond\n\tMore\n");
|
||||
let mut q = defaults::blank_presentation(defaults::WIDE, Default::default(), false);
|
||||
assert_eq!(outline_to_slides(&mut q, &o), 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn markdown_headings_and_list_items() {
|
||||
assert_eq!(md_heading("# Intro"), Some("Intro"));
|
||||
|
||||
Reference in New Issue
Block a user