-
-
Notifications
You must be signed in to change notification settings - Fork 873
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
Allow users to specify theme for syntax highlighting #36
Comments
This is definitely a good suggestion, and in fact you have already found the solution. The only thing left for me to do is to make the function |
Thanks for a prompt reply. So the argument |
It takes a character vector containing your style definitions. You can take a look at I will document this function later. |
Excellent. I have a suggestion in this regard. It might be useful to allow users to define a Internally, this does not create too much work, since you can do the following to get
Alternately, it might be possible to contact the author of
I am in the process of generating Let me know what you think. |
I believe this is a good idea. I'd love to see your work on porting the styles in Andre's highlight package, and will be happy to talk to Romain about it (I noticed he copied some of the style files to his package, but I do not know how we are supposed to use them). |
I have ported styles from Andre's highlight package, as well as have the working code to port from One bottleneck I hit, while testing is that I was unable to change the style definitions used by Once I have this fully tested, I will |
Oh, you should call that inside a code chunk in the Rnw document, because each time you call |
Perfect. It works now. I will put together proof-of-concept and send you the details so that you can take a look. Subsequently, we can figure out the best way to integrate it into |
There is one issue that remains. When using dark backgrounds, the output gets completely masked as it is still in |
Hmm... interesting question. I would not recommend modifying the |
That works. I used the hook |
Actually I tried |
I have successfully converted all themes into css files, that Using the same mapping approach, I was also able to convert themes on http://www.eclipsecolorthemes.org/ to I am still thinking on what is the best way to proceed on this. My current inclination would be to (a) have a themes folder in Let me know what you think about this. Based on your preference, I can fork your code and write my implementation and send a pull request. |
Oh, this is really really cool! I do not have any additional comments; please go ahead with your ideas. Thanks! BTW, what is the total file size of these css files? |
Great. The So I will go ahead and fork your project, and do the following:
|
I am almost done with the implementation. The one issue I am facing is while using themes with dark backgrounds. Using a I am also adding some really cool themes from http://www.eclipsecolorthemes.org/. |
I will address the issue of the background color of plots in another manual for graphics. In short, you can use Your work sounds terrific and it seems people will never need to consider the LaTeX |
I have added the implementation of themes to my fork of
I still need to add details to the documentation. Let me know if it works for you, or if I have inadvertently hard-coded anything for my system. |
I will take a look tomorrow. Thanks! |
I'm reading your theme code, and it looks great. A few issues first:
|
Thanks for the comments Yihui. Here are my responses to the issues you raised.
I think it would be easier to provide the css style files as a folder which gets installed at build time. We could provide a function
A few more things. I noticed that you are using |
I checked the themes on Andre's website. The formats have changed, so I need to rewrite the parser that will extract the elements from his themes and populate the My preference would be to agree on a draft design of how code themes would operate. Here is how I envision it:
I will try to get (1) - (3) done today, use In parallel, I can focus on generating new Let me know if this sounds good. In the long run, I think it might make sense to provide |
I got it working with |
A quick question. Can you take a look at http://www.eclipsecolorthemes.org/? I have written a function that can take a theme number, download the XML style file and convert it to Given that they have a library of 4939 color themes, I was thinking it makes sense to restrict attention solely to themes on that site. A user can visit the site and preview the themes, and would be able to add a theme on the fly. For example, to use
Let me know what you think. If you are in agreement, then I can restrict my attention to just the themes on this site, and probably provide the top 100 themes for direct use in |
I think this site is enough (may be far more than enough, haha). Last night I suddenly realized that the theme can be generated in real time, because knitr has the unbeatable cache! :) For example, we can create the theme in the first chunk and cache it, then the theme is only generated for the first time; in the second theme, we call a function to set the theme. It should be fairly fast. But you need to do a little bit more work -- let your theme functions return the character string (the header/preamble), which can be cached in the first chunk and used in the second chunk. |
My preference would be to add this option on top of the pre-packaged One issue to figure out is the copyrights for ecllipse color themes. The website does not say anything, but might be worth checking before using them in |
Hmm... I did not find anything on copyrights in this site either. We can first include those from Andre's highlight package (it is under GPL), and leave the ecllipse themes alone; if the users really like the latter ones, they can use the cache method I mentioned above to generate the theme in real time, and we are free of copyright problems. BTW, the highlight manual looks great! |
Makes sense. As I had indicated before, the format of style files has changed in Highlight 3.0, which means it will take some work to convert them into the |
I am done converting themes from Andre's Highlight 3.0 to css files. The One issue that remains is the foreground color of plots, especially when using dark backgrounds. Is there a consistent way to change the foreground color to the foreground color of the theme so that plots are rendered visibly? |
as long as you have a line |
It does not seem to be working with plots. I am still getting plots with black outlines, when using a dark background. I will upload a sample file so that you can test it out. |
That is another story; I expect the users to |
It is now possible to use any theme on www.eclipsecolorthemes.org by adding the following chunk to your Rnw file. theme <- save_eclipse_theme(10)
set_theme(theme) This enhances the number of themes accessible to a user manifold, and I think is pretty cool ! |
Yes, this is exactly what I want :) |
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary. |
First off, excellent work on the package. Sweave is a part of my daily workflow, and this package provides most of the features that I wished Sweave would. I have a couple of suggestions, which I will try to post from time to time. My first suggestion is to add a feature that allows users to specify the theme for syntax highlighting.
I see that you are using the
highlight
package, which uses acss
file located in thestylesheet
folder to control the highlighting. It would be nice to allow users to specify the highlighting theme using a css file. In the long run, it would be possible to convert standard themes available inhighlight
ortextmate
tocss
files, allowing the user to choose thestyle
inSweaveOpts
.Let me know if you are open to this suggestion. I have browsed through your code and see that currently, the style definitions are in the variable
.header.hi.tex
. I can work with you in creating the mechanism that would allow user specified styles, if you would like me to.The text was updated successfully, but these errors were encountered: