Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

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.

Note

If the code fences are not balanced (e.g., a starting fence without an ending fence), this function will treat all lines as prose.

Examples

library(xfun)
prose_index(c("a", "```", "b", "```", "c"))
prose_index(c("a", "````", "```r", "1+1", "```", "````", "c"))

xfun

Miscellaneous Functions to Support Packages Maintained by 'Yihui Xie'

v0.22
MIT + file LICENSE
Authors
Yihui Xie [aut, cre, cph] (<https://orcid.org/0000-0003-0645-5666>), Wush Wu [ctb], Daijiang Li [ctb], Xianying Tan [ctb], Salim Brüggemann [ctb] (<https://orcid.org/0000-0002-5329-5987>), Christophe Dervieux [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.