Skip to content

Commit

Permalink
fix #1200: improve the GFM preview
Browse files Browse the repository at this point in the history
1. pass a pagetitle variable to pandoc to suppress the spurious warning (not really important in this case);

2. make sure the extension is .md instead of guessing from the input format in pandoc_output_file();

3. change div.sourceLine to inline elements since the default linespacing is ugly in Pandoc 2.0 (https://groups.google.com/forum/#!topic/pandoc-discuss/1bwAre8fG6E)

should not use code > .class in CSS because in Pandoc 2.0, .class is no longer the direct child of <code>
  • Loading branch information
yihui committed Nov 14, 2017
1 parent 89b7f2c commit 6558c3c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 31 deletions.
2 changes: 1 addition & 1 deletion R/github_document.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ github_document <- function(toc = FALSE,

# provide a preview that looks like github
args <- c(args, "--standalone")
args <- c(args, "--self-contained")
args <- c(args, "--self-contained", if (pandoc2) c("--metadata", "pagetitle=PREVIEW"))
args <- c(args, "--highlight-style", "pygments")
args <- c(args, "--template",
pandoc_path_arg(rmarkdown_system_file(
Expand Down
3 changes: 2 additions & 1 deletion R/md_document.R
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ md_document <- function(variant = "markdown_strict",
knitr = knitr_options_html(fig_width, fig_height, fig_retina, FALSE, dev),
pandoc = pandoc_options(to = variant,
from = from_rmarkdown(extensions = md_extensions),
args = args),
args = args,
ext = '.md'),
clean_supporting = FALSE,
df_print = df_print,
post_processor = post_processor
Expand Down
61 changes: 32 additions & 29 deletions inst/rmarkdown/templates/github_document/resources/github.css
Original file line number Diff line number Diff line change
Expand Up @@ -657,33 +657,36 @@ kbd {
border-color: #4078c0;
}

.sourceLine {
display: inline-block;
}

code > .kw { color: #000000; }
code > .dt { color: #ed6a43; }
code > .dv { color: #009999; }
code > .bn { color: #009999; }
code > .fl { color: #009999; }
code > .ch { color: #009999; }
code > .st { color: #183691; }
code > .co { color: #969896; }
code > .ot { color: #0086b3; }
code > .al { color: #a61717; }
code > .fu { color: #63a35c; }
code > .er { color: #a61717; background-color: #e3d2d2; }
code > .wa { color: #000000; }
code > .cn { color: #008080; }
code > .sc { color: #008080; }
code > .vs { color: #183691; }
code > .ss { color: #183691; }
code > .im { color: #000000; }
code > .va {color: #008080; }
code > .cf { color: #000000; }
code > .op { color: #000000; }
code > .bu { color: #000000; }
code > .ex { color: #000000; }
code > .pp { color: #999999; }
code > .at { color: #008080; }
code > .do { color: #969896; }
code > .an { color: #008080; }
code > .cv { color: #008080; }
code > .in { color: #008080; }
code .kw { color: #000000; }
code .dt { color: #ed6a43; }
code .dv { color: #009999; }
code .bn { color: #009999; }
code .fl { color: #009999; }
code .ch { color: #009999; }
code .st { color: #183691; }
code .co { color: #969896; }
code .ot { color: #0086b3; }
code .al { color: #a61717; }
code .fu { color: #63a35c; }
code .er { color: #a61717; background-color: #e3d2d2; }
code .wa { color: #000000; }
code .cn { color: #008080; }
code .sc { color: #008080; }
code .vs { color: #183691; }
code .ss { color: #183691; }
code .im { color: #000000; }
code .va {color: #008080; }
code .cf { color: #000000; }
code .op { color: #000000; }
code .bu { color: #000000; }
code .ex { color: #000000; }
code .pp { color: #999999; }
code .at { color: #008080; }
code .do { color: #969896; }
code .an { color: #008080; }
code .cv { color: #008080; }
code .in { color: #008080; }

0 comments on commit 6558c3c

Please sign in to comment.