-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Regression: with bookdown 0.22 example (exm) environment misses the colon (:) between Example and its number in odt, docx and epub #1202
Comments
I now remember where this change came from. The bookdown:::theorem_abbr
#> theorem lemma corollary proposition conjecture definition
#> "thm" "lem" "cor" "prp" "cnj" "def"
#> example exercise hypothesis
#> "exm" "exr" "hyp" It was an issue in the code initially that was "fixed" during this PR : https://github.com/rstudio/bookdown/pull/1120/files#r605115658 A I understand this is a breaking change to you. @yihui do you remember why a |
We got here another case where putting back the |
@cderv I think it is uncommon to use
|
I think we can do that using markdown syntax by adding diff --git a/R/ebook.R b/R/ebook.R
index 4f38b42e..22974f75 100644
--- a/R/ebook.R
+++ b/R/ebook.R
@@ -116,13 +116,14 @@ resolve_refs_md = function(content, ref_table, to_md = output_md()) {
for (j in ids) {
m = sprintf('\\(\\\\#%s\\)', j)
if (grepl(m, content[i])) {
- id = ''; sep = ':'
+ id = ''; sep = ':'; bold = FALSE
type = gsub('^([^:]+).*$', '\\1', j)
if (type %in% theorem_abbr) {
id = sprintf('<span id="%s"></span>', j)
sep = ''
+ bold = TRUE
}
- label = label_prefix(type, sep = sep)(ref_table[j])
+ label = label_prefix(type, sep = sep, bold = bold)(ref_table[j])
content[i] = sub(m, paste0(id, label, ' '), content[i])
break
}
diff --git a/R/html.R b/R/html.R
index 6b04a4cd..a422bd6b 100644
--- a/R/html.R
+++ b/R/html.R
@@ -693,7 +693,7 @@ parse_fig_labels = function(content, global = FALSE) {
# given a label, e.g. fig:foo, figure out the appropriate prefix
-label_prefix = function(type, dict = label_names, sep = '') {
+label_prefix = function(type, dict = label_names, sep = '', bold = FALSE) {
label = i18n('label', type, dict)
supported_type = c('fig', 'tab', 'eq')
if (is.function(label)) {
{
}
function(num = NULL) {
if (is.null(num)) return(label)
- paste0(label, num, sep)
+ label = paste0(label, num, sep)
+ if (bold) sprintf("**%s**", label) else label
}
} The aim of What do you think ? |
If we want to offer a mechanism to customize / opt-out from this, we could extend the mechanism of passing a function also for those environments. |
If possible, @yihui , please add colon (:) instead of bold style: Example 1.1: Simple C Program as it was in previous versions. |
I think we can provide an option to add the colon, but by default, I hope not to include the colon, to be consistent with other output formats (PDF and HTML). Will that be okay to you? |
Providing an option is okay for me. Thanks! |
@yihui should it be an option specific for the colon or extending the mechanism to pass a function to customise labels ? With this mechanism I believe it could be customized any way a user wants it to be. |
The latter (if possible) would be better. Either way is fine to me. |
I think I can extend the mechanism I put in place for |
I have the following minimal Rmd bookdown example file named
index.Rmd
:With 0.21 it was rendered as "Example 1.1: Simple C program", but with 0.22 and latest version from github it renders as "Example 1.1 Simple C program". It breaks readability. See image below for odt-output:
I think that it is a regression bug.
Below is the table with Example separators comparison.
:
:
:
Please confirm and fix this bug in the next version.
The text was updated successfully, but these errors were encountered: