R syntax highlighting bug

In my reply to a post I have code snippets for Python and R and the syntax highlighting broke on the second R snippet.
Also, when I copy the snippet which is properly highlighted in the previous post (linked), its not properly highlighted in this post:

iris %>% 
    group_by(Species) %>% 
    summarize(avg.sepal.length = mean(Sepal.Length))

The function names aren’t highlighted here.