GithubHelp home page GithubHelp logo

e9t / render-code Goto Github PK

View Code? Open in Web Editor NEW

This project forked from octopress/render-code

0.0 2.0 1.0 107 KB

Embed highlighted code snippets from a file.

License: MIT License

Ruby 56.51% CoffeeScript 1.82% HTML 41.67%

render-code's Introduction

Octopress Render Code

Embed code snippets from the file system in your Jekyll site.

Build Status Gem Version

Installation

Using Bundler

Add this gem to your site's Gemfile in the :jekyll_plugins group:

group :jekyll_plugins do
  gem 'octopress-render-code'
end

Then install the gem with Bundler

$ bundle

Manual Installation

$ gem install octopress-render-code

Then add the gem to your Jekyll configuration.

gems:
  -octopress-render-code

Usage

{% render_code <FILE> [options] %}

Configuration

In your site's configuration, you can set the directory for embedded code samples.

code_dir: code-examples

The default directory is 'downloads/code'

Options

Note that order does not matter.

Options Example Description
lang lang:ruby Defaults to guessing from file name extension.
title title:"Figure 1.A" Add a figcaption title to your code block.
link_text link_text:"Download" Text for the link, default: "Raw code".
linenos lineos:false Disable line numbering.
start start:5 Start embedding the script from the 5th line number.
end end:15 Stop embedding the script after 15th line number.
range range:5-15 Embed lines 5-15 of the script.
mark mark:5-7,10 Highlight lines of code. This example marks lines 5,6,7 and 10.
class class:"solution" Add CSS class name(s) to the code <figure> element.

Example

Given the existence of a file

{% render figure-1-a.js title:"Figure A: A Simple AJAX Request." mark:5-8

This will

  • Embed and highlight a file at [site_source]/downloads/code/figure-1-a.js
  • Give it a figcaption "Figure A: A Simple AJAX Request
  • Visually mark lines 5,6,7, and 8.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

render-code's People

Contributors

e9t avatar imathis avatar

Watchers

 avatar  avatar

Forkers

ithanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.