From 484195d6f27c37053b77822330a73359e00cd254 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 15 Dec 2025 18:29:26 +0100 Subject: fixup --- src/html_formatter.cc | 19 ++++++++++++++++--- src/html_formatter.h | 2 +- src/pdf_formatter.cc | 7 ++++++- src/pdf_formatter.h | 2 +- src/text_formatter.cc | 8 +++++++- src/text_formatter.h | 2 +- 6 files changed, 32 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/html_formatter.cc b/src/html_formatter.cc index 0e796cc3..6b5930d2 100644 --- a/src/html_formatter.cc +++ b/src/html_formatter.cc @@ -23,7 +23,9 @@ #include +using std::string; using std::unique_ptr; +using std::vector; using namespace dcp; @@ -95,13 +97,24 @@ HTMLFormatter::unordered_list() void -HTMLFormatter::list_item(std::string const& text, boost::optional type) +HTMLFormatter::list_item(std::string const& text, boost::optional type, vector const& details) { if (type) { - _file.puts(dcp::String::compose("
  • %2
  • \n", *type, text).c_str()); + _file.puts(dcp::String::compose("
  • %2", *type, text).c_str()); } else { - _file.puts(dcp::String::compose("
  • %1
  • \n", text).c_str()); + _file.puts(dcp::String::compose("
  • %1", text).c_str()); } + + if (!details.empty()) + { + _file.puts("
      \n"); + for (auto const& detail: details) { + _file.puts(fmt::format("
    1. {}", detail).c_str()); + } + _file.puts("
    \n"); + } + + _file.puts("
  • \n"); } diff --git a/src/html_formatter.h b/src/html_formatter.h index 2f87a758..2261bfb1 100644 --- a/src/html_formatter.h +++ b/src/html_formatter.h @@ -36,7 +36,7 @@ public: std::unique_ptr document() override; std::unique_ptr body() override; std::unique_ptr unordered_list() override; - void list_item(std::string const& text, boost::optional type = {}) override; + void list_item(std::string const& text, boost::optional type = {}, std::vector const& details = {}) override; std::function process_string() override; std::function fixed_width() override; diff --git a/src/pdf_formatter.cc b/src/pdf_formatter.cc index 0ec77c4b..3e4e5c09 100644 --- a/src/pdf_formatter.cc +++ b/src/pdf_formatter.cc @@ -24,7 +24,9 @@ #include +using std::string; using std::unique_ptr; +using std::vector; using namespace dcp; @@ -234,7 +236,7 @@ PDFFormatter::wrapped_text(float x, float first_line_indent, float font_size, dc void -PDFFormatter::list_item(std::string const& text, boost::optional type) +PDFFormatter::list_item(std::string const& text, boost::optional type, vector const& details) { float const indent = 16 * _indent; float constexpr dot_radius = 1.5; @@ -253,6 +255,9 @@ PDFFormatter::list_item(std::string const& text, boost::optional ty } wrapped_text(indent, dot_radius * 6, font_size, colour, text, (page_width - horizontal_margin * 2) * dpi, font_size * 1.2); + for (auto const& detail: details) { + wrapped_text(indent + 16, dot_radius * 6, font_size, colour, text, (page_width - horizontal_margin * 2) * dpi, font_size * 1.2); + } } diff --git a/src/pdf_formatter.h b/src/pdf_formatter.h index b7d0213d..d20e4ded 100644 --- a/src/pdf_formatter.h +++ b/src/pdf_formatter.h @@ -53,7 +53,7 @@ public: void heading(std::string const& text) override; void subheading(std::string const& text) override; std::unique_ptr unordered_list() override; - void list_item(std::string const& text, boost::optional type = {}) override; + void list_item(std::string const& text, boost::optional type = {}, std::vector const& details = {}) override; std::function process_string() override; std::function fixed_width() override; void finish() override; diff --git a/src/text_formatter.cc b/src/text_formatter.cc index a147ea83..55f2e84d 100644 --- a/src/text_formatter.cc +++ b/src/text_formatter.cc @@ -22,7 +22,9 @@ #include "text_formatter.h" +using std::string; using std::unique_ptr; +using std::vector; using namespace dcp; @@ -57,7 +59,7 @@ TextFormatter::unordered_list() void -TextFormatter::list_item(std::string const& text, boost::optional type) +TextFormatter::list_item(std::string const& text, boost::optional type, vector const& details) { LIBDCP_UNUSED(type); for (int i = 0; i < _indent * 2; ++i) { @@ -65,6 +67,10 @@ TextFormatter::list_item(std::string const& text, boost::optional t } _file.puts("* "); print(text); + for (auto const& detail: details) { + _file.puts(" - "); + print(detail); + } } diff --git a/src/text_formatter.h b/src/text_formatter.h index 8fdb0d89..d0442959 100644 --- a/src/text_formatter.h +++ b/src/text_formatter.h @@ -34,7 +34,7 @@ public: void heading(std::string const& text) override; void subheading(std::string const& text) override; std::unique_ptr unordered_list() override; - void list_item(std::string const& text, boost::optional type = {}) override; + void list_item(std::string const& text, boost::optional type = {}, std::vector const& details = {}) override; std::function process_string() override; std::function fixed_width() override; -- cgit v1.2.3