Skip to content

Commit

Permalink
fix #759: restore {{\< to {{< and \>}} to >}}
Browse files Browse the repository at this point in the history
this should be fine in most cases; if the restoration is not expected, users can set options(blogdown.restore.shortcode = FALSE) in .Rprofile
  • Loading branch information
yihui committed Jan 18, 2024
1 parent 78f7c43 commit 6f403c5
Show file tree
Hide file tree
Showing 3 changed files with 9 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 @@
Type: Package
Package: blogdown
Title: Create Blogs and Websites with R Markdown
Version: 1.18.1
Version: 1.18.2
Authors@R: c(
person("Yihui", "Xie", role = c("aut", "cre"), email = "[email protected]", comment = c(ORCID = "0000-0003-0645-5666")),
person("Christophe", "Dervieux", role = "aut", email = "[email protected]", comment = c(ORCID = "0000-0003-4474-2498")),
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 blogdown VERSION 1.19

- Fixed the bug that shortcodes were mangled when there are raw HTML blocks in the Markdown output from R Markdown (thanks, @Redcozmo, #759).

# CHANGES IN blogdown VERSION 1.18

Expand Down
8 changes: 7 additions & 1 deletion R/render.R
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,13 @@ process_markdown = function(res, x = read_utf8(res)) {
options = c('--wrap=preserve', '--preserve-tabs'),
citeproc = TRUE
)
x = c(bookdown:::fetch_yaml(x), '', read_utf8(mds[2]))
x2 = read_utf8(mds[2])
# pandoc will escape < and > in shortcodes, and below is a hack to restore them
if (get_option('blogdown.restore.shortcode', TRUE)) {
x2 = gsub('^\\{\\{\\\\< ([^ ])', '{{< \\1', x2)
x2 = gsub('([^ ]) \\\\>\\}\\}$', '\\1 >}}', x2)
}
x = c(bookdown:::fetch_yaml(x), '', x2)
}
x
}
Expand Down

0 comments on commit 6f403c5

Please sign in to comment.