Testing highlight.js with R code

(This article was first published on jkunst.com: Posts for category R, and kindly contributed to R-bloggers)

I searched for a javascript plugin to highlighter code, but obviously not any code. I needed to higlight R. Finally I founded highlight.js. Highlights.js is pretty cool for many reasons. I like Highlights.js because:

  1. Support R lenguage.
  2. It’s easy to use. Works automatically. That’s mean you don’t have to put the code what are you writing. Highloght it does alone.
  3. A lot of styles.
  4. And yep! Again! Support R lenguage.
function(x, inf = -Inf, sup = Inf){
  if(missing(inf)) return(ifelse(x < sup, x, sup))
  if(missing(sup)) return(ifelse(x > inf, x, inf))
  x <- ifelse(x < sup, x ,sup)
  x <- ifelse(x > inf, x ,inf)
  return(x)
}

And an example of python code:

class RandomPostView(View):

    template_name = "blog/post.html"

    def get(self, request, *args, **kwargs):
        post = Post.objects.filter(status = 1).order_by('?')[0]
        return HttpResponse('Hello, World!')

Nice!

To leave a comment for the author, please follow the link and comment on their blog: jkunst.com: Posts for category R.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers


Sponsors

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)