Title: | R Interface for 'TiddlyWiki' |
---|---|
Description: | 'TiddlyWiki' is a unique non-linear notebook for capturing, organising and sharing complex information. 'rtiddlywiki' is a R interface of 'TiddlyWiki' <https://tiddlywiki.com> to create new tiddler from Rmarkdown file, and then put into a local 'TiddlyWiki' node.js server if it is available. |
Authors: | Bangyou Zheng |
Maintainer: | Bangyou Zheng <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.3.0 |
Built: | 2025-03-04 05:25:19 UTC |
Source: | https://github.com/byzheng/rtiddlywiki |
Delete a tiddler
delete_tiddler(title, bag = TW_OPTIONS("bag"))
delete_tiddler(title, bag = TW_OPTIONS("bag"))
title |
title of the tiddler to retrieve |
bag |
string defining which recipe to write to (optional, defaults to "default") |
no return values
## Not run: delete_tiddler("GettingStarted") ## End(Not run)
## Not run: delete_tiddler("GettingStarted") ## End(Not run)
Get server status
get_status()
get_status()
a list of service status
Get a tiddler
get_tiddler(title, recipe = TW_OPTIONS("recipe"))
get_tiddler(title, recipe = TW_OPTIONS("recipe"))
title |
title of the tiddler to retrieve |
recipe |
string defining which recipe to read from (optional, defaults to "default") |
tiddler information in JSON format
## Not run: get_tiddler("GettingStarted") ## End(Not run)
## Not run: get_tiddler("GettingStarted") ## End(Not run)
Get all tiddlers
get_tiddlers(filter = NULL, exclude = NULL, recipe = TW_OPTIONS("recipe"))
get_tiddlers(filter = NULL, exclude = NULL, recipe = TW_OPTIONS("recipe"))
filter |
filter identifying tiddlers to be returned (optional, defaults to "[all[tiddlers]!is[system]sort[title]]") |
exclude |
comma delimited list of fields to excluded from the returned tiddlers (optional, defaults to "text") |
recipe |
string defining which recipe to read from (optional, defaults to "default") |
all tiddlers information in JSON format
## Not run: #' Get all tiddlers get_tiddlers() ## End(Not run)
## Not run: #' Get all tiddlers get_tiddlers() ## End(Not run)
Put a tiddler
put_tiddler( title, text, type = c("text/vnd.tiddlywiki", "text/x-tiddlywiki", "text/x-markdown", "text/html", "text/plain", "application/json"), tags = NULL, fields = NULL, recipe = TW_OPTIONS("recipe") )
put_tiddler( title, text, type = c("text/vnd.tiddlywiki", "text/x-tiddlywiki", "text/x-markdown", "text/html", "text/plain", "application/json"), tags = NULL, fields = NULL, recipe = TW_OPTIONS("recipe") )
title |
tiddler title |
text |
tiddler text |
type |
tiddler type |
tags |
tiddler tags which is merged with existing tags |
fields |
a named vector for tiddler fields which is merged with existing tags |
recipe |
string defining which recipe to write to (optional, defaults to "default") |
No return value
## Not run: title <- "New tiddler" text <- c("!! Section", "This is a new tiddler") type <- "text/vnd.tiddlywiki" tags <- c("Tag1", "Tag 2") fields <- c("F1" = "V1", "F2" = "V2") put_tiddler(title = title, text = text, type = type, tags = tags, fields = fields) ## End(Not run)
## Not run: title <- "New tiddler" text <- c("!! Section", "This is a new tiddler") type <- "text/vnd.tiddlywiki" tags <- c("Tag1", "Tag 2") fields <- c("F1" = "V1", "F2" = "V2") put_tiddler(title = title, text = text, type = type, tags = tags, fields = fields) ## End(Not run)
This function parses a table written in TiddlyWiki format and converts it into an R data frame. It can optionally treat the first row as a header.
read_table(table, header = TRUE)
read_table(table, header = TRUE)
table |
A character string representing the TiddlyWiki table. |
header |
A logical value indicating whether the first row should be treated as column headers. Default is TRUE. |
A data frame containing the parsed table data.
table <- "|!Cell1 |!Cell2 |\n|Cell3 |Cell4 |" df <- read_table(table, header = TRUE) print(df)
table <- "|!Cell1 |!Cell2 |\n|Cell3 |Cell4 |" df <- read_table(table, header = TRUE) print(df)
Remove fields from tiddlers
remove_fields(title, fields, recipe = TW_OPTIONS("recipe"))
remove_fields(title, fields, recipe = TW_OPTIONS("recipe"))
title |
tiddler title |
fields |
fields to remove |
recipe |
string defining which recipe to write to (optional, defaults to "default") |
no return value
Save ggplot into base64
save_base64(plot, width = 5, height = 4, dpi = 300)
save_base64(plot, width = 5, height = 4, dpi = 300)
plot |
object for ggplot2 |
width |
image width |
height |
image height |
dpi |
image resolution |
character string for base64 image
library(ggplot2) p <- cars |> ggplot() + geom_point(aes(speed, dist)) p |> save_base64()
library(ggplot2) p <- cars |> ggplot() + geom_point(aes(speed, dist)) p |> save_base64()
Split tiddlywiki field into values
split_field(s)
split_field(s)
s |
a string |
an vector of values
This function creates a tabbed interface where each tab has dynamically generated content.
tabs(names, fun, groupname = .unique_name(), checked = 1, ...)
tabs(names, fun, groupname = .unique_name(), checked = 1, ...)
names |
A character vector of tab labels. |
fun |
A function that generates the content for each tab. It must take an index ('i') as the first argument. |
groupname |
A unique string to group the radio inputs (default is generated automatically). |
checked |
The index of the tab that should be pre-selected (default is '1'). |
... |
Additional arguments passed to 'fun'. |
An 'htmltools::tagList' containing the tabbed interface.
tab_labels <- c("Tab1", "Tab2", "Tab3") tab_content_fun <- function(i, extra_text = "") { htmltools::tagList( htmltools::tags$p(paste("Content for tab:", tab_labels[i], extra_text)), htmltools::tags$img(src = paste0("plot_", i, ".png"), width = "100%") ) } tabs(tab_labels, tab_content_fun, checked = 2, extra_text = "Additional details")
tab_labels <- c("Tab1", "Tab2", "Tab3") tab_content_fun <- function(i, extra_text = "") { htmltools::tagList( htmltools::tags$p(paste("Content for tab:", tab_labels[i], extra_text)), htmltools::tags$img(src = paste0("plot_", i, ".png"), width = "100%") ) } tabs(tab_labels, tab_content_fun, checked = 2, extra_text = "Additional details")
Format for converting from R Markdown to another tiddler markdown
tiddler_document( host = NULL, tags = NULL, fields = NULL, use_bookdown = FALSE, overwrite = FALSE, variant = "gfm", pandoc_args = "--wrap=none", ... )
tiddler_document( host = NULL, tags = NULL, fields = NULL, use_bookdown = FALSE, overwrite = FALSE, variant = "gfm", pandoc_args = "--wrap=none", ... )
host |
the host of tiddlywiki web server |
tags |
tiddler tags |
fields |
a named vector for tiddler fields |
use_bookdown |
logical. Use bookdown to generate markdown file. |
overwrite |
whether to overwrite the existing tiddler. |
variant |
variant for md_document |
pandoc_args |
pandoc_args for md_document |
... |
Other argument pass to md_document |
R Markdown output format to pass to render()
## Not run: library(rmarkdown) render("input.Rmd") ## End(Not run)
## Not run: library(rmarkdown) render("input.Rmd") ## End(Not run)
Generate tiddler in json format
tiddler_json( title, text, type = c("text/vnd.tiddlywiki", "text/x-tiddlywiki", "text/x-markdown", "text/html", "text/plain", "application/json"), tags = NULL, fields = NULL, format = c("json", "list") )
tiddler_json( title, text, type = c("text/vnd.tiddlywiki", "text/x-tiddlywiki", "text/x-markdown", "text/html", "text/plain", "application/json"), tags = NULL, fields = NULL, format = c("json", "list") )
title |
tiddler title |
text |
tiddler text |
type |
tiddler type |
tags |
a vector for tiddler tags |
fields |
a named vector for tiddler fields. |
format |
export format as json or list |
New tiddler in json format
Generate tiddler in json format
tiddler_json2(tiddler)
tiddler_json2(tiddler)
tiddler |
A list for new tiddler |
New tiddler in json format
Set or get options for my package
tw_options(...)
tw_options(...)
... |
Option names to retrieve option values or |
the default and modified options.
The following options are supported host: Host of tiddlywiki recipe: Recipes are named lists of bags, ordered from lowest priority to highest bag: Bags have access controls that determines which users can read or write to them
tw_options(host = "http://127.0.0.1:8080/")
tw_options(host = "http://127.0.0.1:8080/")
Reset global options for pkg
tw_reset()
tw_reset()
the default options
tw_options()
tw_options()
Convert data.frame into table of TiddlyWiki
tw_table(df, collapse = "\n")
tw_table(df, collapse = "\n")
df |
data.frame object |
collapse |
an optional character string to separate the results. |
character string for table in TiddlyWiki
cars |> dplyr::slice(1:10) |> tw_table()
cars |> dplyr::slice(1:10) |> tw_table()
Create a tiddlywiki widget from htmlwidget
tw_widget(widget, is_cat = FALSE)
tw_widget(widget, is_cat = FALSE)
widget |
an object of htmlwidget |
is_cat |
whether to show results on screen |
a new tiddlywiki widget
library(leaflet) content <- paste(sep = "<br/>", "<b><a href='http://www.samurainoodle.com'>Samurai Noodle</a></b>", "606 5th Ave. S", "Seattle, WA 98138" ) widget <- leaflet() %>% addTiles() %>% addPopups(-122.327298, 47.597131, content, options = popupOptions(closeButton = FALSE) ) tw_widget(widget)
library(leaflet) content <- paste(sep = "<br/>", "<b><a href='http://www.samurainoodle.com'>Samurai Noodle</a></b>", "606 5th Ave. S", "Seattle, WA 98138" ) widget <- leaflet() %>% addTiles() %>% addPopups(-122.327298, 47.597131, content, options = popupOptions(closeButton = FALSE) ) tw_widget(widget)
backticks for wikitext
wikitext_backticks_return(x)
wikitext_backticks_return(x)
x |
character vector |
By default this function outputs (see: cat
) the result. Call the function ending in .return
to catch the result instead.
wikitext_backticks('FOO') wikitext_backticks_return('FOO')
wikitext_backticks('FOO') wikitext_backticks_return('FOO')
This function converts a Word ('.docx') file to Markdown using Pandoc. Optionally, it embeds images as Base64 for a self-contained Markdown file.
word_to_md( docx_file, output_file = NULL, embed_images = FALSE, overwrite = FALSE )
word_to_md( docx_file, output_file = NULL, embed_images = FALSE, overwrite = FALSE )
docx_file |
Path to the input Word file. |
output_file |
Path to the final Markdown output file. If null, the original file name. |
embed_images |
Logical. If 'TRUE', all images will be embedded as Base64. Default is 'FALSE'. |
overwrite |
Logical. If 'TRUE', Output file is overwrote. Default is 'FALSE' |
Saves a Markdown file (optionally with Base64-embedded images).
# Convert Word to Markdown without embedding images ## Not run: convert_word_to_markdown("input.docx", "output.md", embed_images = FALSE) # Convert and embed images as Base64 convert_word_to_markdown("input.docx", "output_embedded.md", embed_images = TRUE) ## End(Not run)
# Convert Word to Markdown without embedding images ## Not run: convert_word_to_markdown("input.docx", "output.md", embed_images = FALSE) # Convert and embed images as Base64 convert_word_to_markdown("input.docx", "output_embedded.md", embed_images = TRUE) ## End(Not run)