Skip to content

⚙️ Extract shared PandocArgs builder for consistent pandoc command construction#132

Merged
szmyty merged 2 commits intomainfrom
copilot/extract-shared-pandocargs-builder
Mar 27, 2026
Merged

⚙️ Extract shared PandocArgs builder for consistent pandoc command construction#132
szmyty merged 2 commits intomainfrom
copilot/extract-shared-pandocargs-builder

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 26, 2026

Each output strategy (HTML, PDF, DOCX) was independently constructing pandoc argument lists — duplicating --from, input path, and -o boilerplate with no shared abstraction.

Changes

  • New PandocArgs builder (src/strategies/pandoc_args.rs) — centralises all pandoc arg construction:
    • new(input_format, input_path, output_path) — mandatory base args
    • with_template(path)--template <path> (HTML, PDF)
    • with_pdf_engine(engine)--pdf-engine=<engine> (PDF)
    • with_reference_doc(path)--reference-doc <path> (DOCX)
    • build() -> Vec<String> — emits the final arg list
  • Strategies refactored (html.rs, pdf.rs, docx.rs) to use the builder via immutable match-chaining rather than mut reassignment
  • PandocArgs re-exported from strategies/mod.rs

Usage

// PDF strategy
let builder = PandocArgs::new(ctx.input_format.as_pandoc_format(), ctx.input_path, ctx.output_path)
    .with_pdf_engine("tectonic");
let args = match template_path {
    Some(ref path) => builder.with_template(path.as_str()),
    None => builder,
}
.build();
let args_refs: Vec<&str> = args.iter().map(String::as_str).collect();
run_command("pandoc", &args_refs)?;

💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.

Copilot AI changed the title [WIP] Refactor duplicated Pandoc argument construction into shared builder ⚙️ Extract shared PandocArgs builder for consistent pandoc command construction Mar 26, 2026
Copilot AI requested a review from szmyty March 26, 2026 18:38
@szmyty szmyty marked this pull request as ready for review March 27, 2026 00:55
@szmyty szmyty merged commit cd48596 into main Mar 27, 2026
@devactivity-app
Copy link
Copy Markdown

Pull Request Summary by devActivity

Metrics

Cycle Time: 6h 26m Coding Time: < 1 min Pickup Time: 6h 16m Review Time: < 1 min

Achievements

@szmyty szmyty deleted the copilot/extract-shared-pandocargs-builder branch March 27, 2026 00:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants