From 339ecdbfb344e767ebdd1b1382fd5ba7ac06dd5a Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Thu, 11 Apr 2024 12:29:36 -0700 Subject: [PATCH] Integration test cleanup (#612) --- test_integration/bin/slide_notes.dart | 53 +++++++++++++++++---------- 1 file changed, 33 insertions(+), 20 deletions(-) diff --git a/test_integration/bin/slide_notes.dart b/test_integration/bin/slide_notes.dart index c47e079ef..4fc376397 100644 --- a/test_integration/bin/slide_notes.dart +++ b/test_integration/bin/slide_notes.dart @@ -208,31 +208,44 @@ Iterable _printSlides(List pages, {int? lastSlide}) sync* { extension on Page { Iterable get noteLines sync* { final elements = slideProperties?.notesPage?.pageElements; - if (elements != null) { - for (var element in elements) { - final text = element.shape?.text; - if (text != null) { - final value = text.textElements! - .map((e) => e.textRun?.content) - .whereType() - .where((element) => element.isNotEmpty) - .join() - .trim(); - - if (value.isNotEmpty) { - // `value` may contain sections split by new-lines. Turn these into - // individual returned "lines" removing extra whitespace and - // blank lines - yield* LineSplitter.split(value) - .map((line) => line.trim()) - .where((line) => line.isNotEmpty); - } - } + + if (elements == null) { + return; + } + + for (var element in elements) { + final text = element.shape?.text; + if (text == null) { + return; } + + yield* text.lines; } } } +extension on TextContent { + Iterable get lines sync* { + final value = textElements! + .map((e) => e.textRun?.content) + .whereType() + .where((element) => element.isNotEmpty) + .join() + .trim(); + + if (value.isEmpty) { + return; + } + + // `value` may contain sections split by new-lines. Turn these into + // individual returned "lines" removing extra whitespace and + // blank lines + yield* LineSplitter.split(value) + .map((line) => line.trim()) + .where((line) => line.isNotEmpty); + } +} + final _parser = ArgParser() ..addOption('last-slide') ..addOption('html', help: 'HTML file to write content.');