extract_blocks {TheOpenAIR}R Documentation

Extract blocks of a specified type from a list of blocks

Description

Extract blocks of a specified type from a list of blocks

Usage

extract_blocks(block_list, block_type)

Arguments

block_list

A list of blocks

block_type

The type of blocks to be extracted

Value

A list of blocks of the specified type

Author(s)

Jonathan Chassot

Examples

## Not run: 
# Example 1: Extract 'code' blocks
blocks <- list(
  list(type = "text", content = "Hello world!"),
  list(type = "code", content = "print('Hello world!')")
)
extract_blocks(blocks, "code")
# Output:
# [[1]]
# $type
# [1] "code"
#
# $content
# [1] "print('Hello world!')"

# Example 2: Extract 'text' blocks
blocks <- list(
  list(type = "text", content = "Hello world!"),
  list(type = "code", content = "print('Hello world!')")
)
extract_blocks(blocks, "text")
# Output:
# [[1]]
# $type
# [1] "text"
#
# $content
# [1] "Hello world!"

## End(Not run)

[Package TheOpenAIR version 0.1.0 Index]