## ----setup, include=FALSE----------------------------------------------------- knitr::opts_chunk$set(echo = TRUE, collapse = TRUE, comment = "#>") library(parsermd) ## ----------------------------------------------------------------------------- ast = rmd_ast(list( rmd_yaml(list(title = "Example Document")), rmd_heading(name = "Introduction", level = 1L), rmd_markdown(lines = "This is some text."), rmd_chunk( engine = "r", code = c("x <- 1:5", "mean(x)") ) )) ## ----------------------------------------------------------------------------- print(ast, flat = FALSE) ## ----------------------------------------------------------------------------- print(ast, flat = TRUE) ## ----------------------------------------------------------------------------- # Create a heading node heading = rmd_heading(name = "Section Title", level = 2L) # Access properties with @ heading@name heading@level ## ----------------------------------------------------------------------------- yaml_node = rmd_yaml(list( title = "My Document", author = "John Doe", date = "2023-01-01" )) yaml_node ## ----------------------------------------------------------------------------- heading_node = rmd_heading( name = "Introduction", level = 1L ) heading_node ## ----------------------------------------------------------------------------- markdown_node = rmd_markdown( lines = c("This is a paragraph.", "With multiple lines.") ) markdown_node ## ----------------------------------------------------------------------------- # Traditional-style options chunk_node_traditional = rmd_chunk( engine = "r", label = "example", options = list(eval = "TRUE", echo = "FALSE"), code = c("x <- 1:10", "mean(x)") ) # YAML-style options with proper types chunk_node_yaml = rmd_chunk( engine = "r", label = "example", options = list(eval = TRUE, echo = FALSE), code = c("x <- 1:10", "mean(x)") ) chunk_node_yaml ## ----------------------------------------------------------------------------- raw_chunk_node = rmd_raw_chunk( format = "html", code = c( "
Custom HTML content
", "