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

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

```{r setup}
library(rtiddlywiki)
```

## Use rtiddlywiki with Rmarkdown

To use `rtiddlywiki` with Rmarkdown, you can add an output format in the `yaml` header with following configurations. All arguments of `rmarkdown::md_document` or `bookdown::markdown_document2` (if `use_bookdown: true`) can also be specified. 

```yaml
output:
  rtiddlywiki::tiddler_document:
    tags: ["tag1", "tag 2"]
    use_bookdown: false
    fields:
      "field1": "V1"
      "field 2": "Value 2"
```

`tags` is converted into `tag` for tiddler. `fields` is a named vector and converted into fields for tiddler (i.e. name and value pair). A `json` file is generated in the output folder and can be imported into single `tiddlywiki` html file. 


For `tiddlywki` configured with [node.js server](https://tiddlywiki.com/static/Installing%2520TiddlyWiki%2520on%2520Node.js.html), the `path` and `host` can be specified in the `yaml` header to `PUT` into `WebServer`.


```yaml
output:
  rtiddlywiki::tiddler_document:
    path: "full-path-to-tiddlywiki-project"
    host: "http://127.0.0.1:8080/"
    tags: ["tag1", "tag 2"]
    use_bookdown: false
    fields:
      "field1": "V1"
      "field 2": "Value 2"
```







