prose_index: Find the indices of lines in Markdown that are prose (not...

Description Usage Arguments Value Note Examples

View source: R/markdown.R

Description

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

Usage

1
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

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

Example output

Attaching package: 'xfun'

The following object is masked from 'package:base':

    attr

[1] 1 5
[1] 1 7

xfun documentation built on June 16, 2021, 1:07 a.m.