rstudio / rmarkdown

Dynamic Documents for R
https://rmarkdown.rstudio.com
GNU General Public License v3.0
2.88k stars 977 forks source link

Don't rearrange the yaml #1054

Closed jennybc closed 7 years ago

jennybc commented 7 years ago

I have an Rmd that, sadly, must have two output formats. Here's the yaml, arranged in what I think is a very sensible way:

---
title: "Excuse me, do you have a moment to talk about version control?"
authors:
- name: Jennifer Bryan
  affiliation: |
    RStudio and the Department of Statistics, University of British Columbia
  thanks: |
    The author gratefully acknowledges the constructive feedback from reviewers
    Nicholas Horton and Colin Rundel.
blinded: 0
output:
  rticles::asa_article: null
  github_document:
    toc: yes
keywords: version control
abstract: Abstract abstract abstract.
bibliography: git-github-for-stats.bib
---

As I ping-pong between rendering to the two formats, it seems my yaml gets constantly re-written -- re-ordered, really. This causes lots of low value diffs and I find myself constantly scrutinizing them, making sure it's just the usual churn, then discarding those changes.

Here's a recent example:

screen shot 2017-05-18 at 5 18 05 pm

If this is functional, then I guess it must be kept. But if its inessential, can the yaml be left alone? Or is there anything I can do to prevent this myself?

jennybc commented 7 years ago

I acknowledge this may be more of an IDE issue? Because I note that rmarkdown::render() does not touch the .Rmd.

jjallaire commented 7 years ago

Yes this is an IDE issue. @jmcphers is there any hope for a change here soon?

jmcphers commented 7 years ago

Yes, this is caused by round-tripping through the yaml package, which "helpfully" does things like try to alphabetize keys. However it turns out to be very straightforward to skip this roundtrip in the common case wherein the desired output format is already present in the YAML, so I've just pushed a fix.

jennybc commented 7 years ago

Great!

github-actions[bot] commented 3 years ago

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.