sabbath_school_reproducer.generator package

Submodules

sabbath_school_reproducer.generator.css_styles module

CSS Styles for Sabbath School Lessons PDF

This module defines the CSS styles used in the generated PDF.

class sabbath_school_reproducer.generator.css_styles.CssUpdater[source]

Bases: object

Handles CSS style updates with dynamic content based on configuration.

static apply_color_theme(css_template, color_theme)[source]

Apply color theme to CSS template

Parameters:
  • css_template (str) – Original CSS template string

  • color_theme (dict) – Color theme dictionary

Returns:

Updated CSS template with applied color theme

Return type:

str

static get_quarter_display(config)[source]

Get the formatted quarter and year display

Parameters:

config (dict) – Configuration dictionary

Returns:

Formatted quarter display

Return type:

str

static load_color_theme(theme_path)[source]

Load color theme from a YAML file

Parameters:

theme_path (str) – Path to the color theme YAML file

Returns:

Color theme dictionary or None if file not found

Return type:

dict

static update_css_template(css_template, config, lesson_data=None)[source]

Update CSS template with configuration data and color theme

Parameters:
  • css_template (str) – Original CSS template string

  • config (dict) – Configuration dictionary

  • lesson_data (dict, optional) – Optional lesson data dictionary

Returns:

Updated CSS template string

Return type:

str

sabbath_school_reproducer.generator.html_generator module

class sabbath_school_reproducer.generator.html_generator.HtmlGenerator[source]

Bases: object

Generates HTML content for PDF generation with incremental approach.

static add_section(content_parts, dynamic_css, state, section_name, section_html, start_on_odd=True, reset_counter=False)[source]

Adds a section to the document, ensuring it starts on the correct page

Parameters:
  • content_parts (list) – List of HTML content parts

  • dynamic_css (str) – CSS content with modifications

  • state (dict) – Current state tracking page numbers, etc.

  • section_name (str) – Name of the section for comments

  • section_html (str) – HTML content for the section

  • start_on_odd (bool) – Whether section should start on odd-numbered page

  • reset_counter (bool) – Whether to reset page counter for this section

Returns:

(updated content_parts, updated dynamic_css, updated state)

Return type:

tuple

static convert_markdown_to_html(markdown_content)[source]

Convert markdown to HTML with table support

Parameters:

markdown_content (str) – Markdown content

Returns:

HTML content

Return type:

str

static create_back_cover(back_cover_svg_path=None)[source]

Creates the back cover page HTML using the SVG from file if provided

Parameters:

back_cover_svg_path (str, optional) – Path to back cover SVG

Returns:

HTML for back cover

Return type:

str

static create_backmatter_html(backmatter_content)[source]

Creates HTML for the back matter section with table support

Parameters:

backmatter_content (str) – Back matter markdown content

Returns:

HTML for back matter

Return type:

str

static create_cover_page(front_cover_svg_path=None, config=None)[source]

Creates the cover page HTML using the SVG from file if provided

Parameters:
  • front_cover_svg_path (str, optional) – Path to front cover SVG

  • config (dict, optional) – Configuration dictionary

Returns:

HTML for cover page

Return type:

str

static create_debug_html_with_css(content_parts, dynamic_css)[source]

Creates HTML with current content parts and CSS

Parameters:
  • content_parts (list) – List of HTML content parts

  • dynamic_css (str) – CSS content with modifications

Returns:

Complete HTML string

Return type:

str

static create_frontmatter_html(frontmatter_content)[source]

Creates HTML for the front matter section with table support

Parameters:

frontmatter_content (str) – Front matter markdown content

Returns:

HTML for front matter

Return type:

str

static create_lesson_html(lesson, language_code='en')[source]

Creates HTML for a single lesson with improved formatting for title and date

Parameters:
  • lesson (dict) – Lesson dictionary

  • language_code (str) – Language code for translations

Returns:

HTML for lesson

Return type:

str

static create_table_of_contents(lessons, language_code='en', config=None)[source]

Creates the table of contents HTML with links to lessons

Parameters:
  • lessons (list) – List of lesson dictionaries

  • language_code (str) – Language code for translations

  • config (dict, optional) – Configuration dictionary containing language_config_path

Returns:

HTML for table of contents

Return type:

str

static fix_markdown_lists(markdown_content)[source]

Fix markdown list rendering by indenting all non-numbered list item lines, but only if at least one numbered list item exists in the content.

Parameters:

markdown_content (str) – Markdown content with or without numbered lists

Returns:

Fixed markdown content with proper indentation for list continuity

Return type:

str

static generate_html(content_data, front_cover_svg_path=None, back_cover_svg_path=None, config=None)[source]

Generate complete HTML document from content data with incremental approach

Parameters:
  • content_data (dict) – Dictionary with content data

  • front_cover_svg_path (str, optional) – Path to front cover SVG

  • back_cover_svg_path (str, optional) – Path to back cover SVG

  • config (dict, optional) – Configuration dictionary

Returns:

Complete HTML document

Return type:

str

static get_quarter_display(quarter, language_code='en')[source]

Get a formatted display for the quarter

Parameters:
  • quarter (str) – Quarter code (e.g., q1, q2, q3, q4)

  • language_code (str) – Language code for translations

Returns:

Formatted quarter display

Return type:

str

static read_svg_file(filepath)[source]

Read SVG file content from the specified path

Parameters:

filepath (str) – Path to SVG file

Returns:

SVG content or None if error

Return type:

str or None

sabbath_school_reproducer.generator.pdf_generator module

PDF Generator for Sabbath School Lessons

This module handles the final conversion from HTML to PDF with specific pagination fixes.

class sabbath_school_reproducer.generator.pdf_generator.PdfGenerator[source]

Bases: object

Handles conversion of HTML to PDF with pagination control.

static add_css_for_pagination(output_path)[source]

Create a CSS file with pagination rules

Parameters:

output_path (str) – Directory to save the CSS file

Returns:

Path to the generated CSS file

Return type:

str

static count_pages_in_document(document)[source]

Count the number of pages in a WeasyPrint document

Parameters:

document (Document) – WeasyPrint document

Returns:

Number of pages

Return type:

int

static create_blank_page_pdf(output_path)[source]

Generate a blank page PDF

Parameters:

output_path (str) – Path to save the blank page PDF

Returns:

Path to the generated PDF

Return type:

str

static create_section_document(html_content)[source]

Create a WeasyPrint document for a section

Parameters:

html_content (str) – HTML content

Returns:

WeasyPrint document

Return type:

Document

static generate_pdf(html_content, output_pdf, config=None)[source]

Converts HTML content to PDF with targeted pagination fixes

Parameters:
  • html_content (str) – The complete HTML document

  • output_pdf (str) – Path to save the PDF file

  • config (dict, optional) – Configuration dictionary

Returns:

Path to the generated PDF

Return type:

str

sabbath_school_reproducer.generator.svg_updater module

Dynamic SVG Updater for Sabbath School Lessons

This module updates SVG files with dynamic content based on configuration.

class sabbath_school_reproducer.generator.svg_updater.SvgUpdater[source]

Bases: object

Updates SVG files with dynamic content based on configuration.

QUARTER_MONTHS = {'q1': 'January - March', 'q2': 'April - June', 'q3': 'July - September', 'q4': 'October - December'}
QUARTER_NAMES = {'q1': 'FIRST QUARTER', 'q2': 'SECOND QUARTER', 'q3': 'THIRD QUARTER', 'q4': 'FOURTH QUARTER'}
static get_quarter_title(config, lesson_data)[source]

Get the quarter title from either config or lesson data

Parameters:
  • config (dict) – Configuration dictionary

  • lesson_data (dict) – Lesson data dictionary

Returns:

Quarter title

Return type:

str

static update_svg_with_config(svg_path, config, lesson_data=None, is_temporary=False)[source]

Update SVG file with configuration data

Parameters:
  • svg_path (str) – Path to SVG file

  • config (dict) – Configuration dictionary

  • lesson_data (dict, optional) – Optional lesson data dictionary

  • is_temporary (bool) – Whether this is a temporary file

Returns:

Path to updated SVG file

Return type:

str

Module contents

PDF Generator package for Sabbath School Lessons.

This package contains modules for generating HTML, CSS, and PDF files.