10000 Merge branch 'master' of https://github.com/github/markup into jruby-… · github/markup@c722768 · GitHub
[go: up one dir, main page]

Skip to content

Commit c722768

Browse files
author
Dawa Ometto
committed
Merge branch 'master' of https://github.com/github/markup into jruby-compatibility
Conflicts: .travis.yml github-markup.gemspec test/markup_test.rb
2 parents c3a0423 + 8d2b226 commit c722768

24 files changed

+239
-192
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
language: ruby
12
before_install: sudo pip install docutils
23
script: bundle exec rake test
34
rvm:
@@ -17,4 +18,4 @@ matrix:
1718
- rvm: 2.1.1
1819
jdk: oraclejdk7
1920
notifications:
20-
disabled: true
21+
email: false

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ gem "redcarpet", :platforms => :ruby
66
gem "kramdown", :platforms => :jruby
77
gem "RedCloth"
88
gem "rdoc", "~>3.6"
9-
gem "org-ruby", "= 0.9.1.gh"
9+
gem "org-ruby", "= 0.9.9"
1010
gem "creole", "~>0.3.6"
1111
gem "wikicloth", :platforms => :ruby
1212
gem "asciidoctor", "= 0.1.4"

HISTORY.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 1.3.1 (2014-11-13)
2+
3+
* Fix name error when trying to use newer versions of RedCarpet [#387](https://github.com/github/markup/pull/387)
4+
5+
[Full changelog](https://github.com/github/markup/compare/v1.3.0...v1.3.1)
6+
17
## 1.3.0 (2014-09-11)
28

39
* Extend the field limit for tables to 50 characters for RST [#306](https://github.com/github/markup/pull/306)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ you wish to run the library. You can also run `script/bootstrap` to fetch them a
1919
* [.rst](http://docutils.sourceforge.net/rst.html) -- `easy_install docutils`
2020
* [.asciidoc, .adoc, .asc](http://asciidoc.org/) -- `gem install asciidoctor` (http://asciidoctor.org)
2121
* [.pod](http://search.cpan.org/dist/perl/pod/perlpod.pod) -- `Pod::Simple::HTML`
22-
comes with Perl >= 5.10. Lowe F438 r versions should install Pod::Simple from CPAN.
22+
comes with Perl >= 5.10. Lower versions should install [Pod::Simple](http://search.cpan.org/~dwheeler/Pod-Simple-3.28/lib/Pod/Simple.pod) from CPAN.
2323

2424
Installation
2525
-----------

github-markup.gemspec

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ Gem::Specification.new do |s|
1818
s.extensions = "ext/mkrf_conf.rb"
1919

2020
# See ext/mkrf_conf.rb for platform-specific dependencies
21+
s.add_development_dependency 'minitest', '~> 5.4.3'
22+
s.add_development_dependency 'html-pipeline', '~> 1.0'
23+
s.add_development_dependency 'sanitize', '~> 3.0'
2124
s.add_development_dependency 'nokogiri', '~> 1.6.1'
2225
s.add_development_dependency 'nokogiri-diff', '~> 0.2.0'
2326
end

lib/github-markup.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module GitHub
22
module Markup
3-
VERSION = '1.3.0'
3+
VERSION = '1.3.1'
44
Version = VERSION
55
end
66
end

lib/github/commands/foo.rst

Lines changed: 0 additions & 7 deletions
This file was deleted.

lib/github/commands/rest2html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,14 @@ class GitHubHTMLTranslator(HTMLTranslator):
8686
else:
8787
self.body.append(self.starttag(node, 'pre'))
8888

89+
# always wrap two-backtick rst inline literals in <code>, not <tt>
90+
# this also avoids the generation of superfluous <span> tags
91+
def visit_literal(self, node):
92+
self.body.append(self.starttag(node, 'code', suffix=''))
93+
94+
def depart_literal(self, node):
95+
self.body.append('</code>')
96+
8997
def visit_table(self, node):
9098
classes = ' '.join(['docutils', self.settings.table_style]).strip()
9199
self.body.append(

lib/github/markup.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def markup(file, pattern, opts = {}, &block)
3131
end
3232

3333
def command(command, regexp, &block)
34-
if File.exists?(file = File.dirname(__FILE__) + "/commands/#{command}")
34+
if File.exist?(file = File.dirname(__FILE__) + "/commands/#{command}")
3535
command = file
3636
end
3737

lib/github/markup/markdown.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class Markdown < Implementation
88
GitHub::Markdown.render(content)
99
},
1010
"redcarpet" => proc { |content|
11-
RedcarpetCompat.new(content).to_html
11+
Redcarpet::Markdown.new(Redcarpet::Render::HTML).render(content)
1212
},
1313
"rdiscount" => proc { |content|
1414
RDiscount.new(content).to_html

test/markup_test.rb

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
$LOAD_PATH.unshif 10000 t File.dirname(__FILE__) + "/../lib"
44

55
require 'github/markup'
6-
require 'test/unit'
6+
require 'minitest/autorun'
7+
require 'html/pipeline'
78
require 'nokogiri'
89
require 'nokogiri/diff'
910

@@ -32,7 +33,19 @@ def assert_html_equal(expected, actual, msg = nil)
3233
end
3334
end
3435

35-
class MarkupTest < Test::Unit::TestCase
36+
class MarkupTest < Minitest::Test
37+
class MarkupFilter < HTML::Pipeline::Filter
38+
def call
39+
filename = context[:filename]
40+
GitHub::Markup.render(filename, File.read(filename)).strip.force_encoding("utf-8")
41+
end
42+
end
43+
44+
Pipeline = HTML::Pipeline.new [
45+
MarkupFilter,
46+
HTML::Pipeline::SanitizationFilter
47+
]
48+
3649
Dir['test/markups/README.*'].each do |readme|
3750
next if readme =~ /html$/
3851
markup = readme.split('/').last.gsub(/^README\./, '')
@@ -43,7 +56,7 @@ class MarkupTest < Test::Unit::TestCase
4356
source = File.read(readme)
4457
expected_file = "#{readme}.html"
4558
expected = File.read(expected_file).rstrip
46-
actual = GitHub::Markup.render(readme, File.read(readme)).rstrip.force_encoding("utf-8")
59+
actual = Pipeline.to_html(nil, :filename => readme)
4760

4861
if source != expected
4962
assert(source != actual, "#{markup} did not render anything")

test/markups/README.asciidoc.html

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<h1>Document Title</h1>
2-
<div class="sect1">
3-
<h2 id="first-section">First Section</h2>
4-
<div class="sectionbody">
5-
<div class="ulist">
2+
<div>
3+
<h2>First Section</h2>
4+
<div>
5+
<div>
66
<ul>
77
<li>
88
<p>One</p>
@@ -14,26 +14,25 @@ <h2 id="first-section">First Section</h2>
1414
</div>
1515
</div>
1616
</div>
17-
<div class="sect1">
18-
<h2 id="second-section">Second Section</h2>
19-
<div class="sectionbody">
20-
<div class="admonitionblock note">
17+
<div>
18+
<h2>Second Section</h2>
19+
<div>
20+
<div>
2121
<table>
2222
<tr>
23-
<td class="icon">
24-
<div class="title">Note</div>
23+
<td>
24+
<div>Note</div>
2525
</td>
26-
<td class="content">
26+
<td>
2727
Here is some source code.
2828
</td>
2929
</tr>
3030
</table>
3131
</div>
32-
<div class="listingblock">
33-
<div class="content">
32+
<div>
33+
<div>
3434
<pre lang="ruby"><code>puts "Hello, World!"</code></pre>
3535
</div>
3636
</div>
3737
</div>
38-
</div>
39-
38+
</div>

test/markups/README.creole.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
<h1>H1</h1><h2>H2</h2><p>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.</p><p>You can force a linebreak in your paragraph text<br/>thusly.</p><ul><li>a list element<ul><li>sub list element</li></ul></li><li>2nd list element</li></ul><pre>pre formatted text
1+
<h1>H1</h1><h2>H2</h2><p>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.</p><p>You can force a linebreak in your paragraph text<br>thusly.</p><ul>
2+
<li>a list element<ul><li>sub list element</li></ul>
3+
</li>
4+
<li>2nd list element</li>
5+
</ul><pre>pre formatted text
26

37
$ ls -la
48
total 56

test/markups/README.litcoffee.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ <h2>Literate CoffeeScript Test</h2>
66

77
<p>comment comment</p>
88

9-
<pre><code>test &quot;basic literate CoffeeScript parsing&quot;, -&gt;
9+
<pre><code>test "basic literate CoffeeScript parsing", -&gt;
1010
ok yes
1111
</code></pre>
1212

1313
<p>now with a...</p>
1414

15-
<pre><code>test &quot;broken up indentation&quot;, -&gt;
15+
<pre><code>test "broken up indentation", -&gt;
1616
</code></pre>
1717

1818
<p>... broken up ...</p>
@@ -27,7 +27,7 @@ <h2>Literate CoffeeScript Test</h2>
2727

2828
<p>Code must be separated from text by a blank line.</p>
2929

30-
<pre><code>test &quot;code blocks must be preceded by a blank line&quot;, -&gt;
30+
<pre><code>test "code blocks must be preceded by a blank line", -&gt;
3131
</code></pre>
3232

3333
<p>The next line is part of the text and will not be executed.
@@ -38,7 +38,7 @@ <h2>Literate CoffeeScript Test</h2>
3838

3939
<p>Code in <code>backticks is not parsed</code> and...</p>
4040

41-
<pre><code>test &quot;comments in indented blocks work&quot;, -&gt;
41+
<pre><code>test "comments in indented blocks work", -&gt;
4242
do -&gt;
4343
do -&gt;
4444
# Regular comment.
@@ -62,5 +62,5 @@ <h2>Literate CoffeeScript Test</h2>
6262

6363
<p>Tabs work too:</p>
6464

65-
<p>test &quot;tabbed code&quot;, -&gt;
66-
ok yes</p>
65+
<p>test "tabbed code", -&gt;
66+
ok yes</p>

test/markups/README.markdown.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<ul>
22
<li>One</li>
33
<li>Two</li>
4-
</ul>
4+
</ul>

test/markups/README.mediawiki.html

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
1-
2-
<p><a href="Home">&raquo; JRuby Project Wiki Home Page</a>
3-
<h1>Embedding JRuby</h1>
1+
<p><a href="Home">» JRuby Project Wiki Home Page</a>
2+
</p><h1>Embedding JRuby</h1>
43
Using Java from Ruby is JRuby's best-known feature---but you can also go in the other direction, and use Ruby from Java. There are several different ways to do this. You can execute entire Ruby scripts, call individual Ruby methods, or even implement a Java interface in Ruby (thus allowing you to treat Ruby objects like Java ones). We refer to all these techniques generically as "embedding." This section will explain how to embed JRuby in your Java project.
5-
</p>
6-
<p><table id="toc" class="toc" summary="Contents"><tr><td><div id="toctitle"><h2>Table of Contents</h2></div><ul></li><li><a href="#Red_Bridge_JRuby_Embed">Red Bridge (JRuby Embed)</a><ul><li><a href="#Features_of_Red_Bridge">Features of Red Bridge</a></li></ul><li><a href="#Previous_Embedding_JRuby_Page">Previous Embedding JRuby Page</a></li><li><a href="#References">References</a></li></ul></td></tr></table>
7-
</p>
84

9-
<h1><a name="Red_Bridge_JRuby_Embed"></a><span class="mw-headline" id="Red_Bridge_JRuby_Embed">Red Bridge (JRuby Embed)</span></h1>
5+
<p></p><table summary="Contents"><tr><td>
6+
<div><h2>Table of Contents</h2></div>
7+
<ul>
8+
<li>
9+
<a href="#Red_Bridge_JRuby_Embed">Red Bridge (JRuby Embed)</a><ul><li><a href="#Features_of_Red_Bridge">Features of Red Bridge</a></li></ul>
10+
</li>
11+
<li><a href="#Previous_Embedding_JRuby_Page">Previous Embedding JRuby Page</a></li>
12+
<li><a href="#References">References</a></li>
13+
</ul>
14+
</td></tr></table>
15+
16+
17+
<h1>
18+
<a name="Red_Bridge_JRuby_Embed"></a>Red Bridge (JRuby Embed)</h1>
1019

1120

1221

1322
<p>JRuby has long had a private embedding API, which was closely tied to the runtime's internals and therefore changed frequently as JRuby evolved. Since version 1.4, however, we have also provided a more stable public API, known as Red Bridge or JRuby Embed. Existing Java programs written to the <a href="DirectJRubyEmbedding">legacy API</a> should still work, but we strongly recommend Red Bridge for all new projects.
1423
</p>
1524

16-
<h2><a name="Features_of_Red_Bridge"></a><span class="mw-headline" id="Features_of_Red_Bridge">Features of Red Bridge</span></h2>
25+
<h2>
26+
<a name="Features_of_Red_Bridge"></a>Features of Red Bridge</h2>
1727

1828

1929
<p>Red Bridge consists of two layers: Embed Core on the bottom, and implementations of <a href="http://www.jcp.org/en/jsr/detail?id=223" target="_blank">JSR223</a> and <a href="http://jakarta.apache.org/bsf/" target="_blank">BSF</a> on top. Embed Core is JRuby-specific, and can take advantage of much of JRuby's power. JSR223 and BSF are more general interfaces that provide a common ground across scripting languages.
@@ -23,19 +33,25 @@ <h2><a name="Features_of_Red_Bridge"></a><span class="mw-headline" id="Features_
2333

2434

2535

26-
<p><ol><li>With Embed Core, you can create several Ruby environments in one JVM, and configure them individually (via <code>org.jruby.RubyInstanceConfig</code>. With the other APIs, configuration options can only be set globally, via the <code>System</code> properties.</li><li>Embed Core offers several shortcuts, such as loading scripts from a <code>java.io.InputStream</code>, or returning Java-friendly objects from Ruby code. These allow you to skip a lot of boilerplate.</li></ol>
36+
<p></p><ol>
37+
<li>With Embed Core, you can create several Ruby environments in one JVM, and configure them individually (via <code>org.jruby.RubyInstanceConfig</code>. With the other APIs, configuration options can only be set globally, via the <code>System</code> properties.</li>
38+
<li>Embed Core offers several shortcuts, such as loading scripts from a <code>java.io.InputStream</code>, or returning Java-friendly objects from Ruby code. These allow you to skip a lot of boilerplate.</li>
39+
</ol>
2740
For projects requiring multiple scripting languages, JSR223 is a good fit. Though the API is language-independent, JRuby's implementation of it allows you to set some Ruby-specific options. In particular, you can control the threading model of the scripting engine, the lifetime of local variables, compilation mode, and how line numbers are displayed.
28-
</p>
41+
2942
<p>The full <a href="http://jruby-embed.kenai.com/docs/" target="_blank">API documentation</a> has all the gory details. It's worth talking about a couple of the finer points here.
3043
</p>
3144

32-
<h1><a name="Previous_Embedding_JRuby_Page"></a><span class="mw-headline" id="Previous_Embedding_JRuby_Page">Previous Embedding JRuby Page</span></h1>
45+
<h1>
46+
<a name="Previous_Embedding_JRuby_Page"></a>Previous Embedding JRuby Page</h1>
3347

3448

35-
<p>We recommend using Embed Core; however, if you're maintaining code that uses the old API, you can find its documentation on the <a href="JavaIntegration">legacy embedding</a><sup class="reference" id="cite_ref-1-0">[<a href="#cite_note-1">1</a>]</sup> page.
49+
<p>We recommend using Embed Core; however, if you're maintaining code that uses the old API, you can find its documentation on the <a href="JavaIntegration">legacy embedding</a><sup>[<a href="#cite_note-1">1</a>]</sup> page.
3650
</p>
3751

38-
<h1><a name="References"></a><span class="mw-headline" id="References">References</span></h1>
52+
<h1>
53+
<a name="References"></a>References</h1>
3954

4055

41-
<p><ol><li id="cite_note-1"><b><a href="#cite_ref-1-0">^</a> </b> This link goes nowhere.</li></ol></p>
56+
<p></p><ol><li>
57+
<b><a href="#cite_ref-1-0">^</a> </b> This link goes nowhere.</li></ol>

test/markups/README.noformat.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
* One
2-
* Two
2+
* Two

0 commit comments

Comments
 (0)
0