github-markup-1.7.0/000755 001750 001750 00000000000 13401530721 014266 5ustar00srudsrud000000 000000 github-markup-1.7.0/Rakefile000644 001750 001750 00000000545 13401530721 015737 0ustar00srudsrud000000 000000 #!/usr/bin/env rake require "bundler/gem_tasks" require 'rake/testtask' Rake::TestTask.new(:test) do |test| test.libs << 'lib' << 'test' test.pattern = 'test/**/*_test.rb' test.verbose = true end desc "Open an irb session preloaded with this library" task :console do sh "irb -I lib -r bundler/setup -r github/markup" end task :default => :test github-markup-1.7.0/bin/000755 001750 001750 00000000000 13401530721 015036 5ustar00srudsrud000000 000000 github-markup-1.7.0/bin/github-markup000755 001750 001750 00000000753 13401530721 017550 0ustar00srudsrud000000 000000 #!/usr/bin/env ruby $LOAD_PATH.unshift File.dirname(File.realpath(__FILE__)) + "/../lib" require 'github/markup' if ARGV.size < 1 print "usage: #{File.basename($0)} FILE [ FILES ... ]\n" exit 1 end sources = [] ARGV.each { |s| begin file = File.open( s, "r" ) sources.push [ s, file ] rescue Exception => e $stderr.print "error: #{e.message}\n" exit 1 ensure end } sources.each { |name, file| print GitHub::Markup.render( name, file.read ) file.close } github-markup-1.7.0/LICENSE000644 001750 001750 00000002032 13401530721 015270 0ustar00srudsrud000000 000000 Copyright (c) 2009 GitHub Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. github-markup-1.7.0/.kick000644 001750 001750 00000001062 13401530721 015207 0ustar00srudsrud000000 000000 # take control of the growl notifications module GrowlHacks def growl(type, subject, body, *args, &block) case type when Kicker::GROWL_NOTIFICATIONS[:succeeded] puts subject = "Success" body = body.split("\n").last when Kicker::GROWL_NOTIFICATIONS[:failed] subject = "Failure" puts body body = body.split("\n").last else return nil end super(type, subject, body, *args, &block) end end Kicker.send :extend, GrowlHacks # no logging Kicker::Utils.module_eval do def log(message) nil end endgithub-markup-1.7.0/README.md000644 001750 001750 00000006573 13401530721 015560 0ustar00srudsrud000000 000000 GitHub Markup ============= This library is the first step of a journey that every markup file in a repository goes on before it is rendered on GitHub.com: 1. This library converts the raw markup to HTML. See the list of [supported markup formats](#markups) below. 1. The HTML is sanitized, aggressively removing things that could harm you and your kin—such as `script` tags, inline-styles, and `class` or `id` attributes. See the [sanitization filter](https://github.com/jch/html-pipeline/blob/master/lib/html/pipeline/sanitization_filter.rb) for the full whitelist. 1. Syntax highlighting is performed on code blocks. See [github/linguist](https://github.com/github/linguist#syntax-highlighting) for more information about syntax highlighting. 1. The HTML is passed through other filters in the [html-pipeline](https://github.com/jch/html-pipeline) that add special sauce, such as [emoji](https://github.com/jch/html-pipeline/blob/master/lib/html/pipeline/emoji_filter.rb), [task lists](https://github.com/github/task_list/blob/master/lib/task_list/filter.rb), [named anchors](https://github.com/jch/html-pipeline/blob/master/lib/html/pipeline/toc_filter.rb), [CDN caching for images](https://github.com/jch/html-pipeline/blob/master/lib/html/pipeline/camo_filter.rb), and [autolinking](https://github.com/jch/html-pipeline/blob/master/lib/html/pipeline/autolink_filter.rb). 1. The resulting HTML is rendered on GitHub.com. Please note that **only the first step** is covered by this gem — the rest happens on GitHub.com. In particular, `markup` itself does no sanitization of the resulting HTML, as it expects that to be covered by whatever pipeline is consuming the HTML. Please see our [contributing guidelines](CONTRIBUTING.md) before reporting an issue. Markups ------- The following markups are supported. The dependencies listed are required if you wish to run the library. You can also run `script/bootstrap` to fetch them all. * [.markdown, .mdown, .mkdn, .md](http://daringfireball.net/projects/markdown/) -- `gem install commonmarker` (https://github.com/gjtorikian/commonmarker) * [.textile](https://www.promptworks.com/textile) -- `gem install RedCloth` (https://github.com/jgarber/redcloth) * [.rdoc](https://ruby.github.io/rdoc/) -- `gem install rdoc -v 3.6.1` * [.org](http://orgmode.org/) -- `gem install org-ruby` (https://github.com/wallyqs/org-ruby) * [.creole](http://wikicreole.org/) -- `gem install creole` (https://github.com/larsch/creole) * [.mediawiki, .wiki](http://www.mediawiki.org/wiki/Help:Formatting) -- `gem install wikicloth` (https://github.com/nricciar/wikicloth) * [.rst](http://docutils.sourceforge.net/rst.html) -- `pip install docutils` * [.asciidoc, .adoc, .asc](http://asciidoc.org/) -- `gem install asciidoctor` (http://asciidoctor.org) * [.pod](http://search.cpan.org/dist/perl/pod/perlpod.pod) -- `Pod::Simple::XHTML` comes with Perl >= 5.10. Lower versions should install Pod::Simple from CPAN. Installation ----------- ``` gem install github-markup ``` Usage ----- Basic form: ```ruby require 'github/markup' GitHub::Markup.render('README.markdown', "* One\n* Two") ``` More realistic form: ```ruby require 'github/markup' GitHub::Markup.render(file, File.read(file)) ``` And a convenience form: ```ruby require 'github/markup' GitHub::Markup.render_s(GitHub::Markups::MARKUP_MARKDOWN, "* One\n* Two") ``` Contributing ------------ See [Contributing](CONTRIBUTING.md). github-markup-1.7.0/HISTORY.md000644 001750 001750 00000011421 13401530721 015750 0ustar00srudsrud000000 000000 ## 1.7.0 - 2018-01-30 ### Changed * Updates for Linguist v6 [#1139](https://github.com/github/markup/pull/1139) * Update to Nokogiri ~> 1.8; drop support for Ruby 2.0 [#1156](https://github.com/github/markup/pull/1156) ## 1.6.2 - 2017-11-27 ### Changed * Only report basename in usage [#1131](https://github.com/github/markup/pull/1131) * rest2html parameter signature fix [#1082](https://github.com/github/markup/pull/1082) ## 1.6.1 - 2017-07-25 ### Changed * Added support for highlight directive in rST [#925](https://github.com/github/markup/pull/925) * Fixes to documentation and code style [#1009](https://github.com/github/markup/pull/1009) [#1071](https://github.com/github/markup/pull/1071) [#1087](https://github.com/github/markup/pull/1087) * Test against newer Ruby versions [#1086](https://github.com/github/markup/pull/1086) * Upgrade to Asciidoctor 1.5.6.1 [#1088](https://github.com/github/markup/pull/1088) ## 1.6.0 - 2017-04-03 ### Changed * Added filename argument to all renderers for additional context * Removed superfluous `rinku` dependency [#1035](https://github.com/github/markup/pull/1035) * Enable source-to-source navigation for `.adoc` AsciiDoc files, plus additional attributes passed through [#1039](https://github.com/github/markup/pull/1039) and [#1041](https://github.com/github/markup/pull/1041) ## 1.5.0 - 2017-03-27 ### Added * Re-introduce [#537](https://github.com/github/markup/pull/537) to detect language of markup document However `github-linguist` is optional and this gem will fallback to extensions for detection. [Full changelog](https://github.com/github/markup/compare/v1.4.9...v1.5.0) ## 1.4.9 - 2017-03-27 ### Changed * Reverted [#537](https://github.com/github/markup/pull/537) to avoid extra dependencies [Full changelog](https://github.com/github/markup/compare/v1.4.8...v1.4.9) ## 1.3.3 (2015-02-17) * Address a slight typo with `POSIX` [#456](https://github.com/github/markup/pull/456) [Full changelog](https://github.com/github/markup/compare/v1.3.2...v1.3.3) ## 1.3.2 (2015-02-17) * RST: Output code instead of tt for inline literals [#370](https://github.com/github/markup/pull/370) * RST: Add IDs to headers so that `.. contents` works with `.. sectnum` [#391](https://github.com/github/markup/pull/391) [Full changelog](https://github.com/github/markup/compare/v1.3.1...v1.3.2) ## 1.3.1 (2014-11-13) * Fix name error when trying to use newer versions of RedCarpet [#387](https://github.com/github/markup/pull/387) [Full changelog](https://github.com/github/markup/compare/v1.3.0...v1.3.1) ## 1.3.0 (2014-09-11) * Extend the field limit for tables to 50 characters for RST [#306](https://github.com/github/markup/pull/306) * Add `.mkdn` as a supported markdown extension [#308](https://github.com/github/markup/pull/308) * Upgrade wikicloth to 0.8.1 [#317](https://github.com/github/markup/pull/317) * Force encoding of posix-spawn output [#338](https://github.com/github/markup/pull/338) * Add `.rmd` as a supported markdown extension [#343](https://github.com/github/markup/pull/343) [Full changelog](https://github.com/github/markup/compare/v1.2.1...v1.3.0) ## 1.2.1 (2014-04-23) * Disable RST warnings [#290](https://github.com/github/markup/pull/290) [Full changelog](https://github.com/github/markup/compare/v1.2.0...v1.2.1) ## 1.1.1 (2014-04-03) * Upgrade to org-ruby 0.9.1 * Set default encoding to UTF-8 for Python 2 ## 1.1.0 (2014-03-10) * Raise GitHub::Markup::CommandError if external command exits with a non-zero status. * Remove support for literate Haskell (see #266) ## 0.5.1 (2010-09-30) * Support relative path links in rdoc ## 0.5.0 (2010-07-07) * Added creole support ## 0.4.0 (2010-04-23) * Removed man page support until it's ready. ## 0.3.3 (2010-03-29) * UTF-8 works with ReST now. ## 0.3.2 (2010-03-25) * Improved test runner * Forgive ReST problems that aren't user errors. ## 0.3.1 (2010-03-22) * Add .rst.txt extension * Fix ASCII encoding error while using print u'\u010c' non-ASCII char and similar. ## 0.3.0 (2010-03-11) * man rendering * `github-markup` command line runner ## 0.2.2 (2010-02-09) * pod fixes from Ricardo Signes ## 0.2.1 (2010-01-25) * ReST fixes from Michael Jones ## 0.2.0 (2010-01-10) * org-mode support ## 0.1.7 (2009-11-17) * Ditch asciidoc2html, call asciidoc directly ## 0.1.6 (2009-11-17) * mdown ## 0.1.5 (2009-11-17) * Actually, if we can't render a thing then don't. Not once, not never. ## 0.1.4 (2009-11-17) * Bugfix: Missing commands return the input (instead of nothing) ## 0.1.3 (2009-11-02) * Strip the INDEX comments from POD ## 0.1.2 (2009-11-02) * Renamed to `github-markup` * Bugfix: POD rendering works now, not just index ## 0.1.1 (2009-11-02) * Added `GitHub::Markup.can_render?` helper. * Bugfix: Actually check file extensions ## 0.1.0 (2009-11-02) * First release github-markup-1.7.0/.gitignore000644 001750 001750 00000000074 13401530721 016257 0ustar00srudsrud000000 000000 *.pyc pkg/ .bundle Gemfile.lock vendor/ .project .buildpath github-markup-1.7.0/.travis.yml000644 001750 001750 00000001007 13401530721 016375 0ustar00srudsrud000000 000000 dist: trusty sudo: required language: ruby rvm: - 2.1.10 - 2.2.7 - 2.3.4 - 2.4.1 - jruby-9.1.9.0 jdk: - oraclejdk8 notifications: email: false git: depth: 10 before_install: - sudo apt-get update -qq - sudo apt-get install perl - curl -L http://cpanmin.us | perl - --sudo App::cpanminus - sudo cpanm --installdeps --notest Pod::Simple - sudo pip install docutils cache: - bundler - pip env: global: - "JRUBY_OPTS=-Xcext.enabled=true" matrix: allow_failures: - rvm: jruby-9.1.9.0 github-markup-1.7.0/test/000755 001750 001750 00000000000 13401530721 015245 5ustar00srudsrud000000 000000 github-markup-1.7.0/test/fixtures/000755 001750 001750 00000000000 13401530721 017116 5ustar00srudsrud000000 000000 github-markup-1.7.0/test/fixtures/fail.sh000755 001750 001750 00000000070 13401530721 020365 0ustar00srudsrud000000 000000 #!/usr/bin/env bash echo "failure message">&2 && false github-markup-1.7.0/test/markup_test.rb000644 001750 001750 00000010476 13401530721 020140 0ustar00srudsrud000000 000000 # encoding: UTF-8 $LOAD_PATH.unshift File.dirname(__FILE__) + "/../lib" require 'github/markup' require 'minitest/autorun' require 'html/pipeline' require 'nokogiri' require 'nokogiri/diff' def normalize_html(text) text.strip .gsub(/\s\s+/,' ') .gsub(/\p{Pi}|\p{Pf}|&quot;/u,'"') .gsub("\u2026",'...') end def assert_html_equal(expected, actual, msg = nil) assertion = Proc.new do expected_doc = Nokogiri::HTML(expected) {|config| config.noblanks} actual_doc = Nokogiri::HTML(actual) {|config| config.noblanks} expected_doc.search('//text()').each {|node| node.content = normalize_html node.content} actual_doc.search('//text()').each {|node| node.content = normalize_html node.content} ignore_changes = {"+" => Regexp.union(/^\s*id=".*"\s*$/), "-" => nil} expected_doc.diff(actual_doc) do |change, node| if change != ' ' && !node.blank? then break unless node.to_html =~ ignore_changes[change] end end end assert(assertion.call, msg) end class MarkupTest < Minitest::Test class MarkupFilter < HTML::Pipeline::Filter def call filename = context[:filename] GitHub::Markup.render(filename, File.read(filename)).strip.force_encoding("utf-8") end end Pipeline = HTML::Pipeline.new [ MarkupFilter, HTML::Pipeline::SanitizationFilter ] Dir['test/markups/README.*'].each do |readme| next if readme =~ /html$/ markup = readme.split('/').last.gsub(/^README\./, '') define_method "test_#{markup}" do skip "Skipping MediaWiki test because wikicloth is currently not compatible with JRuby." if markup == "mediawiki" && RUBY_PLATFORM == "java" source = File.read(readme) expected_file = "#{readme}.html" expected = File.read(expected_file).rstrip actual = Pipeline.to_html(nil, :filename => readme) if source != expected assert(source != actual, "#{markup} did not render anything") end diff = IO.popen("diff -u - #{expected_file}", 'r+') do |f| f.write actual f.close_write f.read end assert_html_equal expected, actual, <Title') assert_equal true, GitHub::Markup.can_render?('README.markdown', '=== Title') assert_equal true, GitHub::Markup.can_render?('README.rmd', '=== Title') assert_equal true, GitHub::Markup.can_render?('README.Rmd', '=== Title') assert_equal false, GitHub::Markup.can_render?('README.cmd', 'echo 1') assert_equal true, GitHub::Markup.can_render?('README.litcoffee', 'Title') end def test_each_render_has_a_name assert_equal "markdown", GitHub::Markup.renderer('README.md', '=== Title').name assert_equal "redcloth", GitHub::Markup.renderer('README.textile', '* One').name assert_equal "rdoc", GitHub::Markup.renderer('README.rdoc', '* One').name assert_equal "org-ruby", GitHub::Markup.renderer('README.org', '* Title').name assert_equal "creole", GitHub::Markup.renderer('README.creole', '= Title =').name assert_equal "wikicloth", GitHub::Markup.renderer('README.wiki', '

Title

').name assert_equal "asciidoctor", GitHub::Markup.renderer('README.adoc', '== Title').name assert_equal "restructuredtext", GitHub::Markup.renderer('README.rst', 'Title').name assert_equal "pod", GitHub::Markup.renderer('README.pod', '=begin').name end def test_rendering_by_symbol assert_equal '

test

', GitHub::Markup.render_s(GitHub::Markups::MARKUP_MARKDOWN, '`test`').strip end def test_raises_error_if_command_exits_non_zero GitHub::Markup.command(:doesntmatter, 'test/fixtures/fail.sh', /fail/, ['Java'], 'fail') assert GitHub::Markup.can_render?('README.java', 'stop swallowing errors') begin GitHub::Markup.render('README.java', "stop swallowing errors", false) rescue GitHub::Markup::CommandError => e assert_equal "failure message", e.message else fail "an exception was expected but was not raised" end end def test_preserve_markup content = "Noël" assert_equal content.encoding.name, GitHub::Markup.render('Foo.rst', content).encoding.name end end github-markup-1.7.0/test/markups/000755 001750 001750 00000000000 13401530721 016727 5ustar00srudsrud000000 000000 github-markup-1.7.0/test/markups/README.pod000644 001750 001750 00000004470 13401530721 020375 0ustar00srudsrud000000 000000 =head1 Matrixy =head2 INTRODUCTION This is a port of the MATLAB/Octave programming language to Parrot. See the ROADMAP file for more information on the status of this project, and what else needs to be done. =head2 ABOUT Primary goals are: =over 4 =item * Create a working compiler that understands the majority of the MATLAB/Octave programming language. =back =head2 IMPLEMENTATION This project is broken into three primary components: =over 4 =item * The first is the parser, located in the C directory. The parser proper is composed of three source files, F which is a Perl6Grammar file, and F which is the associated actions file written in NQP, and F which is the operator precedence parser. In addition, several helper functions used by the parser are located in C. =item * The second component is the library of builtin functions in the C directory. These functions are, currently, written primarily in PIR. Function names prefixed with an underscore are "private" functions for use with the parser. Other functions should have names which are the same as names for regular MATLAB or Octave functions, since they will be available to the HLL. These are also separated into different namespaces depending on visibility and utility. =item * A number of library functions are written in M, or mostly M with some inline PIR code in C. =back =head2 DEPENDENCIES Matrixy depends on these dependencies: =head3 Parrot To get a proper version of Parrot to build Matrixy, you will need to check out and build Parrot from source: svn co http://svn.parrot.org/parrot/trunk parrot cd parrot perl Configure.pl make && make test && make install-dev =head3 Parrot-Linear-Algebra The linear algebra package for Parrot is available separately and provides functionality required by Matrixy. This includes matrix data types and matrix manipulation libraries =head2 BUILDING Once all dependencies are in place, you can build Matrixy using this sequence of commands: perl Configure.pl nmake test =head2 TODO * Parser * Standard Builtins * Test against Octave Test Suite. =head2 BUGS Lots! =head2 CONTACT If you need to contact the Matrixy team, go to the project home page at: www.github.com\Whiteknight\matrixy github-markup-1.7.0/test/markups/README.rst.txt000644 001750 001750 00000001014 13401530721 021230 0ustar00srudsrud000000 000000 Header 1 ======== Example text. Header 2 -------- 1. Blah blah ``code`` blah 2. More ``code``, hooray 3. Somé UTF-8° ============== ========================================================== Travis http://travis-ci.org/tony/pullv Docs http://pullv.rtfd.org API http://pullv.readthedocs.org/en/latest/api.html Issues https://github.com/tony/pullv/issues Source https://github.com/tony/pullv ============== ========================================================== github-markup-1.7.0/test/markups/README.asciidoc.html000644 001750 001750 00000001411 13401530721 022324 0ustar00srudsrud000000 000000

Document Title

First Section

  • One

  • Two

Navigate from README.asciidoc to another document.

Another Section

Note
Here is some source code.
puts "Hello, World!"
  • ❏ todo

  • ✓ done

Another Section

content

github-markup-1.7.0/test/markups/README.rst.html000644 001750 001750 00000004427 13401530721 021370 0ustar00srudsrud000000 000000

Header 1

Subtitle

Example text.

Table of Contents

Header 2

  1. Blah blah code blah
  2. More code, hooray
  3. Somé UTF-8°

The UTF-8 quote character in this table used to cause python to go boom. Now docutils just silently ignores it.

A block of code
python.code('hooray')
>>> some_function()
'result'
>>> some_function()
'result'
Travis http://travis-ci.org/tony/pullv
Docs http://pullv.rtfd.org
API http://pullv.readthedocs.org/en/latest/api.html
Issues https://github.com/tony/pullv/issues
Source https://github.com/tony/pullv
Coverity Scan Build Status Coverity Scan Build Status

Field list

123456789 123456789 123456789 123456789 123456789 1:
  Uh-oh! This name is too long!
123456789 123456789 123456789 123456789 1234567890: this is a long name, but no problem!
123456789 12345: this is not so long, but long enough for the default!
123456789 1234: this should work even with the default :)

someone@somewhere.org

Press Ctrl+C to quit

RAW HTML!

p {color:blue;} github-markup-1.7.0/test/markups/README.rdoc000644 001750 001750 00000000242 13401530721 020533 0ustar00srudsrud000000 000000 * One * Two This is an {absolute link}[http://github.com]. So is this: http://github.com This is a {relative link}[link:rawr.html]. So is this: link:rawr.htmlgithub-markup-1.7.0/test/markups/README.litcoffee000644 001750 001750 00000001673 13401530721 021555 0ustar00srudsrud000000 000000 Literate CoffeeScript Test -------------------------- > Taken from https://github.com/jashkenas/coffee-script/blob/master/test/literate.litcoffee comment comment test "basic literate CoffeeScript parsing", -> ok yes now with a... test "broken up indentation", -> ... broken up ... do -> ... nested block. ok yes Code must be separated from text by a blank line. test "code blocks must be preceded by a blank line", -> The next line is part of the text and will not be executed. fail() ok yes Code in `backticks is not parsed` and... test "comments in indented blocks work", -> do -> do -> # Regular comment. ### Block comment. ### ok yes Regular [Markdown](http://example.com/markdown) features, like links and unordered lists, are fine: * I * Am * A * List Tabs work too: test "tabbed code", -> ok yes github-markup-1.7.0/test/markups/README.creole.html000644 001750 001750 00000002054 13401530721 022023 0ustar00srudsrud000000 000000

H1

H2

paragraph of text that will be turned into a paragraph element. It can go over several lines with line breaks, it will be turned into a contiguous paragraph element.

You can force a linebreak in your paragraph text
thusly.

  • a list element
    • sub list element
  • 2nd list element
pre formatted text

$ ls -la
total 56
drwxr-xr-x   6 nferrier users  4096 Jul  5 23:10 .
drwxr-x--- 120 nferrier users 12288 Jul  5 19:36 ..
drwxr-xr-x   2 nferrier users  4096 Jul  5 18:19 bin
-rw-r--r--   1 nferrier users     6 Jul  5 18:19 .gitignore
drwxr-xr-x   4 nferrier users  4096 Jul  5 23:10 .hg
-rw-r--r--   1 nferrier users  1182 Jul  5 18:19 HISTORY.md
-rw-r--r--   1 nferrier users   562 Jul  5 18:19 .kick
drwxr-xr-x   3 nferrier users  4096 Jul  5 18:19 lib
-rw-r--r--   1 nferrier users  1050 Jul  5 18:19 LICENSE
-rw-r--r--   1 nferrier users  1312 Jul  5 18:19 Rakefile
-rw-r--r--   1 nferrier users  3390 Jul  5 18:19 README.md
drwxr-xr-x   3 nferrier users  4096 Jul  5 18:19 test
github-markup-1.7.0/test/markups/README.org.html000644 001750 001750 00000011037 13401530721 021342 0ustar00srudsrud000000 000000

org-ruby

Status: Under Development
Location: http://github.com/wallyqs/org-ruby
Version: 0.9.0

1 Description

Helpful Ruby routines for parsing orgmode files. The most significant thing this library does today is convert orgmode files to textile. Currently, you cannot do much to customize the conversion. The supplied textile conversion is optimized for extracting “content” from the orgfile as opposed to “metadata.”

2 History

2.1 2014-02-08: Version 0.9.0

  • Let’s make sure #+INCLUDE: is not supported
  • And confirm that syntax highlight is supported
module GitHub
  module Markup
    VERSION = 'test'
    Version = VERSION
  end
end

2.2 2009-12-30: Version 0.5.1

  • Minor enhancement: Recognize lines starting with “:” as examples.
  • Minor enhancement: Recognize #+BEGIN_SRC as source blocks
  • Minor enhancement: Add “src” and “example” classes to <pre> blocks.

2.3 2009-12-30: Version 0.5.0

  • Parse (but not necessarily use) in-buffer settings. The following in-buffer settings are used:
    • Understand the #+TITLE: directive.
    • Exporting todo keywords (option todo:t)
    • Numbering headlines (option num:t)
    • Skipping text before the first headline (option skip:t)
    • Skipping tables (option |:nil)
    • Custom todo keywords
    • EXPORT_SELECT_TAGS and EXPORT_EXLUDE_TAGS for controlling parts of the tree to export
  • Rewrite “file:(blah).org” links to “http:(blah).html” links. This makes the inter-links to other org-mode files work.
  • Uses <th> tags inside table rows that precede table separators.
  • Bugfixes:
    • Headings now have HTML escaped.

2.4 2009-12-29: Version 0.4.2

  • Got rid of the extraneous newline at the start of code blocks.
  • Everything now shows up in code blocks, even org-mode metadata.
  • Fixed bugs:
    • Regressed smart double quotes with HTML escaping. Added a test case and fixed the regression.

2.5 2009-12-29: Version 0.4.1

  • HTML is now escaped by default
  • org-mode comments will show up in a code block.

2.6 2009-12-29: Version 0.4

  • The first thing output in HTML gets the class “title”
  • HTML output is now indented
  • Proper support for multi-paragraph list items.

    See? This paragraph is part of the last bullet.

  • Fixed bugs:
    • “rake spec” wouldn’t work on Linux. Needed “require ‘rubygems’”.

2.7 2009-12-27: Version 0.3

  • Uses rubypants to get better typography (smart quotes, ellipses, etc…).
  • Fixed bugs:
    • Tables and lists did not get properly closed at the end of file
    • You couldn’t do inline formatting inside table cells
    • Characters in PRE blocks were not HTML escaped.

2.8 2009-12-26: Version 0.2

  • Added to_html output on the parser.
  • Added support for the full range of inline markup: bold, italic, code, verbatim, underline, strikethrough.
  • Lots of refactoring to make the code more maintainable.

2.9 2009-12-23: Version 0.1

  • Added support for block code, like this:
      def flush!
      @logger.debug "FLUSH ==========> #{@output_type}"
      if (@output_type == :blank) then
        @output << "\n"
      elsif (@buffer.length > 0) then
        if @cancel_modifier then
          @output << "p. " if @output_type == :paragraph
          @cancel_modifier = false
        end
        @output << @paragraph_modifier if (@paragraph_modifier and not sticky_modifier?)
        @output << @buffer.textile_substitution << "\n"
      end
      @buffer = ""
    end
        
  • Major code cleanup: Created the OutputBuffer class that greatly simplified a lot of the messiness of textile conversion.
  • Added support for line breaks within list items.
github-markup-1.7.0/test/markups/README.pod.html000644 001750 001750 00000005042 13401530721 021334 0ustar00srudsrud000000 000000

Matrixy

INTRODUCTION

This is a port of the MATLAB/Octave programming language to Parrot. See the ROADMAP file for more information on the status of this project, and what else needs to be done.

ABOUT

Primary goals are:

  • Create a working compiler that understands the majority of the MATLAB/Octave programming language.

IMPLEMENTATION

This project is broken into three primary components:

  • The first is the parser, located in the src/parser/ directory. The parser proper is composed of three source files, grammar.pg which is a Perl6Grammar file, and actions.pm which is the associated actions file written in NQP, and grammar-oper.pm which is the operator precedence parser. In addition, several helper functions used by the parser are located in src/internals.

  • The second component is the library of builtin functions in the src/builtins/ directory. These functions are, currently, written primarily in PIR. Function names prefixed with an underscore are "private" functions for use with the parser. Other functions should have names which are the same as names for regular MATLAB or Octave functions, since they will be available to the HLL. These are also separated into different namespaces depending on visibility and utility.

  • A number of library functions are written in M, or mostly M with some inline PIR code in toolbox/.

DEPENDENCIES

Matrixy depends on these dependencies:

Parrot

To get a proper version of Parrot to build Matrixy, you will need to check out and build Parrot from source:

svn co http://svn.parrot.org/parrot/trunk parrot
cd parrot
perl Configure.pl
make && make test && make install-dev

Parrot-Linear-Algebra

The linear algebra package for Parrot is available separately and provides functionality required by Matrixy. This includes matrix data types and matrix manipulation libraries

BUILDING

Once all dependencies are in place, you can build Matrixy using this sequence of commands:

perl Configure.pl
nmake test

TODO

* Parser
* Standard Builtins
* Test against Octave Test Suite.

BUGS

Lots!

CONTACT

If you need to contact the Matrixy team, go to the project home page at:

www.github.com\Whiteknight\matrixy

github-markup-1.7.0/test/markups/README.rdoc.html000644 001750 001750 00000000430 13401530721 021475 0ustar00srudsrud000000 000000
  • One

  • Two

This is an absolute link. So is this: github.com

This is a relative link. So is this: rawr.html

github-markup-1.7.0/test/markups/README.asciidoc000644 001750 001750 00000000506 13401530721 021365 0ustar00srudsrud000000 000000 = Document Title == First Section * One * Two Refer to <> or <>. Navigate from {docname}{outfilesuffix} to <>. == Another Section NOTE: Here is some source code. ```ruby puts "Hello, World!" ``` * [ ] todo * [x] done == Another Section content github-markup-1.7.0/test/markups/README.toc.rst.html000644 001750 001750 00000002357 13401530721 022154 0ustar00srudsrud000000 000000

1   Introduction

1.1   What is pycparser?

pycparser is a parser for the C language, written in pure Python. It is a module designed to be easily integrated into applications that need to parse C source code.

1.2   What is it good for?

Anything that needs C code to be parsed. The following are some uses for pycparser, taken from real user reports:

  • C code obfuscator
  • Front-end for various specialized C compilers
  • Static code checker
  • Automatic unit-test discovery
  • Adding specialized extensions to the C language

pycparser is unique in the sense that it's written in pure Python - a very high level language that's easy to experiment with and tweak. To people familiar with Lex and Yacc, pycparser's code will be simple to understand.

github-markup-1.7.0/test/markups/README.litcoffee.html000644 001750 001750 00000002456 13401530721 022520 0ustar00srudsrud000000 000000

Literate CoffeeScript Test

Taken from https://github.com/jashkenas/coffee-script/blob/master/test/literate.litcoffee

comment comment

test "basic literate CoffeeScript parsing", ->
  ok yes

now with a...

test "broken up indentation", ->

... broken up ...

  do ->

... nested block.

    ok yes

Code must be separated from text by a blank line.

test "code blocks must be preceded by a blank line", ->

The next line is part of the text and will not be executed. fail()

  ok yes

Code in backticks is not parsed and...

test "comments in indented blocks work", ->
  do ->
    do ->
      # Regular comment.

      ###
        Block comment.
      ###

      ok yes

Regular Markdown features, like links and unordered lists, are fine:

  • I

  • Am

  • A

  • List

Tabs work too:

test "tabbed code", -> ok yes

github-markup-1.7.0/test/markups/README.directives.rst000644 001750 001750 00000005346 13401530721 022566 0ustar00srudsrud000000 000000 ================================================== restructuredText (rst) directives and comments ================================================== Introduction ================= An rst directive starts with two periods, and has a keyword followed by two colons, like this:: .. MyDirective:: The rst parser is quite flexible and configurable. Directives may be added for specialized operations. Sphinx is a system that was designed for writing documentation, and, for example, readthedocs.org uses sphinx. Display of rst files at github needs to cover two distinct use-cases: - The github display is the primary method for displaying the file (e.g. for README.rst files) - The github display is incidental to the primary method for displaying the file (e.g. for readthedocs documentation) Currently, github handles the first case fine, but could confuse viewers for the second case, because sometimes content is missing from the github display. It would seem that one possibility for distinguishing these two cases is to add a github directive to control the display. Unfortunately, this would place a burden on every other rst parser to ignore the github directive (some of them will error on unknown directives). Instead, we can assign semantic content to specific comments. This is a fairly ugly hack, but it has the benefit of not requiring any document changes that would create problems with any conformant parser. The proposed special comment is:: .. github display [on | off] If you pass this the "on" value, then all unknown directives will be displayed as literal code blocks. If you pass this the "off" value, then unknown directives will not be displayed. In addition to controlling the display of literal code blocks, this also allows you to show comments specifically for github. For example, somebody could place this at the top of their file:: .. github display This file was designed to be viewed at readthedocs. Some content will not display properly when viewing using the github browser. Tests ========== By default, unknown directives should be displayed. .. UnknownDirective:: This is an unknown directive it has a lot of stuff underneath it But we can turn this off, and the next directive should not be displayed. .. github display off .. UnknownDirective:: This is an unknown directive it has a lot of stuff underneath it Or we can turn it back on... .. github display on .. UnknownDirective:: This is an unknown directive (3) it has a lot of stuff underneath it Here is a comment that should display at github .. github display YOU SHOULD SEE THIS! And here is a comment that should not display at github .. foobar YOU SHOULD NOT SEE THIS! This concludes the tests. github-markup-1.7.0/test/markups/README.rmd000644 001750 001750 00000000024 13401530721 020364 0ustar00srudsrud000000 000000 # Title * One * Two github-markup-1.7.0/test/markups/README.creole000644 001750 001750 00000001771 13401530721 021065 0ustar00srudsrud000000 000000 = H1 = == H2 == paragraph of text that will be turned into a paragraph element. It can go over several lines with line breaks, it will be turned into a contiguous paragraph element. You can force a linebreak in your paragraph text\\thusly. * a list element ** sub list element * 2nd list element {{{ pre formatted text $ ls -la total 56 drwxr-xr-x 6 nferrier users 4096 Jul 5 23:10 . drwxr-x--- 120 nferrier users 12288 Jul 5 19:36 .. drwxr-xr-x 2 nferrier users 4096 Jul 5 18:19 bin -rw-r--r-- 1 nferrier users 6 Jul 5 18:19 .gitignore drwxr-xr-x 4 nferrier users 4096 Jul 5 23:10 .hg -rw-r--r-- 1 nferrier users 1182 Jul 5 18:19 HISTORY.md -rw-r--r-- 1 nferrier users 562 Jul 5 18:19 .kick drwxr-xr-x 3 nferrier users 4096 Jul 5 18:19 lib -rw-r--r-- 1 nferrier users 1050 Jul 5 18:19 LICENSE -rw-r--r-- 1 nferrier users 1312 Jul 5 18:19 Rakefile -rw-r--r-- 1 nferrier users 3390 Jul 5 18:19 README.md drwxr-xr-x 3 nferrier users 4096 Jul 5 18:19 test }}} github-markup-1.7.0/test/markups/README.textile000644 001750 001750 00000000014 13401530721 021257 0ustar00srudsrud000000 000000 * One * Two github-markup-1.7.0/test/markups/README.noformat.html000644 001750 001750 00000000013 13401530721 022370 0ustar00srudsrud000000 000000 * One * Twogithub-markup-1.7.0/test/markups/README.textile.html000644 001750 001750 00000000046 13401530721 022227 0ustar00srudsrud000000 000000
  • One
  • Two
github-markup-1.7.0/test/markups/README.directives.rst.html000644 001750 001750 00000005226 13401530721 023526 0ustar00srudsrud000000 000000

restructuredText (rst) directives and comments

Introduction

An rst directive starts with two periods, and has a keyword followed by two colons, like this:

.. MyDirective::

The rst parser is quite flexible and configurable. Directives may be added for specialized operations. Sphinx is a system that was designed for writing documentation, and, for example, readthedocs.org uses sphinx.

Display of rst files at github needs to cover two distinct use-cases:

  • The github display is the primary method for displaying the file (e.g. for README.rst files)
  • The github display is incidental to the primary method for displaying the file (e.g. for readthedocs documentation)

Currently, github handles the first case fine, but could confuse viewers for the second case, because sometimes content is missing from the github display.

It would seem that one possibility for distinguishing these two cases is to add a github directive to control the display.

Unfortunately, this would place a burden on every other rst parser to ignore the github directive (some of them will error on unknown directives).

Instead, we can assign semantic content to specific comments.

This is a fairly ugly hack, but it has the benefit of not requiring any document changes that would create problems with any conformant parser.

The proposed special comment is:

.. github display [on | off]

If you pass this the "on" value, then all unknown directives will be displayed as literal code blocks. If you pass this the "off" value, then unknown directives will not be displayed.

In addition to controlling the display of literal code blocks, this also allows you to show comments specifically for github.

For example, somebody could place this at the top of their file:

.. github display

  This file was designed to be viewed at readthedocs.  Some
  content will not display properly when viewing using the
  github browser.

Tests

By default, unknown directives should be displayed.

.. UnknownDirective::  This is an unknown directive

      it has a lot of stuff underneath it

But we can turn this off, and the next directive should not be displayed.

Or we can turn it back on...

.. UnknownDirective::  This is an unknown directive (3)

      it has a lot of stuff underneath it

Here is a comment that should display at github


YOU SHOULD SEE THIS!

And here is a comment that should not display at github

This concludes the tests.

github-markup-1.7.0/test/markups/README.rmd.html000644 001750 001750 00000000064 13401530721 021333 0ustar00srudsrud000000 000000

Title

  • One
  • Two
github-markup-1.7.0/test/markups/README.markdown.html000644 001750 001750 00000000044 13401530721 022371 0ustar00srudsrud000000 000000
  • One
  • Two
github-markup-1.7.0/test/markups/README.rst000644 001750 001750 00000003354 13401530721 020423 0ustar00srudsrud000000 000000 Header 1 ======== -------- Subtitle -------- Example text. .. contents:: Table of Contents Header 2 -------- 1. Blah blah ``code`` blah 2. More ``code``, hooray 3. Somé UTF-8° The UTF-8 quote character in this table used to cause python to go boom. Now docutils just silently ignores it. .. csv-table:: Things that are Awesome (on a scale of 1-11) :quote: ” Thing,Awesomeness Icecream, 7 Honey Badgers, 10.5 Nickelback, -2 Iron Man, 10 Iron Man 2, 3 Tabular Data, 5 Made up ratings, 11 .. code:: A block of code .. code:: python python.code('hooray') .. doctest:: ignored >>> some_function() 'result' >>> some_function() 'result' ============== ========================================================== Travis http://travis-ci.org/tony/pullv Docs http://pullv.rtfd.org API http://pullv.readthedocs.org/en/latest/api.html Issues https://github.com/tony/pullv/issues Source https://github.com/tony/pullv ============== ========================================================== .. image:: https://scan.coverity.com/projects/621/badge.svg :target: https://scan.coverity.com/projects/621 :alt: Coverity Scan Build Status .. image:: https://scan.coverity.com/projects/621/badge.svg :alt: Coverity Scan Build Status Field list ---------- :123456789 123456789 123456789 123456789 123456789 1: Uh-oh! This name is too long! :123456789 123456789 123456789 123456789 1234567890: this is a long name, but no problem! :123456789 12345: this is not so long, but long enough for the default! :123456789 1234: this should work even with the default :) someone@somewhere.org Press :kbd:`Ctrl+C` to quit .. raw:: html

RAW HTML!

github-markup-1.7.0/test/markups/README.rst.txt.html000644 001750 001750 00000001476 13401530721 022207 0ustar00srudsrud000000 000000

Header 1

Example text.

Header 2

  1. Blah blah code blah
  2. More code, hooray
  3. Somé UTF-8°
Travis http://travis-ci.org/tony/pullv
Docs http://pullv.rtfd.org
API http://pullv.readthedocs.org/en/latest/api.html
Issues https://github.com/tony/pullv/issues
Source https://github.com/tony/pullv
github-markup-1.7.0/test/markups/README.org000644 001750 001750 00000010175 13401530721 020401 0ustar00srudsrud000000 000000 #+TITLE: org-ruby #+AUTHOR: Brian Dewey #+EMAIL: bdewey@gmail.com #+DATE: 2009-12-21 #+DESCRIPTION: #+KEYWORDS: #+LANGUAGE: en #+OPTIONS: H:3 num:t toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t #+OPTIONS: TeX:t LaTeX:nil skip:nil d:nil todo:nil pri:nil tags:not-in-toc #+EXPORT_EXCLUDE_TAGS: exclude #+STARTUP: showall | Status: | Under Development | | Location: | [[http://github.com/wallyqs/org-ruby]] | | Version: | 0.9.0 | * Description Helpful Ruby routines for parsing orgmode files. The most significant thing this library does today is convert orgmode files to textile. Currently, you cannot do much to customize the conversion. The supplied textile conversion is optimized for extracting "content" from the orgfile as opposed to "metadata." * History ** 2014-02-08: Version 0.9.0 - Let's make sure =#+INCLUDE:= is not supported #+INCLUDE: "./README.txt" src text - And confirm that syntax highlight is supported #+begin_src ruby module GitHub module Markup VERSION = 'test' Version = VERSION end end #+end_src ** 2009-12-30: Version 0.5.1 - Minor enhancement: Recognize lines starting with ":" as examples. - Minor enhancement: Recognize #+BEGIN_SRC as source blocks - Minor enhancement: Add "src" and "example" classes to
 blocks.


** 2009-12-30: Version 0.5.0

   - Parse (but not necessarily *use*) in-buffer settings. The following
     in-buffer settings *are* used:
     - Understand the #+TITLE: directive.
     - Exporting todo keywords (option todo:t)
     - Numbering headlines (option num:t)
     - Skipping text before the first headline (option skip:t)
     - Skipping tables (option |:nil)
     - Custom todo keywords
     - EXPORT_SELECT_TAGS and EXPORT_EXLUDE_TAGS for controlling parts of
       the tree to export
   - Rewrite "file:(blah).org" links to "http:(blah).html" links. This
     makes the inter-links to other org-mode files work.
   - Uses  tags inside table rows that precede table separators.
   - Bugfixes:
     - Headings now have HTML escaped.

** 2009-12-29: Version 0.4.2

   - Got rid of the extraneous newline at the start of code blocks.
   - Everything now shows up in code blocks, even org-mode metadata.
   - Fixed bugs:
     - Regressed smart double quotes with HTML escaping. Added a test
       case and fixed the regression.

** 2009-12-29: Version 0.4.1
   - HTML is now escaped by default
   - org-mode comments will show up in a code block.

** 2009-12-29: Version 0.4

   - The first thing output in HTML gets the class "title"
   - HTML output is now indented
   - Proper support for multi-paragraph list items.

     See? This paragraph is part of the last bullet.
     
   - Fixed bugs:
     - "rake spec" wouldn't work on Linux. Needed "require 'rubygems'".

** 2009-12-27: Version 0.3

   - Uses rubypants to get better typography (smart quotes, ellipses, etc...).
   - Fixed bugs:
     - Tables and lists did not get properly closed at the end of file
     - You couldn't do inline formatting inside table cells
     - Characters in PRE blocks were not HTML escaped.
   
** 2009-12-26: Version 0.2

   - Added =to_html= output on the parser.
   - Added support for the full range of inline markup: *bold*,
     /italic/, =code=, ~verbatim~, _underline_, +strikethrough+.
   - Lots of refactoring to make the code more maintainable.

** 2009-12-23: Version 0.1

   - Added support for block code, like this:

     #+BEGIN_EXAMPLE
     def flush!
     @logger.debug "FLUSH ==========> #{@output_type}"
     if (@output_type == :blank) then
       @output << "\n"
     elsif (@buffer.length > 0) then
       if @cancel_modifier then
         @output << "p. " if @output_type == :paragraph
         @cancel_modifier = false
       end
       @output << @paragraph_modifier if (@paragraph_modifier and not sticky_modifier?)
       @output << @buffer.textile_substitution << "\n"
     end
     @buffer = ""
   end
   #+END_EXAMPLE

   - Major code cleanup: Created the =OutputBuffer= class that
     greatly simplified a lot of the messiness of =textile=
     conversion.
   - Added support for line breaks within list items.
github-markup-1.7.0/test/markups/README.markdown000644 001750 001750 00000000014 13401530721 021423 0ustar00srudsrud000000 000000 * One
* Two
github-markup-1.7.0/test/markups/README.txt000644 001750 001750 00000000014 13401530721 020420 0ustar00srudsrud000000 000000 * One
* Two
github-markup-1.7.0/test/markups/README.txt.html000644 001750 001750 00000000013 13401530721 021362 0ustar00srudsrud000000 000000 * One
* Twogithub-markup-1.7.0/test/markups/README.noformat000644 001750 001750 00000000014 13401530721 021426 0ustar00srudsrud000000 000000 * One
* Two
github-markup-1.7.0/test/markups/README.toc.rst000644 001750 001750 00000001524 13401530721 021204 0ustar00srudsrud000000 000000 .. contents::
    :backlinks: none

.. sectnum::

Introduction
============

What is pycparser?
------------------

**pycparser** is a parser for the C language, written in pure Python. It is a
module designed to be easily integrated into applications that need to parse
C source code.

What is it good for?
--------------------

Anything that needs C code to be parsed. The following are some uses for
**pycparser**, taken from real user reports:

* C code obfuscator
* Front-end for various specialized C compilers
* Static code checker
* Automatic unit-test discovery
* Adding specialized extensions to the C language

**pycparser** is unique in the sense that it's written in pure Python - a very
high level language that's easy to experiment with and tweak. To people familiar
with Lex and Yacc, **pycparser**'s code will be simple to understand.
github-markup-1.7.0/github-markup.gemspec000644 001750 001750 00000002325 13401530721 020414 0ustar00srudsrud000000 000000 require File.expand_path("../lib/github-markup", __FILE__)

Gem::Specification.new do |s|
  s.name          = "github-markup"
  s.version       = GitHub::Markup::VERSION
  s.summary       = "The code GitHub uses to render README.markup"
  s.description   = "This gem is used by GitHub to render any fancy markup such " +
                    "as Markdown, Textile, Org-Mode, etc. Fork it and add your own!"
  s.authors       = ["Chris Wanstrath"]
  s.email         = "chris@ozmm.org"
  s.homepage      = "https://github.com/github/markup"
  s.license       = "MIT"

  s.files         = `git ls-files`.split($\)
  s.executables   = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
  s.test_files    = s.files.grep(%r{^(test|spec|features)/})
  s.require_paths = %w[lib]

  s.add_development_dependency 'rake', '~> 12'
  s.add_development_dependency 'activesupport', '~> 4.0'
  s.add_development_dependency 'minitest', '~> 5.4', '>= 5.4.3'
  s.add_development_dependency 'html-pipeline', '~> 1.0'
  s.add_development_dependency 'sanitize', '~> 2.1', '>= 2.1.0'
  s.add_development_dependency 'nokogiri', '~> 1.8.1'
  s.add_development_dependency 'nokogiri-diff', '~> 0.2.0'
  s.add_development_dependency "github-linguist", "~> 6.0"
end
github-markup-1.7.0/lib/000755 001750 001750 00000000000 13401530721 015034 5ustar00srudsrud000000 000000 github-markup-1.7.0/lib/github-markup.rb000644 001750 001750 00000000124 13401530721 020135 0ustar00srudsrud000000 000000 module GitHub
  module Markup
    VERSION = '1.7.0'
    Version = VERSION
  end
end
github-markup-1.7.0/lib/github/000755 001750 001750 00000000000 13401530721 016316 5ustar00srudsrud000000 000000 github-markup-1.7.0/lib/github/commands/000755 001750 001750 00000000000 13401530721 020117 5ustar00srudsrud000000 000000 github-markup-1.7.0/lib/github/commands/pod2html000755 001750 001750 00000000526 13401530721 021601 0ustar00srudsrud000000 000000 #!/usr/bin/env perl

use strict;
use Pod::Simple::XHTML 3.11;

my $p = Pod::Simple::XHTML->new;
$p->html_header('');
$p->html_footer('');
$p->perldoc_url_prefix('https://metacpan.org/pod/');
$p->strip_verbatim_indent(sub {
    my $lines = shift;
    (my $indent = $lines->[0]) =~ s/\S.*//;
    return $indent;
});
$p->parse_from_file(shift);
github-markup-1.7.0/lib/github/commands/rest2html000755 001750 001750 00000023442 13401530721 021776 0ustar00srudsrud000000 000000 #!/usr/bin/env python
"""
rest2html - A small wrapper file for parsing ReST files at GitHub.

Written in 2008 by Jannis Leidel 

Brandon Keepers 
Bryan Veloso 
Chris Wanstrath 
Dave Abrahams 
Garen Torikian 
Gasper Zejn 
Michael Jones 
Sam Whited 
Tyler Chung 
Vicent Marti 

To the extent possible under law, the author(s) have dedicated all copyright
and related and neighboring rights to this software to the public domain
worldwide. This software is distributed without any warranty.

You should have received a copy of the CC0 Public Domain Dedication along with
this software. If not, see .
"""

__author__ = "Jannis Leidel"
__license__ = "CC0"
__version__ = "0.1"

import sys
import os

# This fixes docutils failing with unicode parameters to CSV-Table. The -S
# switch and the following 3 lines can be removed after upgrading to python 3.
if sys.version_info[0] < 3:
    reload(sys)
    sys.setdefaultencoding('utf-8')

import site

try:
    import locale
    locale.setlocale(locale.LC_ALL, '')
except:
    pass

import codecs
import io

from docutils import nodes
from docutils.parsers.rst import directives, roles
from docutils.parsers.rst.directives.body import CodeBlock, Directive
from docutils.core import publish_parts
from docutils.writers.html4css1 import Writer, HTMLTranslator
from docutils.parsers.rst.states import Body
from docutils import nodes

# By default, docutils provides two choices for unknown directives:
#  - Show errors if the reporting level is high enough
#  - Silently do not display them otherwise
# Comments are not displayed, either.

# This code monkey-patches docutils to show preformatted lines
# in both these cases.

# Recommended practice for repositories with rst files:
#  - If github is the preferred viewer for the rst files (e.g. README.rst),
#    then design the files to properly display for github.  E.g., do not
#    include unknown directives or restructuredText comments.
#  - If github is NOT the preferred viewer for the rst files (e.g.
#    the files are designed to be used with sphinx extensions at readthedocs)
#    then include a restructuredText comment at the top of the file
#    explaining that the document will display much more nicely with its
#    preferred viewer, e.g. at readthedocs.

original_behavior = False  # Documents original docutils behavior
github_display = True

def unknown_directive(self, type_name):
    lineno = self.state_machine.abs_line_number()
    indented, indent, offset, blank_finish = \
        self.state_machine.get_first_known_indented(0, strip_indent=False)
    text = '\n'.join(indented)
    if original_behavior:
        error = self.reporter.error(
              'Unknown directive type "%s".' % type_name,
              nodes.literal_block(text, text), line=lineno)
        return [error], blank_finish
    elif github_display:
        cls = ['unknown_directive']
        result = [nodes.literal_block(text, text, classes=cls)]
        return result, blank_finish
    else:
        return [nodes.comment(text, text)], blank_finish

def comment(self, match):
    if not match.string[match.end():].strip() \
            and self.state_machine.is_next_line_blank(): # an empty comment?
        return [nodes.comment()], 1 # "A tiny but practical wart."
    indented, indent, offset, blank_finish = \
            self.state_machine.get_first_known_indented(match.end())
    while indented and not indented[-1].strip():
        indented.trim_end()
    if not original_behavior:
        firstline = ''.join(indented[:1]).split()
        if ' '.join(firstline[:2]) == 'github display':
            if len(firstline) == 3 and firstline[2] in ('on', 'off'):
                global github_display
                github_display = firstline[2] == 'on'
            if len(indented) == 1:
                return [nodes.comment()], 1
            text = '\n'.join(indented[1:])
            cls = ['github_comment']
            result = [nodes.literal_block(text, text, classes=cls)]
            return result, blank_finish
    text = '\n'.join(indented)
    return [nodes.comment(text, text)], blank_finish

Body.comment = comment
Body.unknown_directive = unknown_directive


SETTINGS = {
    'cloak_email_addresses': False,
    'file_insertion_enabled': False,
    'raw_enabled': True,
    'strip_comments': True,
    'doctitle_xform': True,
    'initial_header_level': 2,
    'report_level': 5,
    'syntax_highlight': 'none',
    'math_output': 'latex',
    'field_name_limit': 50,
}

default_highlight_language = None

class HighlightDirective(Directive):
    required_arguments = 1
    optional_arguments = 1
    option_spec = {}
    def run(self):
        """Track the default syntax highlighting language
        """
        global default_highlight_language
        default_highlight_language = self.arguments[0]
        return []

class DoctestDirective(CodeBlock):
    """Render Sphinx 'doctest:: [group]' blocks as 'code:: python'
    """

    def run(self):
        """Discard any doctest group argument, render contents as python code
        """
        self.arguments = ['python']
        return super(DoctestDirective, self).run()


class GitHubHTMLTranslator(HTMLTranslator):

    # removes the 
tag wrapped around docs # see also: http://bit.ly/1exfq2h (warning! sourceforge link.) def depart_document(self, node): HTMLTranslator.depart_document(self, node) self.html_body.pop(0) # pop the starting
off self.html_body.pop() # pop the ending
off # technique for visiting sections, without generating additional divs # see also: http://bit.ly/NHtyRx # the a is to support ::contents with ::sectnums: http://git.io/N1yC def visit_section(self, node): id_attribute = node.attributes['ids'][0] self.body.append('\n' % id_attribute) self.section_level += 1 def depart_section(self, node): self.section_level -= 1 def visit_literal_block(self, node): classes = node.attributes['classes'] if len(classes) >= 2 and classes[0] == 'code': language = classes[1] del classes[:] self.body.append(self.starttag(node, 'pre', lang=language)) elif default_highlight_language is not None: self.body.append(self.starttag(node, 'pre', lang=default_highlight_language)) else: self.body.append(self.starttag(node, 'pre')) def visit_doctest_block(self, node): self.body.append(self.starttag(node, 'pre', lang='pycon')) # always wrap two-backtick rst inline literals in , not # this also avoids the generation of superfluous tags def visit_literal(self, node): self.body.append(self.starttag(node, 'code', suffix='')) def depart_literal(self, node): self.body.append('') def visit_table(self, node): classes = ' '.join(['docutils', self.settings.table_style]).strip() self.body.append( self.starttag(node, 'table', CLASS=classes)) def depart_table(self, node): self.body.append('\n') def depart_image(self, node): uri = node['uri'] ext = os.path.splitext(uri)[1].lower() # we need to swap RST's use of `object` with `img` tags # see http://git.io/5me3dA if ext == ".svg": # preserve essential attributes atts = {} for attribute, value in node.attributes.items(): # we have no time for empty values if value: if attribute == "uri": atts['src'] = value else: atts[attribute] = value # toss off `object` tag self.body.pop() # add on `img` with attributes self.body.append(self.starttag(node, 'img', **atts)) HTMLTranslator.depart_image(self, node) def kbd(name, rawtext, text, lineno, inliner, options={}, content=[]): return [nodes.raw('', '%s' % text, format='html')], [] def main(): """ Parses the given ReST file or the redirected string input and returns the HTML body. Usage: rest2html < README.rst rest2html README.rst """ try: text = codecs.open(sys.argv[1], 'r', 'utf-8').read() except IOError: # given filename could not be found return '' except IndexError: # no filename given if sys.version_info[0] < 3: # python 2.x text = sys.stdin.read() else: # python 3 input_stream = io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8') text = input_stream.read() writer = Writer() writer.translator_class = GitHubHTMLTranslator roles.register_canonical_role('kbd', kbd) # Render source code in Sphinx doctest blocks directives.register_directive('doctest', DoctestDirective) # Set default highlight language directives.register_directive('highlight', HighlightDirective) parts = publish_parts(text, writer=writer, settings_overrides=SETTINGS) if 'html_body' in parts: html = parts['html_body'] # publish_parts() in python 2.x return dict values as Unicode type # in py3k Unicode is unavailable and values are of str type if isinstance(html, str): return html else: return html.encode('utf-8') return '' if __name__ == '__main__': if sys.version_info[0] < 3: # python 2.x sys.stdout.write("%s%s" % (main(), "\n")) else: # python 3 output_stream = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8') output_stream.write("%s%s" % (main(), "\n")) sys.stdout.flush() github-markup-1.7.0/lib/github/markups.rb000644 001750 001750 00000003632 13401530721 020331 0ustar00srudsrud000000 000000 require "github/markup/markdown" require "github/markup/rdoc" require "shellwords" markup_impl(::GitHub::Markups::MARKUP_MARKDOWN, ::GitHub::Markup::Markdown.new) markup(::GitHub::Markups::MARKUP_TEXTILE, :redcloth, /textile/, ["Textile"]) do |filename, content| RedCloth.new(content).to_html end markup_impl(::GitHub::Markups::MARKUP_RDOC, GitHub::Markup::RDoc.new) markup(::GitHub::Markups::MARKUP_ORG, 'org-ruby', /org/, ["Org"]) do |filename, content| Orgmode::Parser.new(content, { :allow_include_files => false, :skip_syntax_highlight => true }).to_html end markup(::GitHub::Markups::MARKUP_CREOLE, :creole, /creole/, ["Creole"]) do |filename, content| Creole.creolize(content) end markup(::GitHub::Markups::MARKUP_MEDIAWIKI, :wikicloth, /mediawiki|wiki/, ["MediaWiki"]) do |filename, content| wikicloth = WikiCloth::WikiCloth.new(:data => content) WikiCloth::WikiBuffer::HTMLElement::ESCAPED_TAGS << 'tt' unless WikiCloth::WikiBuffer::HTMLElement::ESCAPED_TAGS.include?('tt') wikicloth.to_html(:noedit => true) end markup(::GitHub::Markups::MARKUP_ASCIIDOC, :asciidoctor, /adoc|asc(iidoc)?/, ["AsciiDoc"]) do |filename, content| attributes = { 'showtitle' => '@', 'idprefix' => '', 'idseparator' => '-', 'docname' => File.basename(filename, (extname = File.extname(filename))), 'docfilesuffix' => extname, 'outfilesuffix' => extname, 'env' => 'github', 'env-github' => '', 'source-highlighter' => 'html-pipeline' } Asciidoctor::Compliance.unique_id_start_index = 1 Asciidoctor.convert(content, :safe => :secure, :attributes => attributes) end command( ::GitHub::Markups::MARKUP_RST, "python2 -S #{Shellwords.escape(File.dirname(__FILE__))}/commands/rest2html", /re?st(\.txt)?/, ["reStructuredText"], "restructuredtext" ) command(::GitHub::Markups::MARKUP_POD, :pod2html, /pod/, ["Pod"], "pod") github-markup-1.7.0/lib/github/markup/000755 001750 001750 00000000000 13401530721 017615 5ustar00srudsrud000000 000000 github-markup-1.7.0/lib/github/markup/markdown.rb000644 001750 001750 00000003122 13401530721 021762 0ustar00srudsrud000000 000000 require "github/markup/implementation" module GitHub module Markup class Markdown < Implementation MARKDOWN_GEMS = { "commonmarker" => proc { |content| CommonMarker.render_html(content, :GITHUB_PRE_LANG, [:tagfilter, :autolink, :table, :strikethrough]) }, "github/markdown" => proc { |content| GitHub::Markdown.render(content) }, "redcarpet" => proc { |content| Redcarpet::Markdown.new(Redcarpet::Render::HTML).render(content) }, "rdiscount" => proc { |content| RDiscount.new(content).to_html }, "maruku" => proc { |content| Maruku.new(content).to_html }, "kramdown" => proc { |content| Kramdown::Document.new(content).to_html }, "bluecloth" => proc { |content| BlueCloth.new(content).to_html }, } def initialize super( /md|rmd|mkdn?|mdwn|mdown|markdown|litcoffee/i, ["Markdown", "RMarkdown", "Literate CoffeeScript"]) end def load return if @renderer MARKDOWN_GEMS.each do |gem_name, renderer| if try_require(gem_name) @renderer = renderer return end end raise LoadError, "no suitable markdown gem found" end def render(filename, content) load @renderer.call(content) end def name "markdown" end private def try_require(file) require file true rescue LoadError false end end end end github-markup-1.7.0/lib/github/markup/rdoc.rb000644 001750 001750 00000000774 13401530721 021101 0ustar00srudsrud000000 000000 require "github/markup/implementation" require "rdoc" require "rdoc/markup/to_html" module GitHub module Markup class RDoc < Implementation def initialize super(/rdoc/, ["RDoc"]) end def render(filename, content) if ::RDoc::VERSION.to_i >= 4 h = ::RDoc::Markup::ToHtml.new(::RDoc::Options.new) else h = ::RDoc::Markup::ToHtml.new end h.convert(content) end def name "rdoc" end end end end github-markup-1.7.0/lib/github/markup/implementation.rb000644 001750 001750 00000001434 13401530721 023171 0ustar00srudsrud000000 000000 module GitHub module Markup class Implementation attr_reader :regexp attr_reader :languages def initialize(regexp, languages) @regexp = regexp if defined?(::Linguist) @languages = languages.map {|l| Linguist::Language[l]} end end def load # no-op by default end def render(filename, content) raise NotImplementedError, "subclasses of GitHub::Markup::Implementation must define #render" end def match?(filename, language) if defined?(::Linguist) languages.include? language else file_ext_regexp =~ filename end end private def file_ext_regexp @file_ext_regexp ||= /\.(#{regexp})\z/ end end end end github-markup-1.7.0/lib/github/markup/gem_implementation.rb000644 001750 001750 00000001110 13401530721 024010 0ustar00srudsrud000000 000000 require "github/markup/implementation" module GitHub module Markup class GemImplementation < Implementation attr_reader :gem_name, :renderer def initialize(regexp, languages, gem_name, &renderer) super(regexp, languages) @gem_name = gem_name.to_s @renderer = renderer end def load return if @loaded require gem_name @loaded = true end def render(filename, content) load renderer.call(filename, content) end def name gem_name end end end end github-markup-1.7.0/lib/github/markup/command_implementation.rb000644 001750 001750 00000003350 13401530721 024666 0ustar00srudsrud000000 000000 begin require "posix-spawn" rescue LoadError require "open3" end require "github/markup/implementation" module GitHub module Markup class CommandError < RuntimeError end class CommandImplementation < Implementation attr_reader :command, :block, :name def initialize(regexp, languages, command, name, &block) super(regexp, languages) @command = command.to_s @block = block @name = name end def render(filename, content) rendered = execute(command, content) rendered = rendered.to_s.empty? ? content : rendered call_block(rendered, content) end private def call_block(rendered, content) if block && block.arity == 2 block.call(rendered, content) elsif block block.call(rendered) else rendered end end if defined?(POSIX::Spawn) def execute(command, target) spawn = POSIX::Spawn::Child.new(*command, :input => target) if spawn.status.success? sanitize(spawn.out, target.encoding) else raise CommandError.new(spawn.err.strip) end end else def execute(command, target) output = Open3.popen3(*command) do |stdin, stdout, stderr, wait_thr| stdin.puts target stdin.close if wait_thr.value.success? stdout.readlines else raise CommandError.new(stderr.readlines.join('').strip) end end sanitize(output.join(''), target.encoding) end end def sanitize(input, encoding) input.gsub("\r", '').force_encoding(encoding) end end end end github-markup-1.7.0/lib/github/markup.rb000644 001750 001750 00000005043 13401530721 020144 0ustar00srudsrud000000 000000 begin require "linguist" rescue LoadError # Rely on extensions instead. end require "github/markup/command_implementation" require "github/markup/gem_implementation" module GitHub module Markups # all of supported markups: MARKUP_ASCIIDOC = :asciidoc MARKUP_CREOLE = :creole MARKUP_MARKDOWN = :markdown MARKUP_MEDIAWIKI = :mediawiki MARKUP_ORG = :org MARKUP_POD = :pod MARKUP_RDOC = :rdoc MARKUP_RST = :rst MARKUP_TEXTILE = :textile end module Markup extend self @@markups = {} def markups @@markups end def markup_impls markups.values end def preload! markup_impls.each do |markup| markup.load end end def render(filename, content = nil, symlink = nil) content ||= File.read(filename) symlink = (File.symlink?(filename) rescue false) if symlink.nil? if impl = renderer(filename, content, symlink) impl.render(filename, content) else content end end def render_s(symbol, content) if content.nil? raise ArgumentError, 'Can not render a nil.' elsif markups.has_key?(symbol) markups[symbol].render(nil, content) else content end end def markup(symbol, gem_name, regexp, languages, opts = {}, &block) markup_impl(symbol, GemImplementation.new(regexp, languages, gem_name, &block)) end def markup_impl(symbol, impl) if markups.has_key?(symbol) raise ArgumentError, "The '#{symbol}' symbol is already defined." end markups[symbol] = impl end def command(symbol, command, regexp, languages, name, &block) if File.exist?(file = File.dirname(__FILE__) + "/commands/#{command}") command = file end markup_impl(symbol, CommandImplementation.new(regexp, languages, command, name, &block)) end def can_render?(filename, content, symlink = false) !!renderer(filename, content, symlink) end def renderer(filename, content, symlink = false) language = language(filename, content, symlink) markup_impls.find { |impl| impl.match?(filename, language) } end def language(filename, content, symlink = false) if defined?(::Linguist) blob = Linguist::Blob.new(filename, content, symlink: symlink) return Linguist.detect(blob, allow_empty: true) end end # Define markups markups_rb = File.dirname(__FILE__) + '/markups.rb' instance_eval File.read(markups_rb), markups_rb end end github-markup-1.7.0/Gemfile000644 001750 001750 00000000557 13401530721 015570 0ustar00srudsrud000000 000000 source "http://rubygems.org" gemspec gem "posix-spawn", :platforms => :ruby gem "redcarpet", :platforms => :ruby gem "kramdown", :platforms => :jruby gem "RedCloth" gem "commonmarker", "~> 0.14.12" gem "rdoc", "~>3.6" gem "org-ruby", "= 0.9.9" gem "creole", "~>0.3.6" gem "wikicloth", "=0.8.3" gem "twitter-text", "~> 1.14" gem "asciidoctor", "= 1.5.6.1" gem "rake" github-markup-1.7.0/CONTRIBUTING.md000644 001750 001750 00000004454 13401530721 016526 0ustar00srudsrud000000 000000 # Contributing This project adheres to the [Open Code of Conduct][code-of-conduct]. By participating, you are expected to honor this code. [code-of-conduct]: http://todogroup.org/opencodeofconduct/#GitHub%20Markup/opensource@github.com This library's only job is to decide which markup format to use and call out to an external library to convert the markup to HTML (see the [README](README.md) for more information on how markup is rendered on GitHub.com). If you are having an issue with: * **Syntax highlighting** - see [github/linguist](https://github.com/github/linguist/blob/master/CONTRIBUTING.md#fixing-syntax-highlighting) * **Markdown on GitHub** - contact support@github.com * **Styling issues on GitHub** - see [primer-markdown](https://github.com/primer/primer-css/tree/master/modules/primer-markdown) module in the [primer/primer-css](https://github.com/primer/primer-css) repository Anything else - [search open issues](https://github.com/github/markup/issues) or create an issue and and we'll help point you in the right direction. ## Submitting a Pull Request 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. Open a [Pull Request][1] 6. Enjoy a refreshing Diet Coke and wait **dependencies** You can run `script/bootstrap.contrib` to fetch them all. ## Testing To run the tests: $ rake If nothing complains, congratulations! ## Releasing a new version If you are the current maintainer of this gem: 0. Bump the version number in `lib/github-markup.rb`, adhering to [Semantic Versioning](http://semver.org/) 0. Update `HISTORY.md` 0. Test the latest version on GitHub 0. Build the new version with `rake build` 0. Copy `pkg/github-markup*.gem` to `vendor/cache` in your local checkout of GitHub 0. Update the version for `github-markup` in the `Gemfile` 0. Run `bundle update --local github-markup` 0. Run any relevant tests and test it manually from the browser. 0. Push the new gem release with `rake release`. If you don't have permission to release to rubygems.org, contact one of the existing owners (`gem owners github-markup`) and ask them to add you. [1]: http://github.com/github/markup/pulls [r2h]: lib/github/commands/rest2html [r2hc]: lib/github/markups.rb#L51 github-markup-1.7.0/script/000755 001750 001750 00000000000 13401530721 015572 5ustar00srudsrud000000 000000 github-markup-1.7.0/script/bootstrap.contrib000755 001750 001750 00000000475 13401530721 021202 0ustar00srudsrud000000 000000 #!/bin/bash set -e cd $(dirname "$0")/.. bundle install --path vendor/bundle virtualenv vendor/python && source vendor/python/bin/activate pip install docutils echo "" echo "*** DONE ***" echo "" echo "activate python environment with 'source vendor/python/bin/activate'" echo "run tests with 'bundle exec rake'" github-markup-1.7.0/script/bootstrap000755 001750 001750 00000000121 13401530721 017527 0ustar00srudsrud000000 000000 #!/bin/bash set -e cd $(dirname "$0")/.. bundle install easy_install docutils github-markup-1.7.0/script/cibuild000755 001750 001750 00000000627 13401530721 017140 0ustar00srudsrud000000 000000 #!/bin/bash set -e # GC customizations export RUBY_GC_MALLOC_LIMIT=79000000 export RUBY_HEAP_MIN_SLOTS=800000 export RUBY_HEAP_FREE_MIN=100000 export RUBY_HEAP_SLOTS_INCREMENT=400000 export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1 export PATH="/usr/share/rbenv/shims:$PATH" export RBENV_VERSION="1.9.3" # bootstrap gem environment changes echo "Bootstrapping gem environment ..." script/bootstrap --local rake