Skip to content

Commit

Permalink
unfortunately I discovered another bad bug after the previous release…
Browse files Browse the repository at this point in the history
…: spaces in headers of verbatim code blocks were not restored
  • Loading branch information
yihui committed Oct 10, 2023
1 parent 46a28a5 commit c29ed02
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: markdown
Type: Package
Title: Render Markdown with 'commonmark'
Version: 1.10.1
Version: 1.10.2
Authors@R: c(
person("Yihui", "Xie", role = c("aut", "cre"), email = "[email protected]", comment = c(ORCID = "0000-0003-0645-5666")),
person("JJ", "Allaire", role = "aut"),
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# CHANGES IN markdown VERSION 1.11

- Verbatim code blocks of the form ```` ```{lang attr1 attr2 ...} ```` were not correctly rendered.

# CHANGES IN markdown VERSION 1.10

Expand Down
4 changes: 3 additions & 1 deletion R/render.R
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ mark = function(
text = match_replace(text, r4, function(x) {
x1 = sub(r4, '\\1', x)
x2 = sub(r4, '\\2', x)
x2 = gsub(' ', id4, x2)
x2 = gsub(' ', id4, x2, fixed = TRUE)
paste0(x1, x2)
})
}
Expand Down Expand Up @@ -232,6 +232,8 @@ mark = function(
z2 = ifelse(i, sub('^class="', '', z2), paste0('"', z2))
paste0(z1, z2, '>')
}, 'html', function(z2) gsub(id4, ' ', restore_html(z2)))
# some code blocks with "attributes" are verbatim ones
ret = match_replace(ret, '```+\\{.+}', function(x) gsub(id4, ' ', x, fixed = TRUE))
# auto identifiers
if (isTRUE(options[['auto_identifiers']])) ret = auto_identifier(ret)
# number sections
Expand Down
1 change: 1 addition & 0 deletions inst/examples/render-options.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ cat(mark('```{.r}\n1 + 1;\n```'))
cat(mark('```{.r .js}\n1 + 1;\n```'))
cat(mark('```{.r .js #foo}\n1 + 1;\n```'))
cat(mark('```{.r .js #foo style="color:red;"}\n1 + 1;\n```'))
cat(mark('````\n```{r, echo=TRUE}\n1 + 1;\n```\n````'))

# raw blocks
cat(mark('```{=html}\n<p>raw HTML</p>\n```'))
Expand Down
1 change: 1 addition & 0 deletions man/markdown_options.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions tests/tests.Rout.save
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@ Content Cell | Content Cell</p>
<pre><code class="language-r js" id="foo" style="color:red;">1 + 1;
</code></pre>

> cat(mark("````\n```{r, echo=TRUE}\n1 + 1;\n```\n````"))
<pre><code>```{r, echo=TRUE}
1 + 1;
```
</code></pre>

> cat(mark("```{=html}\n<p>raw HTML</p>\n```"))
<p>raw HTML</p>

Expand Down

0 comments on commit c29ed02

Please sign in to comment.