Learn R Programming

accessrmd (version 1.0.0)

sus_alt: Check an R markdown document for suspicious alt text.

Description

Checks if an R markdown contains images alt text is equal to alt attribute placeholder values, including: 'nbsp', 'spacer' and src attribute value (filename).

Usage

sus_alt(rmd_path = NULL, lan = detect_html_lang(lines))

Arguments

rmd_path

Path to the Rmd that contains image tags to check.

lan

Identify the language of text content. Attempts to find a lang attribute value from the rmd document. Alternatively, use a character string such as "en".

Value

Line numbers of images that has alt text equal to placeholder values.

Examples

Run this code
# NOT RUN {
# create a testfile
rmd <- tempfile("testing", fileext = ".rmd")
# write basic markdown content
writeLines('---
title: "Suspicious Alt Text"
author: "Some Author"
date: "`r format(Sys.Date(), "%d %b %Y")`"
output: html_document
---

 ```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## R Markdown

![nbsp](some_img)

![another_img](another_img)',
  con = rmd
)

# test the file for suspicious alt text
sus_alt(rmd, lan = "en")

# Adjust the document header to improve screen reader accessibility
access_head(rmd, lan = "en")
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab