EvaMaeRey / flipbookr

Presenting code step-by-step and side-by-side with its output
https://evamaerey.github.io/flipbookr/
Other
198 stars 20 forks source link

With break_type = "non_seq", error for #BREAKN when N > 9 #44

Closed petrbouchal closed 3 years ago

petrbouchal commented 3 years ago

When using the "non_seq" break type, the following error (or different, depending on context) appears. It seems that the problem is with the #BREAK10 string, where a stray 0 is left behind in the code, suggesting that flipbookr does not pick up two-digit break sequence comments correctly.

Error:

image

Quasi-reprex:

This works:

```{r setup}
library(gggplot2)
library(flipbookr)
```

`r chunk_reveal("ggplot2-example-singledigit", break_type = "non_seq")`
```{r ggplot2-example-singledigit, include = F}
ggplot(mpg) + #BREAK
  aes(cty, hwy) + #BREAK2
  geom_point( #BREAK3
    aes(colour = year) #BREAK4
  ) + #BREAK3
  facet_wrap(~cyl) + #BREAK5
  theme( #BREAK6
    legend.position = "bottom", #BREAK7
    panel.border = element_rect(colour = "red", fill = NA) #BREAK8
  ) + #BREAK6
  # labs(x = NULL, title = "Hi there") + #BREAK9
  scale_colour_viridis_c() #BREAK9
```

This breaks:

`r chunk_reveal("ggplot2-example-doubledigit", break_type = "non_seq")`
```{r ggplot2-example-doubledigit, include = F}
ggplot(mpg) + #BREAK
  aes(cty, hwy) + #BREAK2
  geom_point( #BREAK3
    aes(colour = year) #BREAK4
  ) + #BREAK3
  facet_wrap(~cyl) + #BREAK5
  theme( #BREAK6
    legend.position = "bottom", #BREAK7
    panel.border = element_rect(colour = "red", fill = NA) #BREAK8
  ) + #BREAK6
  labs(x = NULL, title = "Hi there") + #BREAK9
  scale_colour_viridis_c() #BREAK10
```
EvaMaeRey commented 3 years ago

Okay. I think we are now good from 2 to 99. Let me know if there are any problems. Thanks for the issue!

petrbouchal commented 3 years ago

Thank you! All fine now on my end.

EvaMaeRey commented 3 years ago

Good. Also, nice example graphs!