Skip to content

Commit

Permalink
Use sanitization filter in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bkeepers committed Dec 22, 2014
1 parent ef25634 commit ebe8e64
Show file tree
Hide file tree
Showing 14 changed files with 198 additions and 174 deletions.
5 changes: 3 additions & 2 deletions test/markup_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ class MarkupTest < Minitest::Test
class MarkupFilter < HTML::Pipeline::Filter
def call
filename = context[:filename]
GitHub::Markup.render(filename, File.read(filename)).rstrip.force_encoding("utf-8")
GitHub::Markup.render(filename, File.read(filename)).strip.force_encoding("utf-8")
end
end

Pipeline = HTML::Pipeline.new [
MarkupFilter
MarkupFilter,
HTML::Pipeline::SanitizationFilter
]

Dir['test/markups/README.*'].each do |readme|
Expand Down
29 changes: 14 additions & 15 deletions test/markups/README.asciidoc.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<h1>Document Title</h1>
<div class="sect1">
<h2 id="first-section">First Section</h2>
<div class="sectionbody">
<div class="ulist">
<div>
<h2>First Section</h2>
<div>
<div>
<ul>
<li>
<p>One</p>
Expand All @@ -14,26 +14,25 @@ <h2 id="first-section">First Section</h2>
</div>
</div>
</div>
<div class="sect1">
<h2 id="second-section">Second Section</h2>
<div class="sectionbody">
<div class="admonitionblock note">
<div>
<h2>Second Section</h2>
<div>
<div>
<table>
<tr>
<td class="icon">
<div class="title">Note</div>
<td>
<div>Note</div>
</td>
<td class="content">
<td>
Here is some source code.
</td>
</tr>
</table>
</div>
<div class="listingblock">
<div class="content">
<div>
<div>
<pre lang="ruby"><code>puts "Hello, World!"</code></pre>
</div>
</div>
</div>
</div>

</div>
6 changes: 5 additions & 1 deletion test/markups/README.creole.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<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
<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

$ ls -la
total 56
Expand Down
12 changes: 6 additions & 6 deletions test/markups/README.litcoffee.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ <h2>Literate CoffeeScript Test</h2>

<p>comment comment</p>

<pre><code>test &quot;basic literate CoffeeScript parsing&quot;, -&gt;
<pre><code>test "basic literate CoffeeScript parsing", -&gt;
ok yes
</code></pre>

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

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

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

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

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

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

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

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

<p>Tabs work too:</p>

<p>test &quot;tabbed code&quot;, -&gt;
ok yes</p>
<p>test "tabbed code", -&gt;
ok yes</p>
2 changes: 1 addition & 1 deletion test/markups/README.markdown.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<ul>
<li>One</li>
<li>Two</li>
</ul>
</ul>
44 changes: 30 additions & 14 deletions test/markups/README.mediawiki.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@

<p><a href="Home">&raquo; JRuby Project Wiki Home Page</a>
<h1>Embedding JRuby</h1>
<p><a href="Home">» JRuby Project Wiki Home Page</a>
</p><h1>Embedding JRuby</h1>
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.
</p>
<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>
</p>

<h1><a name="Red_Bridge_JRuby_Embed"></a><span class="mw-headline" id="Red_Bridge_JRuby_Embed">Red Bridge (JRuby Embed)</span></h1>
<p></p><table summary="Contents"><tr><td>
<div><h2>Table of Contents</h2></div>
<ul>
<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>
<li><a href="#Previous_Embedding_JRuby_Page">Previous Embedding JRuby Page</a></li>
<li><a href="#References">References</a></li>
</ul>
</td></tr></table>


<h1>
<a name="Red_Bridge_JRuby_Embed"></a>Red Bridge (JRuby Embed)</h1>



<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.
</p>

<h2><a name="Features_of_Red_Bridge"></a><span class="mw-headline" id="Features_of_Red_Bridge">Features of Red Bridge</span></h2>
<h2>
<a name="Features_of_Red_Bridge"></a>Features of Red Bridge</h2>


<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.
Expand All @@ -23,19 +33,25 @@ <h2><a name="Features_of_Red_Bridge"></a><span class="mw-headline" id="Features_



<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>
<p></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>
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.
</p>

<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.
</p>

<h1><a name="Previous_Embedding_JRuby_Page"></a><span class="mw-headline" id="Previous_Embedding_JRuby_Page">Previous Embedding JRuby Page</span></h1>
<h1>
<a name="Previous_Embedding_JRuby_Page"></a>Previous Embedding JRuby Page</h1>


<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.
<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.
</p>

<h1><a name="References"></a><span class="mw-headline" id="References">References</span></h1>
<h1>
<a name="References"></a>References</h1>


<p><ol><li id="cite_note-1"><b><a href="#cite_ref-1-0">^</a> </b> This link goes nowhere.</li></ol></p>
<p></p><ol><li>
<b><a href="#cite_ref-1-0">^</a> </b> This link goes nowhere.</li></ol>
2 changes: 1 addition & 1 deletion test/markups/README.noformat.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
* One
* Two
* Two
77 changes: 43 additions & 34 deletions test/markups/README.org.html
Original file line number Diff line number Diff line change
@@ -1,38 +1,47 @@
<h1 class="title">org-ruby</h1>
<h1>org-ruby</h1>
<table>
<tr><td>Status:</td><td>Under Development</td></tr>
<tr><td>Location:</td><td><a href="http://github.com/wallyqs/org-ruby">http://github.com/wallyqs/org-ruby</a></td></tr>
<tr><td>Version:</td><td>0.9.0</td></tr>
<tr>
<td>Status:</td>
<td>Under Development</td>
</tr>
<tr>
<td>Location:</td>
<td><a href="http://github.com/wallyqs/org-ruby">http://github.com/wallyqs/org-ruby</a></td>
</tr>
<tr>
<td>Version:</td>
<td>0.9.0</td>
</tr>
</table>
<h1><span class="heading-number heading-number-1">1</span> Description</h1>
<h1>1 Description</h1>
<p>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 &#8220;content&#8221; from the orgfile as opposed to &#8220;metadata.&#8221;</p>
<h1><span class="heading-number heading-number-1">2</span> History</h1>
<h2><span class="heading-number heading-number-2">2.1</span> 2014-02-08: Version 0.9.0</h2>
extracting content from the orgfile as opposed to metadata.</p>
<h1>2 History</h1>
<h2>2.1 2014-02-08: Version 0.9.0</h2>
<ul>
<li>Let&#8217;s make sure <code>#+INCLUDE:</code> is not supported</li>
<li>Lets make sure <code>#+INCLUDE:</code> is not supported</li>
</ul>
<ul>
<li>And confirm that syntax highlight is supported</li>
</ul>
<pre class="src" lang="ruby">
<pre lang="ruby">
module GitHub
module Markup
VERSION = &#39;test&#39;
VERSION = 'test'
Version = VERSION
end
end
</pre>
<h2><span class="heading-number heading-number-2">2.2</span> 2009-12-30: Version 0.5.1</h2>
<h2>2.2 2009-12-30: Version 0.5.1</h2>
<ul>
<li>Minor enhancement: Recognize lines starting with &#8220;:&#8221; as examples.</li>
<li>Minor enhancement: Recognize lines starting with “:” as examples.</li>
<li>Minor enhancement: Recognize #+BEGIN_SRC as source blocks</li>
<li>Minor enhancement: Add &#8220;src&#8221; and &#8220;example&#8221; classes to &lt;pre&gt; blocks.</li>
<li>Minor enhancement: Add src and example classes to &lt;pre&gt; blocks.</li>
</ul>
<h2><span class="heading-number heading-number-2">2.3</span> 2009-12-30: Version 0.5.0</h2>
<h2>2.3 2009-12-30: Version 0.5.0</h2>
<ul>
<li>Parse (but not necessarily <b>use</b>) in-buffer settings. The following
in-buffer settings <b>are</b> used:
Expand All @@ -47,7 +56,7 @@ <h2><span class="heading-number heading-number-2">2.3</span> 2009-12-30: Version
the tree to export</li>
</ul>
</li>
<li>Rewrite &#8220;file:(blah).org&#8221; links to &#8220;http:(blah).html&#8221; links. This
<li>Rewrite file:(blah).org links to http:(blah).html links. This
makes the inter-links to other org-mode files work.</li>
<li>Uses &lt;th&gt; tags inside table rows that precede table separators.</li>
<li>Bugfixes:
Expand All @@ -56,7 +65,7 @@ <h2><span class="heading-number heading-number-2">2.3</span> 2009-12-30: Version
</ul>
</li>
</ul>
<h2><span class="heading-number heading-number-2">2.4</span> 2009-12-29: Version 0.4.2</h2>
<h2>2.4 2009-12-29: Version 0.4.2</h2>
<ul>
<li>Got rid of the extraneous newline at the start of code blocks.</li>
<li>Everything now shows up in code blocks, even org-mode metadata.</li>
Expand All @@ -67,64 +76,64 @@ <h2><span class="heading-number heading-number-2">2.4</span> 2009-12-29: Version
</ul>
</li>
</ul>
<h2><span class="heading-number heading-number-2">2.5</span> 2009-12-29: Version 0.4.1</h2>
<h2>2.5 2009-12-29: Version 0.4.1</h2>
<ul>
<li>HTML is now escaped by default</li>
<li>org-mode comments will show up in a code block.</li>
</ul>
<h2><span class="heading-number heading-number-2">2.6</span> 2009-12-29: Version 0.4</h2>
<h2>2.6 2009-12-29: Version 0.4</h2>
<ul>
<li>The first thing output in HTML gets the class &#8220;title&#8221;</li>
<li>The first thing output in HTML gets the class title</li>
<li>HTML output is now indented</li>
<li>Proper support for multi-paragraph list items.
<p>See? This paragraph is part of the last bullet.</p>
</li>
<li>Fixed bugs:
<ul>
<li>&#8220;rake spec&#8221; wouldn&#8217;t work on Linux. Needed &#8220;require &#8216;rubygems&#8217;&#8221;.</li>
<li>rake spec wouldnt work on Linux. Needed require rubygems’”.</li>
</ul>
</li>
</ul>
<h2><span class="heading-number heading-number-2">2.7</span> 2009-12-27: Version 0.3</h2>
<h2>2.7 2009-12-27: Version 0.3</h2>
<ul>
<li>Uses rubypants to get better typography (smart quotes, elipses, etc&#8230;).</li>
<li>Uses rubypants to get better typography (smart quotes, elipses, etc).</li>
<li>Fixed bugs:
<ul>
<li>Tables and lists did not get properly closed at the end of file</li>
<li>You couldn&#8217;t do inline formatting inside table cells</li>
<li>You couldnt do inline formatting inside table cells</li>
<li>Characters in PRE blocks were not HTML escaped.</li>
</ul>
</li>
</ul>
<h2><span class="heading-number heading-number-2">2.8</span> 2009-12-26: Version 0.2</h2>
<h2>2.8 2009-12-26: Version 0.2</h2>
<ul>
<li>Added <code>to_html</code> output on the parser.</li>
<li>Added support for the full range of inline markup: <b>bold</b>,
<i>italic</i>, <code>code</code>, <code>verbatim</code>, <span style="text-decoration:underline;">underline</span>, <del>strikethrough</del>.</li>
<i>italic</i>, <code>code</code>, <code>verbatim</code>, underline, <del>strikethrough</del>.</li>
<li>Lots of refactoring to make the code more maintainable.</li>
</ul>
<h2><span class="heading-number heading-number-2">2.9</span> 2009-12-23: Version 0.1</h2>
<h2>2.9 2009-12-23: Version 0.1</h2>
<ul>
<li>Added support for block code, like this:
<pre class="example">
<pre>
def flush!
@logger.debug &quot;FLUSH ==========&gt; #{@output_type}&quot;
@logger.debug "FLUSH ==========&gt; #{@output_type}"
if (@output_type == :blank) then
@output &lt;&lt; &quot;\n&quot;
@output &lt;&lt; "\n"
elsif (@buffer.length &gt; 0) then
if @cancel_modifier then
@output &lt;&lt; &quot;p. &quot; if @output_type == :paragraph
@output &lt;&lt; "p. " if @output_type == :paragraph
@cancel_modifier = false
end
@output &lt;&lt; @paragraph_modifier if (@paragraph_modifier and not sticky_modifier?)
@output &lt;&lt; @buffer.textile_substitution &lt;&lt; &quot;\n&quot;
@output &lt;&lt; @buffer.textile_substitution &lt;&lt; "\n"
end
@buffer = &quot;&quot;
@buffer = ""
end
</pre>
</li>
<li>Major code cleanup: Created the <code>OutputBuffer</code> class that
greatly simplified a lot of the messiness of <code>textile</code>
conversion.</li>
<li>Added support for line breaks within list items.</li>
</ul>
</ul>
Loading

0 comments on commit ebe8e64

Please sign in to comment.