k5cents/gluedown

Separate md_quote() elements with extra newline

k5cents opened this issue · 1 comments

TL;DR: When taking a vector of strings, each string should be treated as either (1) a new paragraph in the block quote, or (2) separate block quotes.

Right now, knitting a github_document with a vector passed to md_quote(), the quote is concatenated and printed as a single block quote. The GFM spec outlines three rules for block quotes:

A block quote marker consists of 0-3 spaces of initial indent, plus (a) the character > together with a following space, or (b) a single character > not followed by a space.

The following rules define block quotes:

  1. Basic case. If a string of lines Ls constitute a sequence of blocks Bs, then the result of prepending a block quote marker to the beginning of each line in Ls is a block quote containing Bs.
  2. Laziness. If a string of lines Ls constitute a block quote with contents Bs, then the result of deleting the initial block quote marker from one or more lines in which the next non-whitespace character after the block quote marker is paragraph continuation text is a block quote with Bs as its content. Paragraph continuation text is text that will be parsed as part of the content of a paragraph, but does not occur at the beginning of the paragraph.
  3. Consecutiveness. A document cannot contain two block quotes in a row unless there is a blank line between them.
library(rvest)
library(gluedown)
quote <- c(
  "Line number one.",
  "Line number two.",
  "Line number three."
)
md_quote(quote, cat = TRUE)

Line number one. Line number two. Line number three.

Created on 2019-10-20 by the reprex package (v0.3.0)

In this case, the user is probably hoping for one of two formats:

  1. Line number one.
    Line number two.
    Line number three.

  2. Line number one.

    Line number two.

    Line number three.

Following the philosophy of vectors, I believe the second format is desired, with each element of the vector as a separate quote.

I need to investigate whether this is an issue with GitHub rendering or RStudio's "preview" feature.

The .md file generated by such a github_document has the following text:

``` r
library(rvest)
library(gluedown)
quote <- c(
  "Line number one.",
  "Line number two.",
  "Line number three."
)
md_quote(quote, cat = TRUE)
```

> Line number one. Line number two. Line number three. Line number four.
> Line number five.

The preview for this document shows that output as a single line, but that exact text will be formatted on GitHub (issues) as two quotes?

Line number one. Line number two. Line number three. Line number four.
Line number five.