I've found some mention of .gitattributes that might help here, but before diving more into this, I'd like to have some opinion from people with experience about this problem.
Edit:
It seems like I might also be able to control that with git config --global core.autocrlf. If so, would that be favored over using .gitattributes when not working in a team?
Possibly related, I have the following helper in my package to control how to rebuild the YAML header of .Rmd/.qmd files. Would using .gitattributes or git config also controls that for me automatically?
I don't think I can do that (for what it's worth, here's the test). I could probably omit \r when extracting the string from the output file here with a better regex, e.g. (?<=## ).+(?=\\R)$. I can't test it on my machine though.
Instead of expect_equal(), would it help to use a regular expression instead, with expect_match()? As you said you could also edit md_extract_chunk_output(). You could do that in a git branch, open a PR and see if it works on the OS you don't have locally. Quite cheap.
Or you could write your own custom expectation, that would remove the ending before testing the "equality".