xfun (version 0.12)

prose_index: Find the indices of lines in Markdown that are prose (not code blocks)

Description

Filter out the indices of lines between code block fences such as ``` (could be three or four or more backticks).

Usage

prose_index(x, warn = TRUE)

Arguments

x

A character vector of text in Markdown.

warn

Whether to emit a warning when code fences are not balanced.

Value

An integer vector of indices of lines that are prose in Markdown.

Examples

Run this code
# NOT RUN {
library(xfun)
prose_index(c("a", "```", "b", "```", "c"))
prose_index(c("a", "````", "```r", "1+1", "```", "````", "c"))
# }

Run the code above in your browser using DataLab