Unlabeled chunks will now be labeled as unnamed-chunk-n, with n incrementing.
breaks my tutorial.helpers package. Sadly, I did not have any test cases which would catch this change. Lesson: test more thoroughly!
2) Is there any way to remove this behavior? That would be very convenient for me!
3) Comment: This seems like a very bad default behavior to me. The purpose of parsermd should be to parsermd documents. It should not, quietly or otherwise, add any text to a document. If a code chunk has no label, it should be left without a label.
UPDATE: I was able to use this hack to solve my problem. So no need to fix this just for me.
# Parse Rmd of file path
rmd <- parsermd::parse_rmd(file_path)
tbl <- tibble::as_tibble(rmd)
# parsermd 0.1.3 created a difficult to diagnose bug for me. It labels any
# unlabelled R code chunk as "unnamed-chunk-n" with "n" incrementing. That is
# very bad! You should not add labels which do not exist. So, I do a total
# hack to just remove those labels from the final document. Of course, this
# will hose any user who actually has a code chunk whose label matches
# "unnamed-chunk-n" wiuth "n" as any integer, but what are you going to do?
# This hack was easier (?) than trying to work directly with objects of class
# "rmd_ast" "list"
for(i in seq_len(nrow(tbl))){
if(grepl("^unnamed-chunk-\\d+$", tbl[i, "label"])){
# Once we get the correct row, we do two things. First, we remove the
# label from the tibble. Not sure why this is necessary. Is the label
# really used later? Second, we need to change the ast itself.
tbl$label[i] <- NA
new_ast <- purrr::map(tbl$ast[i], change_chunk_function, "name", "")
tbl$ast[i] <- new_ast
}
}
If anyone has comments on a better way to do this, I would be interested.
1) This change in version 0.1.3
breaks my tutorial.helpers package. Sadly, I did not have any test cases which would catch this change. Lesson: test more thoroughly!
2) Is there any way to remove this behavior? That would be very convenient for me!
3) Comment: This seems like a very bad default behavior to me. The purpose of parsermd should be to parsermd documents. It should not, quietly or otherwise, add any text to a document. If a code chunk has no label, it should be left without a label.
UPDATE: I was able to use this hack to solve my problem. So no need to fix this just for me.
If anyone has comments on a better way to do this, I would be interested.