carpentries / carpentries/pegboard
div fences are capped at 80 characters
- Dominant language
- R
- Stars
- 6
- Forks
- 5
- PR merge metrics
- No merged PRs in 30d
Description
## Problem
As reported in https://github.com/carpentries/workbench/issues/62, if someone writes a closing div fence that is more than 80 characters wide, they encounter an error of a missing div tag.
I can construct a reproducible example that demonstrates this pattern with 91 closing colons:
```markdown
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: instructor
test
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
```
``` r
tmp <- withr::local_tempfile()
open <- paste(paste(rep(":", 80), collapse = ""), "instructor")
close <- paste(rep(":", 91), collapse = "")
writeLines(c(open, "\ntest\n", close), tmp)
pegboard::Episode$new(tmp)$label_divs()
#> ✖ A section (div) tag mis-match was detected.
#> ✖ There are not enough close tags (0) for the number of open tags (2).
#> Error: Missing close section (div) tag in /tmp/RtmpBS9YrF/file8e3174daa911.
#> Here is a list of all the tags in the file:
#> /tmp/RtmpBS9YrF/file8e3174daa911:1 | tag: instructor
#> /tmp/RtmpBS9YrF/file8e3174daa911:5 | tag: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
```
Created on 2023-06-29 with [reprex v2.0.2](https://reprex.tidyverse.org)
## Explanation
The reason for this is because the regex (yes, we use regex for this 😨) caps the number of colons at 80 (important part is `[:]{3,80}$`): https://github.com/carpentries/pegboard/blob/3b06f4559892e31ff0a6bae1d838cd1ba6fd94fb/R/div.R#L658-L660
Note, however that this cap is NOT present in the opening div regex (which is even more horrifying than the previous; so much so that [it needs 20 lines of explanation](https://github.com/carpentries/pegboard/blob/3b06f4559892e31ff0a6bae1d838cd1ba6fd94fb/R/div.R#L635-L656)) (important part is `[:]{3,}`): https://github.com/carpentries/pegboard/blob/3b06f4559892e31ff0a6bae1d838cd1ba6fd94fb/R/div.R#L655
Contributor guide
Research direction
Start in R/div.R at the closing-div regex around lines 658-660, then run the reproducible pegboard::Episode$new(tmp)$label_divs() example from the issue. The fix is done when a closing fence longer than 80 colons is recognized and the missing-div error no longer occurs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100