Skip to content

Visual mode destroys citation markdown #15037

Open

Description

@mSparks43

System details

RStudio Edition : Desktop
RStudio Version :  2024.04.2 Build 764
OS Version      :  FC39
R Version       :  R version 4.3.3 (2024-02-29) -- "Angel Food Cake"

Steps to reproduce the problem

In source enter multiple citations, e.g.
^[@Cite1;@cite2;@cite3;@Cite4]^
knit
correctly renders to
image

select visual mode, citations become

^[@Cite1;\ @cite2;\ @cite3;\ @Cite4]^

which now incorrectly rendering to
image

Describe the problem in detail

Selecting visual mode is destroying citation markdown

Describe the behavior you expected

Selecting visual mode should not modify markdown unless it is actually edited.

  • I have read the guide for submitting good bug reports.
  • I have installed the latest version of RStudio, and confirmed that the issue still persists.
  • If I am reporting an RStudio crash, I have included a diagnostics report.
  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.

Activity

  1. added
    new
    on Aug 4, 2024
  2. ronblum commented on Aug 5, 2024

    @ronblum
    Contributor

    @mSparks43 Thank you for raising this! Some changes are expected, as the code with the Visual Editor conforms to Pandoc. https://quarto.org/docs/visual-editor/markdown.html. But they shouldn't change what's rendered.

    A few questions:

    1. For the incorrect rendering, do you mean the extra space?
    2. Do the citations still work when you switch back to visual mode?
    3. Are the carets ^ part of the code, or are you using them here to indicate the code?
    4. In the first example, did you use commas instead of semicolons? The rendering shown has commas.
    5. Does it make a difference if you use Quarto or R Markdown? I'm guessing not, but good to know
  3. added
    info needed
    visual markdown
    and removed
    new
    on Aug 5, 2024
  4. mSparks43 commented on Aug 5, 2024

    @mSparks43
    Author

    citeTest.zip

    Attached a minimal example

    1. yes, every time you switch between visual and source mode it adds an extra space between them
      Initially:
      image
      renders to
      image

    2. they still "work" but the space between them increases each time you switch from visual to source
      image

    3. The ^ makes them superscript, seems to be required to trigger it
      image

    4. commas dont work in markdown for seperating multiple citations, using commas results in
      image

    5. Not sure what Quarto is

  5. ronblum commented on Aug 19, 2024

    @ronblum
    Contributor

    @mSparks43 Thank you! I've been able to reproduce this--I wanted to make sure that we're seeing the same thing.

  6. removed
    info needed
    on Aug 21, 2024
  7. added this to the Later milestone on Aug 21, 2024
  8. jthomasmock commented on Aug 21, 2024

    @jthomasmock
    Contributor

    We are doing some improvements to the Visual Editor and will evaluate this alongside other "roundtripping" issues.

  9. michalovadek commented on Feb 26, 2025

    @michalovadek

    I am encountering a similar issue (on latest RStudio daily) where switching between Visual and Source incorrectly adds backslashes to [] when pinpointing a citation. After fixing this manually in Source, I confirmed that switching to Visual re-adds the backslashes, which destroys the citation pinpoint.

    In a footnote of a Quarto document I have the markdown source text:

    ... See @Bebr1953European [p. 20] and @Gillingham1991Coal [p. 313]. ...

    After switching to Visual and back to Source, the markdown is changed to:

    ... See @Bebr1953European \[p. 20\] and @Gillingham1991Coal [p. 313]. ...

    Throughout the Visual editing mode displays the citation as if parsed correctly, but in the rendered output (as well as the Source view) it's clear there is an issue.

    This behaviour is not obviously consistent, because only the first citation gets messed up, not the second. The problem occurs in a (relatively small) number of footnotes throughout my Quarto book, but I cannot identify a pattern. Maybe someone can see one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugvisual markdown

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions