Skip to content

Commit

Permalink
print to pdf css
Browse files Browse the repository at this point in the history
  • Loading branch information
jjallaire committed Feb 4, 2013
1 parent d37e26a commit 0a1495f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
28 changes: 19 additions & 9 deletions src/cpp/session/modules/presentation/SessionPresentation.cpp
Expand Up @@ -147,7 +147,9 @@ ResourceFiles& resourceFiles()



std::string revealResource(const std::string& path, bool embed)
std::string revealResource(const std::string& path,
bool embed,
const std::string& extraAttribs)
{
// determine type
bool isCss = boost::algorithm::ends_with(path, "css");
Expand All @@ -158,13 +160,13 @@ std::string revealResource(const std::string& path, bool embed)
{
if (isCss)
{
code = "<style type=\"text/css\">\n" +
code = "<style type=\"text/css\" " + extraAttribs + " >\n" +
resourceFiles().get("presentation/" + path) + "\n"
+ "</style>";
}
else
{
code = "<script type=\"text/javascript\">\n" +
code = "<script type=\"text/javascript\" " + extraAttribs + " >\n" +
resourceFiles().get("presentation/" + path) + "\n"
+ "</script>";
}
Expand All @@ -173,25 +175,28 @@ std::string revealResource(const std::string& path, bool embed)
{
if (isCss)
{
code = "<link rel=\"stylesheet\" href=\"" + path + "\">";
code = "<link rel=\"stylesheet\" href=\"" + path + "\" "
+ extraAttribs + " >";
}
else
{
code = "<script src=\"" + path + "\"></script>";
code = "<script src=\"" + path + "\" " + extraAttribs + " ></script>";
}
}

return code;
}

std::string revealEmbed(const std::string& path)
std::string revealEmbed(const std::string& path,
const std::string& extraAttribs = std::string())
{
return revealResource(path, true);
return revealResource(path, true, extraAttribs);
}

std::string revealLink(const std::string& path)
std::string revealLink(const std::string& path,
const std::string& extraAttribs = std::string())
{
return revealResource(path, false);
return revealResource(path, false, extraAttribs);
}


Expand Down Expand Up @@ -464,6 +469,9 @@ void handlePresentationPaneRequest(const http::Request& request,
// generate standalone version

// embedded versions of reveal assets
const char * const kMediaPrint = "media=\"print\"";
vars["reveal_print_pdf_css"] = revealEmbed("revealjs/css/print/pdf.css",
kMediaPrint);
vars["reveal_css"] = revealEmbed("revealjs/css/reveal.min.css");
vars["reveal_theme_css"] = revealEmbed("revealjs/css/theme/simple.css");
vars["reveal_head_js"] = revealEmbed("revealjs/lib/js/head.min.js");
Expand Down Expand Up @@ -496,6 +504,8 @@ void handlePresentationPaneRequest(const http::Request& request,
// generate preview version

// linked versions of reveal assets
vars["reveal_print_pdf_css"] = revealLink("revealjs/css/print/pdf.css",
kMediaPrint);
vars["reveal_css"] = revealLink("revealjs/css/reveal.css");
vars["reveal_theme_css"] = revealLink("revealjs/css/theme/simple.css");
vars["reveal_head_js"] = revealLink("revealjs/lib/js/head.min.js");
Expand Down
5 changes: 4 additions & 1 deletion src/cpp/session/resources/presentation/slides.html
Expand Up @@ -19,7 +19,10 @@
#!slides_css#
#!user_slides_css#
</style>


<!-- reveal print to pdf css -->
#!reveal_print_pdf_css#

#!r_highlight#

#!mathjax#
Expand Down

0 comments on commit 0a1495f

Please sign in to comment.