Syntax highlighting R script - r

As my R scripts get long and messy, I would like to create headers that are easily identifiable: for instance, change the color of certain comments in script. I am not looking for something crazy like underlining or changing the fonts for chunks of comments, just changing color, i.e. highlighting comments.
From all my search, the only option is to change the Editor appearance from setting, but I would like to distinguish certain chunks of comments from other comments.

Related

Syntax highlighting for LaTeX code in RStudio

I have recently started writing mathematical documents using Bookdown and RStudio, and I am looking for a way to setup syntax highlighting for LaTeX code. I know that I can customise the syntax highlighting using editor themes, and I have found this tool for creating them, but I don't know what to enter into the "scope" fields to achieve the highlighting I want.
I would like something similar to the syntax highlighting in TeXworks (which is what I'm used to). This has separate highlight colours for special characters, commands beginning and ending LaTeX environments, LaTeX packages, and control sequences. Ideally, I'd also like another highlight colour for text in mathmode, and I would like the highlighting to be the same for text that is inside or outside Bookdown's equivalent of Theorem environments.
Based on trying a few themes and looking at them in the editor, I think that keyword highlighting will highlight LaTeX control sequences and support.function will highlight text in mathmode, but these only work outside of Bookdown's environments.
Is it possible to achieve the highlighting I want? And if so, how?

AvalonEdit - Syntax Highlighting - How do I add underline, change font size, etc?

I'm trying to build a basic, Markdown-style plain/rich text editor. (One where the text is styled inline, instead of having two panels side-by-side the way most Markdown editors do) (I'm also not going to support the full Markdown spec - no lists or tables, mainly just rich text formatting like bold, italics, underline, etc)
I have a project that consumes the AvalonEdit project (via the source code, not the Nuget package) - I got the editor all setup exactly how I want - then I started to write a syntax highlighting XSHD file when I realized that the highlighter only supports formatting like font colors, italics, bold, etc and not font size, underline and others...
How can I add additional font formatting? Will I have to write a whole new parser/highlighter/whatever? Is there an easy way to hook into and extend the existing highlighter?
I've already made a few small changes to one file in the source (TextEditor.xaml), and I'm willing to change more to make this work - though when I started I was hoping to touch the source as little as possible...
If someone could just point me in the right direction, I'd appreciate it - Thanks!
From the syntax highlighting documentation:
Among the text rendering extension points is the support for "visual
line transformers" that can change the display of a visual line after
it has been constructed by the "visual element generators". A useful
base class implementing IVisualLineTransformer for the purpose of
syntax highlighting is DocumentColorizingTransformer. Take a look at
that class' documentation to see how to write fully custom syntax
highlighters. This article only discusses the XML-driven built-in
highlighting engine.
Having read and/or scanned through that page a number of times, I couldn't fully grok this until I'd looked through the code a bit more, read some posts on the SharpDevelop forums, etc.
And if you're at the same stage I was (and can't quite wrap your head around that quote), the gist is that the editor does these two things (simplified, of course):
It generates lines of visible text (it only bothers with the lines
currently visible on the screen for performance reasons)
It then runs various transformers over said generated text, to style it in various ways
So the "XML-driven built-in highlighting engine" is only one way to find and style text - one that's meant to be a simple implementation of the more 'advanced' way, which is to build a custom text transformer, like a DocumentColorizingTransformer.
And here's some info on DocumentColorizingTransformer that you may find useful (besides the API documentation they point you to):
https://stackoverflow.com/a/23251990/859833
http://danielgrunwald.de/coding/AvalonEdit/rendering.php

Change color of multiple separated lines of text in Wordpress?

I want to change the color of multiple lines of text in Wordpress.
The lines are separated like this:
Line 1 (change to green)
some other lines
Line 2 (change to green)
some other lines
Line 3 (green)
I have used CTRL and selected all the lines but when I change the color it deselects all lines except for the last one?
I would also like to insert multiple horizontal rules at different points on a page without doing them one by one.
I think the text editor is defected if it won't allow a simple ctrl and select multiple items?
The problem with the Wordpress Visual Editor is that it was built for the lowest common denominator of users in mind. Basically, it's only useful for people with little to no experience in HTML and CSS.
Most of the time, the Visual Editor's output will either be just plain messy - or wrong - for developers to use it in a clean and concise way.
Your question has more to do with the usability of the Wordpress Visual Editor rather than HOW to use it. What I would suggest if you are not comfortable with editing your content using the HTML View (which can allow you to format your content on a much more granular level) is to copy all of your content into a Text Editor like Microsoft Word, making the changes you want, and then pasting everything back into the Editor.
It actually does fairly well using that method.
While Wordpress does the job in making things as easy as possible for the less technologically adept users, it is not foolproof. If you feel that its usability is flawed on a very fundamental level, my suggestion would be to contact the Wordpress Development team in the Wordpress forums.
Good luck.
http://wordpress.org/support/

Styling footnotes for markdown

I've been using footnotes in markdown pages as mentioned in this post on DaringFireball, but I can't seem to figure out how to get them styled the way I want. Adding .footnotes {} to my style sheet allows me to style the footnote text, but I'm missing two things:
In Gruber's post, his footnote's backlink is given a style "a.footnoteBackLink," but my page simply produces "a href="link" rev="footnote". I don't know how to call this in CSS and I have no idea how I'd change it so that my markdown page outputs any differently. My backlink goes to a separate line, and I'd like to have it on the same line. Perhaps this is an issue with the markdown engine; I'm using Maruku (I think), and I could probably figure out how to change it if I knew which one I should use instead.
No matter what I put in the footnote brackets, the page outputs numbered footnotes. How can I tell it to use asterisks or other symbols? Most pages with footnotes will have only one or two, and symbols are generally correct when there are less than seven footnotes, so I'd like to do things proper.
I probably shouldn't even say this, but I've been teaching myself web development for the past couple of months and I absolutely could not have done it without SO. This is the first time I haven't found my answer here, so it's my first time asking. I love you don't get mad at me please.
There is a great variety of conversion tools out there. Each may have a different way of handling this. I found remarkable a good choice for your issue. It adds the class "footnote-item" to each footnote.
Check the live demo and inspect the HTML Output.

Drupal with Texy and GeSHi

I have my Drupal installation set up to use both Texy for markup (hand-writing HTML soon gets tedious) and GeSHi for syntax highlighting (which is about the only syntax highlighter I found for Drupal at that time).
The problem now is that since the last update to Texy seemingly nothing really works anymore. I spend a long time trying to convince both of them working together a while ago but it was a pretty flaky setup. Depending on the order of evaluation of both filters I either get no syntax highlighting or all, escaped HTML output, line breaks disappear or, sometimes, it can indeed work.
I am now at a point where it almost works again, but with exceptions. Ideally GeSHi would take care of the code, while Texy handles the rest, but that's not the case. The nice regular expression
[1–9][0–9]*[WDwd][1–9][0–9]*(\+[1–9][0–9]*)?
gets the part between the first two asterisks italicized, since Texy runs over that part as well. Which is unfortunate, since it changes the meaning of the regex.
Anyone out here who has insights of how to peroperly set up multiple filters for input in Drupal and how to handle non-HTML markup and syntax highlighting simultaneously. As I currently have to go over every post that contains code I have written (nearly all) it wouldn probably not much less work to completely redo every page on the site in search for a better setup. As for syntax highlighting, I have much need for the usual common languages, such as C#, Java, etc. but also for more esoteric ones like Windows batch files or Powershell. Simply dumping unhighlighted code there isn't very pretty.
So, actually I have two questions here:
How can one convince multiple input filters to work without interfering with each other, specifically Texy and GeSHI?
What other options are out there that meet my requirements of easy-to-write non-HTML markup1 and syntax highlighting even for lesser-used languages2?
1 Often I just need emphasis and strong emphasis, sometimes headings, often images, sometimes also tables. Oh, and usually code :-)
2 The Stack Overflow-like guessing for syntax highlighting doesn't work very well for most code, it just works well enough to be a little pleasing.
To answer 2. I have had good results with markdown and GeSHI. I have no experience with Texy.
What you must pay very good attention to, is the combination of filter-format settings, filter-format ordering, filter-format permissions. For your problem, I would suggest the following input formats.
Basic HTML (default). Used for comments and so on.
Markdown (For editors, does what you describe)
Raw HTML (no filtering at all usefull for webmasters etc.)
Then configure them as follows, in this order:
Basic HTML:
URL filter
HTML filter. only allow inline styles em, strong, a. Maybe a very few more, but not br, p and such.
linebreak filter.
Markdown
HTML filter: strips all tags, except the "code" tags for GESHI.
Markdown filter.
Geshi filter.
This implies that markdown has no limits: people can use markdown to creat H1 tags, for example. If you want to limit the abilities in Markdown, you must place the HTML filter after the markdown filter. In that set-up, markdown will convert to full HTML, then the HTML-filters will strip the not-allowed filters.
Since GeSHI requires non-standard code tags, you will want to let them fall-trough. Since GeSHI adds a bucketload of spans, divs and color-coded style-elements, you will always need to put this filter after the HTML-filter, to avoid these spans- etc to be removed again

Resources