Thanks for replying. The mystery deepens and the status is that my document that required several hours of trial and error to 'fix' by excaping the apostrophes now compiles fine and I can't reproduce the issue. I had tried compiling other, related, .rmd files (beamer presentations for the class I'm teaching) and could not reproduce the '-related problem behavior in them. RMarkdown's pandoc_version() gives 2.1.1 so it appears my pandoc possibly wasn't upgraded with RStudio (1.4.1103).
It seems that the problem fixed itself overnight and I'll close this issue. I hope I didn't waste anyone's time on this
Another interesting change since upgrading RStudio/RMarkdown is in Beamer using 2 columns with the notation
::::::{.columns}
::: {.column width="45%" data-latex="{0.55\textwidth}"}
mycode
:::
::: {.column width="45%" data-latex="{0.55\textwidth}"}
mycode
:::
::::::
I'd found this syntax in a forum and it worked really well so I never had the notion to change anything. After upgrading RStudio/RMarkdown the usable space in the columns shrank to 0.55 of the column width which changed the slides and the text no longer fit. Changing this parameter to ...data-latex="0.99\textwidth}"}, so a column defined by
::::::{.columns}
::: {.column width="45%" data-latex="{0.99\textwidth}"}
mycode
...
fixed this. I had fiddled with the data-latex value before but it didn't seem to have an effect on the results. Now the value does seem to matter, which makes more sense.