---
title: "Importing a (pre)registration from embedded JSON from a URL"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Importing a (pre)registration from embedded JSON from a URL}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
```

The `preregr` vignettes are themselves RMarkdown files. Therefore, the human-readable (pre-)registrations shown there as an example also caused the corresponding JSON to be embedded in those vignettes.

This command imports this information from the `preregr` Pkgdown website:

```{r}
importedExample <-
  preregr::import_from_html("https://preregr.opens.science/articles/specifying_prereg_content.html");
```

We can then show the result:

```{r}
importedExample;
```

Or knit it into this vignette (which will then again also embed it as JSON, which can be imported again, etc):

```{r}
preregr::prereg_knit_item_content(
  importedExample,
  section="metadata"
);
```

# Initializing a new (pre)registration with the for used by an imported (pre)registration

It is also possible to initialize a new preregistration, using the form that was saved along with the preregistered content:

```{r}
freshPrereg <-
  preregr::prereg_initialize(
    importedExample
  );
```

This yields an empty preregistration specification:

```{r}
freshPrereg;
```

This way, it's easy to initialize a preregistration based on the form used by somebody else.
