---
title: "End-to-End Workflow"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{End-to-End Workflow}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(collapse = TRUE, comment = "#>")
```

## Overview

authordown standardizes author metadata and produces common manuscript sections. This vignette uses bundled example data so it can run offline and deterministically.

## Load example data

```{r}
library(authordown)

csv_path <- system.file("extdata", "authordown_template.csv", package = "authordown")
authors <- authordown_read_local(csv_path)
```

If you want a fresh template in a temporary file:

```{r}
csv_path <- authordown_template()
authors <- authordown_read_local(csv_path)
unlink(csv_path)
```

## Title page

```{r}
title_page <- generate_title_page(
  data = authors,
  title = "Example Paper",
  style = "default",
  show_degree = TRUE
)
cat(title_page)
```

## Acknowledgements, conflict, and contributions

```{r}
ack <- generate_acknowledgement(authors, style = "paragraph")
coi <- generate_conflict(authors, style = "paragraph")
contrib <- generate_contribution(authors, style = "bullets")

cat(ack)
cat("\n\n")
cat(coi)
cat("\n\n")
cat(contrib)
```

## XLSX input

```{r}
xlsx_path <- system.file("extdata", "authordown_template.xlsx", package = "authordown")
authors_xlsx <- authordown_read_local(xlsx_path)
```

## Online tables (export to local file first)

If you manage authors in an online table, export it locally and read the file.

1) Export to CSV or XLSX (or TSV).
2) Read locally with `authordown_read_local()`.

Supported formats: CSV, TSV, XLSX.

## Affiliations

Use `Affiliation1`, `Affiliation2`, ... `AffiliationN` columns to list all
affiliations for each author. There is no hard limit; add as many columns as
needed. The title page numbers affiliations in the order they first appear.

## Troubleshooting

- Missing required columns means your input does not include required fields such as `FirstName` and `LastName`.
- Corresponding authors must have an Email means a row has `Corresponding = TRUE` but `Email` is blank.
- ORCID values must match `0000-0000-0000-0000` format.

## Render sections for copy/paste

If you want HTML for clean copy/paste into a manuscript system, use `render_section_html()`:

```{r, eval=FALSE}
html_path <- render_section_html(
  section_title = "Conflict of Interest",
  content_function = generate_conflict,
  data = authors,
  style = "paragraph"
)
```
