GithubHelp home page GithubHelp logo

markup's Introduction

GitHub Markup

We use this library on GitHub when rendering your README or any other rich text file.

Markups

The following markups are supported. The dependencies listed are required if you wish to run the library.

  • .markdown -- gem install redcarpet
  • .textile -- gem install RedCloth
  • .rdoc
  • .org -- gem install org-ruby
  • .creole -- gem install creole
  • .mediawiki -- gem install wikicloth
  • .rst -- easy_install docutils
  • .asciidoc -- brew install asciidoc
  • .pod -- Pod::Simple::HTML comes with Perl >= 5.10. Lower versions should install Pod::Simple from CPAN.
  • .1 - Requires groff

Contributing

Want to contribute? Great! There are two ways to add markups.

Commands

If your markup is in a language other than Ruby, drop a translator script in lib/github/commands which accepts input on STDIN and returns HTML on STDOUT. See rest2html for an example.

Once your script is in place, edit lib/github/markups.rb and tell GitHub Markup about it. Again we look to rest2html for guidance:

command(:rest2html, /re?st(.txt)?/)

Here we're telling GitHub Markup of the existence of a rest2html command which should be used for any file ending in rest, rst, rest.txt or rst.txt. Any regular expression will do.

Finally add your tests. Create a README.extension in test/markups along with a README.extension.html. As you may imagine, the README.extension should be your known input and the README.extension.html should be the desired output.

Now run the tests: rake

If nothing complains, congratulations!

Classes

If your markup can be translated using a Ruby library, that's great. Check out Check lib/github/markups.rb for some examples. Let's look at Markdown:

markup(:markdown, /md|mkdn?|markdown/) do |content|
  Markdown.new(content).to_html
end

We give the markup method three bits of information: the name of the file to require, a regular expression for extensions to match, and a block to run with unformatted markup which should return HTML.

If you need to monkeypatch a RubyGem or something, check out the included RDoc example.

Tests should be added in the same manner as described under the Commands section.

Installation

gem install github-markup

Usage

require 'github/markup'
GitHub::Markup.render('README.markdown', "* One\n* Two")

Or, more realistically:

require 'github/markup'
GitHub::Markup.render(file, File.read(file))

Testing

To run the tests:

$ rake

To add tests see the Commands section earlier in this README.

Contributing

  1. Fork it.
  2. Create a branch (git checkout -b my_markup)
  3. Commit your changes (git commit -am "Added Snarkdown")
  4. Push to the branch (git push origin my_markup)
  5. Create an Issue with a link to your branch
  6. Enjoy a refreshing Diet Coke and wait

markup's People

Contributors

bdewey avatar dabrahams avatar defunkt avatar michaeljones avatar nicferrier avatar qmx avatar rjbs avatar rtomayko avatar technoweenie avatar tekkub avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.