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
Syntax Highlighting Themes for HTML #179
Merged
Merged
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
3fe593e
make highlighting themes work with html too
ramnathv e1281fd
make render_html respect knit_theme highlight settings
ramnathv 55378ef
add default.css to support default theme
ramnathv 15cbc81
add .knitr.css to define knitr classes for highlighting in html
ramnathv df1fbd3
minor changes to .knitr.css
ramnathv 8c8ce62
add TODOs to refactor .header.hi.html and .header.hi.tex
ramnathv 09505a1
add background to default css
ramnathv 8ba2e9f
use header_to_theme_xxx to generate default highlight headers
ramnathv 131ed42
move latex header to knitr.sty and read .header.framed from there
ramnathv 8757069
move .header.hi.xxx to themes.R
ramnathv dc49e76
move definition of .header.hi.tex inside render_latex
ramnathv 4502202
move .header.hi.html inside render_html where it is used
ramnathv e6171eb
move .header.framed inside render_latex so that it is not run before …
ramnathv 9114783
move definitions in .header.framed to style file knitr.sty
ramnathv 68cf44b
Merge remote branch 'upstream/master'
ramnathv c06ce2b
add .Rproj.user to .*ignore files
ramnathv 797ef9e
add misc folder and knitr.Rroj to gitignore
ramnathv bcc05cf
add graphicx package
ramnathv 21cf811
make code for get_theme() more explicit
ramnathv 96d14ef
add experimental hooks for reStructuredText
ramnathv 7742977
add myhooks.R to collate
ramnathv d31f0bc
export render_rst and hook_plot_rst
ramnathv 8958918
Merge remote branch 'upstream/master'
ramnathv 46481d3
modify insert_header to allow writing header to external file
ramnathv a57e1dd
remove graphicx from list of packages loaded
ramnathv 0d8f95e
remove <style..> </style> from header to allow writing to external file
ramnathv f3324e3
adjust spacing in css file
ramnathv af4f62e
remove myhooks from DESCRIPTION
ramnathv efb1a11
remove hooks for rst to do more extensive tests
ramnathv 6780ba6
remove rst hooks to do more extensive tests
ramnathv a6e95c3
add self.contained = TRUE as default in opts_knit
ramnathv 289619e
Merge remote branch 'upstream/master'
ramnathv 67ae3a0
Merge remote branch 'upstream/master'
ramnathv 56ab698
allow ```{r} fixes #195
ramnathv File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,4 @@ knitr-minimal.html | |
knitr-minimal.md | ||
knitr-latex.tex | ||
png$ | ||
^\.Rproj\.user$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,6 @@ inst/examples/figure | |
inst/examples/ex-out* | ||
knitr-minimal.html | ||
knitr-latex.tex | ||
|
||
.Rproj.user | ||
misc | ||
knitr.Rproj |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
\usepackage{framed} | ||
\makeatletter | ||
\newenvironment{kframe}{% | ||
\def\FrameCommand##1{\hskip\@totalleftmargin \hskip-\fboxsep | ||
\colorbox{shadecolor}{##1}\hskip-\fboxsep | ||
% There is no \\@totalrightmargin, so: | ||
\hskip-\linewidth \hskip-\@totalleftmargin \hskip\columnwidth}% | ||
\MakeFramed {\advance\hsize-\width | ||
\@totalleftmargin\z@ \linewidth\hsize | ||
\@setminipage}}% | ||
{\par\unskip\endMakeFramed} | ||
\makeatother | ||
|
||
\definecolor{shadecolor}{rgb}{.97, .97, .97} | ||
\newenvironment{knitrout}{}{} % an empty environment to be redefined in TeX | ||
|
||
\newcommand{\SweaveOpts}[1]{} % do not interfere with LaTeX | ||
\newcommand{\SweaveInput}[1]{} % because they are not real TeX commands | ||
\newcommand{\Sexpr}[1]{} % will only be parsed by R |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
.knitr { | ||
background-color: #F7F7F7; | ||
border:solid 1px #B0B0B0; | ||
} | ||
.error { | ||
font-weight: bold; | ||
color: #FF0000; | ||
}, | ||
.warning { | ||
font-weight: bold; | ||
} | ||
.message { | ||
font-style: italic; | ||
} | ||
.source, .output, .warning, .error, .message { | ||
padding: 0.5em 1em; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
.background{ | ||
color: #eeeeee ; | ||
} | ||
.number{ | ||
color: rgb(21,20,181) ; | ||
} | ||
|
||
.functioncall{ | ||
color: red ; | ||
} | ||
|
||
.string{ | ||
color: rgb(153,153,255) ; | ||
} | ||
|
||
.keyword{ | ||
font-weight: bolder ; | ||
color: black; | ||
} | ||
|
||
.argument{ | ||
color: rgb( 177,63,5) ; | ||
} | ||
|
||
.comment{ | ||
color: rgb( 204,204,204) ; | ||
} | ||
|
||
.roxygencomment{ | ||
color: rgb(0,151,255); | ||
} | ||
|
||
.formalargs{ | ||
color: rgb(18,182,18); | ||
} | ||
|
||
.eqformalargs{ | ||
color: rgb(18,182,18); | ||
} | ||
|
||
.assignement{ | ||
font-weight: bolder; | ||
color: rgb(55,55,98); | ||
} | ||
|
||
.package{ | ||
color: rgb(150,182,37); | ||
} | ||
|
||
.slot{ | ||
font-style:italic; | ||
} | ||
|
||
.symbol{ | ||
color: black ; | ||
} | ||
|
||
.prompt{ | ||
color: black ; | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is
edit-eclipse
the default theme for LaTeX output?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the default that you had used previously. I remember reading a note of yours sometime, where you indicated that you found the colors of the default highlight theme too flashy for pdfs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I think I mentioned it at some time, but I'm not actually using
edit-eclipse
. The default theme has a light gray background, and the background ofedit-eclipse
is white.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that event, I will create a
default.latex.css
theme which has thegray
background.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I do not see much gain of moving the two objects
.header.framed
and.header.hi.tex
to two files respectively; I mean they are simply string constants and it is probably not worth it to read and write through extra files. At the end of the day, they will be concatenated ininsert_header()
, and that will be the time to write the header into a separate file ifopts_knit$get('self.contained') == TRUE
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First, to some extent it is a style issue, since I don't prefer
latex
and other markups contaminating my R code. Second, these are just defaults. So pulling them inside default files helps keep the code clean without cluttering them up with a lot ofif.. else
statements. For instance, if we implementhighlight.style
as an option, you can set it todefault
and the headers would automatically correspond to them. Just my two cents :-)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK,
.header.hi.tex
can go to a file likedefault.css
. For.header.framed
, I'd rather leave it as is at the moment.