read_md_to_df_str | R Documentation |
Reads a Markdown file using readLines
and parses the content into a structured
DataFrame based on the Markdown headings. The function allows optional aggregation
of content under each heading and flexible reading of files with additional readLines
arguments.
read_md_to_df_str(
file,
summarize = TRUE,
collapse = ", ",
readLines_args = list()
)
file |
A character string naming a file, a connection, or literal data (either a single string or a raw vector) to be read. |
summarize |
Logical, if |
collapse |
The string to use when collapsing multiple lines of content under
each heading when |
readLines_args |
A list of additional arguments to pass to |
A data.frame
where each row corresponds to a heading or content line. If
summarize
is TRUE
, each heading level is condensed into a single entry. The columns
of the DataFrame represent the hierarchical levels (headings) and the content under these headings.
# Read a local Markdown file and convert to a DataFrame
# df <- read_md_to_df_str("path/to/your/file.md")
# Read a Markdown file with content summarization disabled
# df <- read_md_to_df_str("path/to/your/file.md", summarize = FALSE)
# Read a Markdown file with specific encoding
# df <- read_md_to_df_str("path/to/your/file.md", readLines_args = list(encoding = "UTF-8"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.