Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ GEM
commonmarker (2.8.2-x86_64-linux)
concurrent-ruby (1.3.6)
connection_pool (3.0.2)
crass (1.0.6)
creole (0.5.0)
date (3.5.1)
docile (1.4.1)
Expand All @@ -47,9 +46,9 @@ GEM
charlock_holmes (~> 0.7.7)
mini_mime (~> 1.0)
rugged (~> 1.0)
html-pipeline (1.11.0)
activesupport (>= 2)
nokogiri (~> 1.4)
html-pipeline (3.2.4)
selma (~> 0.4)
zeitwerk (~> 2.5)
htmlentities (4.3.4)
i18n (1.14.8)
concurrent-ruby (~> 1.0)
Expand Down Expand Up @@ -95,10 +94,14 @@ GEM
rexml (3.4.4)
rubypants (0.7.1)
rugged (1.9.0)
sanitize (6.1.3)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
securerandom (0.4.1)
selma (0.5.0)
rb_sys (~> 0.9)
selma (0.5.0-aarch64-linux)
selma (0.5.0-arm-linux)
selma (0.5.0-arm64-darwin)
selma (0.5.0-x86_64-darwin)
selma (0.5.0-x86_64-linux)
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
Expand All @@ -122,6 +125,7 @@ GEM
htmlentities
nokogiri
twitter-text
zeitwerk (2.8.2)

PLATFORMS
aarch64-linux
Expand All @@ -139,7 +143,7 @@ DEPENDENCIES
creole (~> 0.5.0)
github-linguist (>= 7.1.3)
github-markup!
html-pipeline (~> 1.0)
html-pipeline (~> 3.2)
kramdown
minitest (~> 6.0, >= 5.4.3)
nokogiri (~> 1.19.2)
Expand All @@ -149,7 +153,6 @@ DEPENDENCIES
rdoc (~> 7.2.0)
redcarpet
rexml
sanitize (>= 4.6.3)
simplecov (~> 0.22)
twitter-text (~> 1.14)
wikicloth (= 0.8.3)
Expand Down
3 changes: 1 addition & 2 deletions github-markup.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ Gem::Specification.new do |s|
s.add_development_dependency 'rake', '~> 13'
s.add_development_dependency 'activesupport', '~> 8.1.3'
s.add_development_dependency 'minitest', '>= 5.4.3', '~> 6.0'
s.add_development_dependency 'html-pipeline', '~> 1.0'
s.add_development_dependency 'sanitize', '>= 4.6.3'
s.add_development_dependency 'html-pipeline', '~> 3.2'
s.add_development_dependency 'nokogiri', '~> 1.19.2'
s.add_development_dependency 'nokogiri-diff', '~> 0.3.0'
s.add_development_dependency "github-linguist", ">= 7.1.3"
Expand Down
18 changes: 9 additions & 9 deletions test/markup_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
require 'github-markup'
require 'github/markup'
require 'minitest/autorun'
require 'html/pipeline'
require 'html_pipeline'
require 'nokogiri'
require 'nokogiri/diff'

Expand Down Expand Up @@ -36,17 +36,17 @@ def assert_html_equal(expected, actual, msg = nil)
end

class MarkupTest < Minitest::Test
class MarkupFilter < HTML::Pipeline::Filter
def call
filename = context[:filename]
class MarkupFilter < HTMLPipeline::ConvertFilter
def call(_text, context: {})
filename = context[: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
]
Pipeline = HTMLPipeline.new(
convert_filter: MarkupFilter.new,
sanitization_config: HTMLPipeline::SanitizationFilter::DEFAULT_CONFIG
)

Dir['test/markups/README.*'].each do |readme|
next if readme =~ /html$/
Expand All @@ -57,7 +57,7 @@ def call
source = File.read(readme)
expected_file = "#{readme}.html"
expected = File.read(expected_file).rstrip
actual = Pipeline.to_html(nil, :filename => readme)
actual = Pipeline.call("", context: { filename: readme })[:output].to_s

if source != expected
assert(source != actual, "#{markup} did not render anything")
Expand Down
12 changes: 6 additions & 6 deletions test/markups/README.asciidoc.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h1>Document Title</h1>
<div>
<h2>First Section</h2>
<h2 id="first-section">First Section</h2>
<div>
<div>
<ul>
Expand All @@ -16,12 +16,12 @@ <h2>First Section</h2>
<p>Refer to <a href="#another-section">Another Section</a> or <a href="#another-section-1">Another Section</a>.</p>
</div>
<div>
<p>Navigate from README.asciidoc to <a href="another-document.asciidoc">another document</a>.</p>
<p>Navigate from README.asciidoc to <a>another document</a>.</p>
</div>
</div>
</div>
<div>
<h2>Another Section</h2>
<h2 id="another-section">Another Section</h2>
<div>
<div>
<table>
Expand All @@ -43,17 +43,17 @@ <h2>Another Section</h2>
<div>
<ul>
<li>
<p> todo</p>
<p>&#10063; todo</p>
</li>
<li>
<p> done</p>
<p>&#10003; done</p>
</li>
</ul>
</div>
</div>
</div>
<div>
<h2>Another Section</h2>
<h2 id="another-section-1">Another Section</h2>
<div>
<div>
<p>content</p>
Expand Down
6 changes: 1 addition & 5 deletions test/markups/README.creole.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
<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
4 changes: 2 additions & 2 deletions test/markups/README.directives.rst.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ <h2>Introduction</h2>
<pre>
.. github display [on | off]
</pre>
<p>If you pass this the "on" value, then all unknown directives
<p>If you pass this the &quot;on&quot; 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.</p>
the &quot;off&quot; value, then unknown directives will not be displayed.</p>
<p>In addition to controlling the display of literal code blocks,
this also allows you to show comments specifically for github.</p>
<p>For example, somebody could place this at the top of their file:</p>
Expand Down
10 changes: 5 additions & 5 deletions test/markups/README.litcoffee.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ <h2>Literate CoffeeScript Test</h2>
<p>Taken from <a href="https://github.com/jashkenas/coffee-script/blob/master/test/literate.litcoffee">https://github.com/jashkenas/coffee-script/blob/master/test/literate.litcoffee</a></p>
</blockquote>
<p>comment comment</p>
<pre><code>test "basic literate CoffeeScript parsing", -&gt;
<pre><code>test &quot;basic literate CoffeeScript parsing&quot;, -&gt;
ok yes
</code></pre>
<p>now with a...</p>
<pre><code>test "broken up indentation", -&gt;
<pre><code>test &quot;broken up indentation&quot;, -&gt;
</code></pre>
<p>... broken up ...</p>
<pre><code> do -&gt;
Expand All @@ -16,14 +16,14 @@ <h2>Literate CoffeeScript Test</h2>
<pre><code> ok yes
</code></pre>
<p>Code must be separated from text by a blank line.</p>
<pre><code>test "code blocks must be preceded by a blank line", -&gt;
<pre><code>test &quot;code blocks must be preceded by a blank line&quot;, -&gt;
</code></pre>
<p>The next line is part of the text and will not be executed.
fail()</p>
<pre><code> ok yes
</code></pre>
<p>Code in <code>backticks is not parsed</code> and...</p>
<pre><code>test "comments in indented blocks work", -&gt;
<pre><code>test &quot;comments in indented blocks work&quot;, -&gt;
do -&gt;
do -&gt;
# Regular comment.
Expand Down Expand Up @@ -51,5 +51,5 @@ <h2>Literate CoffeeScript Test</h2>
</li>
</ul>
<p>Tabs work too:</p>
<p>test "tabbed code", -&gt;
<p>test &quot;tabbed code&quot;, -&gt;
ok yes</p>
Loading