redcarpet-3.5.0/ 0000755 0000041 0000041 00000000000 13520411237 013516 5 ustar www-data www-data redcarpet-3.5.0/COPYING 0000644 0000041 0000041 00000002104 13520411237 014546 0 ustar www-data www-data Copyright (c) 2009, Natacha Porté
Copyright (c) 2015, Vicent Marti
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.
redcarpet-3.5.0/test/ 0000755 0000041 0000041 00000000000 13520411237 014475 5 ustar www-data www-data redcarpet-3.5.0/test/redcarpet_compat_test.rb 0000644 0000041 0000041 00000002543 13520411237 021401 0 ustar www-data www-data # coding: UTF-8
require 'test_helper'
class RedcarpetCompatTest < Redcarpet::TestCase
def test_simple_compat_api
html = RedcarpetCompat.new("This is_just_a test").to_html
assert_equal "
This isjusta test
\n", html
end
def test_compat_api_enables_extensions
html = RedcarpetCompat.new("This is_just_a test", :no_intra_emphasis).to_html
assert_equal "
This is_just_a test
\n", html
end
def test_compat_api_knows_fenced_code_extension
text = "```ruby\nx = 'foo'\n```"
html = RedcarpetCompat.new(text, :fenced_code).to_html
assert_equal "
x = 'foo'\n
\n", html
end
def test_compat_api_ignores_gh_blockcode_extension
text = "```ruby\nx = 'foo'\n```"
html = RedcarpetCompat.new(text, :fenced_code, :gh_blockcode).to_html
assert_equal "
x = 'foo'\n
\n", html
end
def test_compat_api_knows_no_intraemphasis_extension
html = RedcarpetCompat.new("This is_just_a test", :no_intraemphasis).to_html
assert_equal "
This is_just_a test
\n", html
end
def test_translate_outdated_extensions
# these extensions are no longer used
exts = [:gh_blockcode, :no_tables, :smart, :strict]
html = RedcarpetCompat.new('"TEST"', *exts).to_html
assert_equal "
"TEST"
\n", html
end
end
redcarpet-3.5.0/test/pathological_inputs_test.rb 0000644 0000041 0000041 00000001426 13520411237 022134 0 ustar www-data www-data # coding: UTF-8
require 'test_helper'
# Disabled by default
# (these are the easy ones -- the evil ones are not disclosed)
class PathologicalInputsTest # < Redcarpet::TestCase
def setup
@markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML)
end
def test_pathological_1
star = '*' * 250000
@markdown.render("#{star}#{star} hi #{star}#{star}")
end
def test_pathological_2
crt = '^' * 255
str = "#{crt}(\\)"
@markdown.render("#{str*300}")
end
def test_pathological_3
c = "`t`t`t`t`t`t" * 20000000
@markdown.render(c)
end
def test_pathological_4
@markdown.render(" [^a]: #{ "A" * 10000 }\n#{ "[^a][]" * 1000000 }\n")
end
def test_unbound_recursion
@markdown.render(("[" * 10000) + "foo" + ("](bar)" * 10000))
end
end
redcarpet-3.5.0/test/html_toc_render_test.rb 0000644 0000041 0000041 00000006020 13520411237 021227 0 ustar www-data www-data # coding: UTF-8
require 'test_helper'
class HTMLTOCRenderTest < Redcarpet::TestCase
def setup
@renderer = Redcarpet::Render::HTML_TOC
@markdown = <<-Markdown.strip_heredoc
# A title
## A __nice__ subtitle
## Another one
### A sub-sub-title
### 見出し
Markdown
end
def test_simple_toc_render
output = render(@markdown)
assert output.start_with?("
")
assert output.match("Another one")
assert output.match("A sub-sub-title")
assert output.match("見出し")
refute output.match("A title")
refute output.match("A really tiny title")
end
def test_toc_heading_id
output = render(@markdown)
assert_match /a-title/, output
assert_match /a-nice-subtitle/, output
assert_match /another-one/, output
assert_match /a-sub-sub-title/, output
# the part number length varies depending on architecture (32b or 64b)
assert_match /part-(37870bf)?a194139f/, output
end
def test_toc_heading_with_hyphen_and_equal
output = render("# Hello World\n\n-\n\n=")
assert_equal 1, output.scan("
").length
assert !output.include?('')
end
def test_anchor_generation_with_edge_cases
# Imported from ActiveSupport::Inflector#parameterize's tests
titles = {
"Donald E. Knuth" => "donald-e-knuth",
"Random text with *(bad)* characters" => "random-text-with-bad-characters",
"!@#Surrounding bad characters!@#" => "surrounding-bad-characters",
"Squeeze separators" => "squeeze-separators",
"Test with + sign" => "test-with-sign",
"Test with a Namespaced::Class" => "test-with-a-namespaced-class"
}
titles.each do |title, anchor|
assert_match %("##{anchor}"), render("# #{title}")
end
end
def test_inline_markup_is_not_escaped
output = render(@markdown)
assert_match "A nice subtitle", output
assert_no_match %r{<}, output
end
def test_inline_markup_escaping
output = render(@markdown, with: [:escape_html])
assert_match "<strong>", output
assert_no_match %r{}, output
end
def test_ignoring_fenced_code_blocks_comments
markdown = <<-Markdown.strip_heredoc
# Hello world !
~~~ruby
# This is a comment
~~~
Markdown
output = render(markdown)
assert output.match("Hello world")
refute output.match("This is a comment")
end
end
redcarpet-3.5.0/test/fixtures/ 0000755 0000041 0000041 00000000000 13520411237 016346 5 ustar www-data www-data redcarpet-3.5.0/test/fixtures/benchmark.md 0000644 0000041 0000041 00000020053 13520411237 020622 0 ustar www-data www-data Download
--------
[Markdown 1.0.1][dl] (18 KB) -- 17 Dec 2004
[dl]: http://daringfireball.net/projects/downloads/Markdown_1.0.1.zip
Introduction
------------
Markdown is a text-to-HTML conversion tool for web writers. Markdown
allows you to write using an easy-to-read, easy-to-write plain text
format, then convert it to structurally valid XHTML (or HTML).
Thus, "Markdown" is two things: (1) a plain text formatting syntax;
and (2) a software tool, written in Perl, that converts the plain text
formatting to HTML. See the [Syntax][] page for details pertaining to
Markdown's formatting syntax. You can try it out, right now, using the
online [Dingus][].
[syntax]: /projects/markdown/syntax
[dingus]: /projects/markdown/dingus
The overriding design goal for Markdown's formatting syntax is to make
it as readable as possible. The idea is that a Markdown-formatted
document should be publishable as-is, as plain text, without looking
like it's been marked up with tags or formatting instructions. While
Markdown's syntax has been influenced by several existing text-to-HTML
filters, the single biggest source of inspiration for Markdown's
syntax is the format of plain text email.
The best way to get a feel for Markdown's formatting syntax is simply
to look at a Markdown-formatted document. For example, you can view
the Markdown source for the article text on this page here:
(You can use this '.text' suffix trick to view the Markdown source for
the content of each of the pages in this section, e.g. the
[Syntax][s_src] and [License][l_src] pages.)
[s_src]: /projects/markdown/syntax.text
[l_src]: /projects/markdown/license.text
Markdown is free software, available under a BSD-style open source
license. See the [License] [pl] page for more information.
[pl]: /projects/markdown/license
Discussion List
---------------
I've set up a public [mailing list for discussion about Markdown] [ml].
Any topic related to Markdown -- both its formatting syntax and
its software -- is fair game for discussion. Anyone who is interested
is welcome to join.
It's my hope that the mailing list will lead to good ideas for future
improvements to Markdown.
[ml]: http://six.pairlist.net/mailman/listinfo/markdown-discuss
Installation and Requirements
-----------------------------
Markdown requires Perl 5.6.0 or later. Welcome to the 21st Century.
Markdown also requires the standard Perl library module [Digest::MD5]
[md5], which is probably already installed on your server.
[md5]: http://search.cpan.org/dist/Digest-MD5/MD5.pm
### Movable Type ###
Markdown works with Movable Type version 2.6 or later (including
Movable Type 3.0).
1. Copy the "Markdown.pl" file into your Movable Type "plugins"
directory. The "plugins" directory should be in the same directory
as "mt.cgi"; if the "plugins" directory doesn't already exist, use
your FTP program to create it. Your installation should look like
this:
(mt home)/plugins/Markdown.pl
2. Once installed, Markdown will appear as an option in Movable Type's
Text Formatting pop-up menu. This is selectable on a per-post basis:
![Screenshot of Movable Type 'Text Formatting' Menu][tfmenu]
Markdown translates your posts to HTML when you publish; the posts
themselves are stored in your MT database in Markdown format.
3. If you also install SmartyPants 1.5 (or later), Markdown will
offer a second text formatting option: "Markdown With
SmartyPants". This option is the same as the regular "Markdown"
formatter, except that it automatically uses SmartyPants to create
typographically correct curly quotes, em-dashes, and ellipses. See
the [SmartyPants web page][sp] for more information.
4. To make Markdown (or "Markdown With SmartyPants") your default
text formatting option for new posts, go to Weblog Config:
Preferences.
Note that by default, Markdown produces XHTML output. To configure
Markdown to produce HTML 4 output, see "Configuration", below.
[sp]: http://daringfireball.net/projects/smartypants/
### Blosxom ###
Markdown works with Blosxom version 2.0 or later.
1. Rename the "Markdown.pl" plug-in to "Markdown" (case is
important). Movable Type requires plug-ins to have a ".pl"
extension; Blosxom forbids it.
2. Copy the "Markdown" plug-in file to your Blosxom plug-ins folder.
If you're not sure where your Blosxom plug-ins folder is, see the
Blosxom documentation for information.
3. That's it. The entries in your weblog will now automatically be
processed by Markdown.
4. If you'd like to apply Markdown formatting only to certain
posts, rather than all of them, Markdown can optionally be used in
conjunction with Blosxom's [Meta][] plug-in. First, install the
Meta plug-in. Next, open the Markdown plug-in file in a text
editor, and set the configuration variable `$g_blosxom_use_meta`
to 1. Then, simply include a "`meta-markup: Markdown`" header line
at the top of each post you compose using Markdown.
[meta]: http://www.blosxom.com/plugins/meta/meta.htm
### BBEdit ###
Markdown works with BBEdit 6.1 or later on Mac OS X. It also works
with BBEdit 5.1 or later and MacPerl 5.6.1 on Mac OS 8.6 or later. If
you're running Mac OS X 10.2 (Jaguar), you may need to install the
Perl module [Digest::MD5] [md5] from CPAN; Digest::MD5 comes
pre-installed on Mac OS X 10.3 (Panther).
1. Copy the "Markdown.pl" file to appropriate filters folder in your
"BBEdit Support" folder. On Mac OS X, this should be:
BBEdit Support/Unix Support/Unix Filters/
See the BBEdit documentation for more details on the location of
these folders.
You can rename "Markdown.pl" to whatever you wish.
2. That's it. To use Markdown, select some text in a BBEdit document,
then choose Markdown from the Filters sub-menu in the "#!" menu, or
the Filters floating palette
Configuration
-------------
By default, Markdown produces XHTML output for tags with empty elements.
E.g.:
Markdown can be configured to produce HTML-style tags; e.g.:
### Movable Type ###
You need to use a special `MTMarkdownOptions` container tag in each
Movable Type template where you want HTML 4-style output:
... put your entry content here ...
The easiest way to use MTMarkdownOptions is probably to put the
opening tag right after your `` tag, and the closing tag right
before ``.
To suppress Markdown processing in a particular template, i.e. to
publish the raw Markdown-formatted text without translation into
(X)HTML, set the `output` attribute to 'raw':
... put your entry content here ...
### Command-Line ###
Use the `--html4tags` command-line switch to produce HTML output from a
Unix-style command line. E.g.:
% perl Markdown.pl --html4tags foo.text
Type `perldoc Markdown.pl`, or read the POD documentation within the
Markdown.pl source code for more information.
Acknowledgements
----------------
[Aaron Swartz][] deserves a tremendous amount of credit for his feedback on the
design of Markdown's formatting syntax. Markdown is *much* better thanks
to Aaron's ideas, feedback, and testing. Also, Aaron's [html2text][]
is a very handy (and free) utility for turning HTML into
Markdown-formatted plain text.
[Nathaniel Irons][], [Dan Benjamin][], [Daniel Bogan][], and [Jason Perkins][]
also deserve thanks for their feedback.
[Michel Fortin][] has ported Markdown to PHP; it's a splendid port, and highly recommended for anyone looking for a PHP implementation of Markdown.
[Aaron Swartz]: http://www.aaronsw.com/
[Nathaniel Irons]: http://bumppo.net/
[Dan Benjamin]: http://hivelogic.com/
[Daniel Bogan]: http://waferbaby.com/
[Jason Perkins]: http://pressedpants.com/
[Michel Fortin]: http://www.michelf.com/projects/php-markdown/
[html2text]: http://www.aaronsw.com/2002/html2text/
[tfmenu]: /graphics/markdown/mt_textformat_menu.png
redcarpet-3.5.0/test/markdown_test.rb 0000644 0000041 0000041 00000030354 13520411237 017710 0 ustar www-data www-data # coding: UTF-8
require 'test_helper'
class MarkdownTest < Redcarpet::TestCase
def setup
@renderer = Redcarpet::Render::HTML
end
def test_that_simple_one_liner_goes_to_html
assert_equal "
Hello World.
", render("Hello World.")
end
def test_that_inline_markdown_goes_to_html
assert_equal "
"
assert_equal expected, output
end
# This isn't in the spec but is Markdown.pl behavior.
def test_block_quotes_preceded_by_spaces
output = render <<-Markdown.strip_heredoc
A wise man once said:
> Isn't it wonderful just to be alive.
Markdown
expected = <<-HTML.chomp.strip_heredoc
A wise man once said:
Isn't it wonderful just to be alive.
HTML
assert_equal expected, output
end
def test_para_before_block_html_should_not_wrap_in_p_tag
output = render("Things to watch out for\n
\n
Blah
\n
", with: [:lax_spacing])
expected = "
Things to watch out for
\n\n
\n
Blah
\n
"
assert_equal expected, output
end
# https://github.com/vmg/redcarpet/issues/111
def test_p_with_less_than_4space_indent_should_not_be_part_of_last_list_item
text = <<-Markdown
* a
* b
* c
This paragraph is not part of the list.
Markdown
expected = <<-HTML.chomp.strip_heredoc
a
b
c
This paragraph is not part of the list.
HTML
assert_equal expected, render(text)
end
# http://github.com/rtomayko/rdiscount/issues/#issue/13
def test_headings_with_trailing_space
text = "The Ant-Sugar Tales \n" +
"=================== \n\n" +
"By Candice Yellowflower \n"
assert_equal "
The Ant-Sugar Tales
\n\n
By Candice Yellowflower
", render(text)
end
def test_that_intra_emphasis_works
assert_equal "
"
assert_equal expected, output
end
def test_that_tags_can_have_dashes_and_underscores
output = render("foo bar and baz")
expected = "
foo bar and baz
"
assert_equal expected, output
end
def test_link_syntax_is_not_processed_within_code_blocks
output = render(" This is a code block\n This is a link [[1]] inside\n")
expected = "
This is a code block\nThis is a link [[1]] inside\n
)
assert_equal expected, output
end
def test_memory_leak_when_parsing_char_links
render(<<-leaks.strip_heredoc)
2. Identify the wild-type cluster and determine all clusters
containing or contained by it:
wildtype <- wildtype.cluster(h)
wildtype.mask <- logical(nclust)
wildtype.mask[c(contains(h, wildtype),
wildtype,
contained.by(h, wildtype))] <- TRUE
This could be more elegant.
leaks
end
def test_infinite_loop_in_header
assert_equal "
", render("=")
end
def test_that_tables_flag_works
text = <<-Markdown.strip_heredoc
aaa | bbbb
-----|------
hello|sailor
Markdown
assert render(text) !~ /
underlined'
assert output.include? 'underlined'
assert output.include? 'some'
end
def test_highlight_flag_works
text = "this is ==highlighted=="
output = render(text, with: [:highlight])
refute render(text).include? 'highlighted'
assert output.include? 'highlighted'
end
def test_quote_flag_works
text = 'this is a "quote"'
output = render(text, with: [:quote])
refute render(text).include? 'quote'
assert_equal '
this is a quote
', output
end
def test_that_fenced_flag_works
text = <<-fenced.strip_heredoc
This is a simple test
~~~~~
This is some awesome code
with tabs and shit
~~~
fenced
assert render(text) !~ /")
output = render(text, with: [:fenced_code_blocks])
assert !output.include?("
")
end
def test_that_indented_code_preserves_references
text = <<-indented.strip_heredoc
This is normal text
Link to [Google][1]
[1]: http://google.com
indented
output = render(text, with: [:fenced_code_blocks])
assert output.include?("[1]: http://google.com")
end
def test_that_fenced_flag_preserves_references
text = <<-fenced.strip_heredoc
This is normal text
```
Link to [Google][1]
[1]: http://google.com
```
fenced
out = render(text, with: [:fenced_code_blocks])
assert out.include?("[1]: http://google.com")
end
def test_that_fenced_code_copies_language_verbatim_with_braces
text = "```{rust,no_run}\nx = 'foo'\n```"
html = render(text, with: [:fenced_code_blocks])
assert_equal "
x = 'foo'\n
", html
end
def test_that_fenced_code_copies_language_verbatim
text = "```rust,no_run\nx = 'foo'\n```"
html = render(text, with: [:fenced_code_blocks])
assert_equal "
x = 'foo'\n
", html
end
def test_that_indented_flag_works
text = <<-indented.strip_heredoc
This is a simple text
This is some awesome code
with shit
And this is again a simple text
indented
assert render(text) =~ /GitHub"
assert_equal expected, output
end
def test_autolinking_with_ent_chars
markdown = <<-Markdown.strip_heredoc
This a stupid link: https://github.com/rtomayko/tilt/issues?milestone=1&state=open
Markdown
output = render(markdown, with: [:autolink])
assert_equal "
\n"
assert_equal expected, @output
end
def test_enabling_a_parse_option
run_bin("--parse", "highlight", @fixture_path)
assert_output ""
refute_output "=="
end
def test_enabling_a_render_option
run_bin("--render", "no-links", @fixture_path)
assert_output "[link]"
refute_output ""
end
def test_enabling_smarty_pants
run_bin("--smarty", @fixture_path)
assert_output "&ndash"
refute_output "--"
end
def test_version_option
run_bin("--version")
assert_output "Redcarpet #{Redcarpet::VERSION}"
end
def test_legacy_option_parsing
run_bin("--parse-highlight", "--render-no-links", @fixture_path)
assert_output ""
refute_output "=="
assert_output "[link]"
refute_output ""
end
private
def run_bin(*args)
bin_path = File.expand_path('../../bin/redcarpet', __FILE__)
ruby = RbConfig.ruby
IO.popen("#{ruby} #{bin_path} #{args.join(" ")}") do |stream|
@output = stream.read
end
end
def assert_output(pattern)
assert_match pattern, @output
end
def refute_output(pattern)
refute_match Regexp.new(pattern), @output
end
end
redcarpet-3.5.0/test/benchmark.rb 0000644 0000041 0000041 00000001021 13520411237 016746 0 ustar www-data www-data # coding: UTF-8
# Thanks Kramdown for the inspiration!
require 'benchmark/ips'
require 'redcarpet'
require 'bluecloth'
require 'kramdown'
markdown = File.read(File.join(File.dirname(__FILE__), "fixtures/benchmark.md"))
# Let's bench!
Benchmark.ips do |bench|
bench.report("Redcarpet") do
Redcarpet::Markdown.new(Redcarpet::Render::HTML).render(markdown)
end
bench.report("BlueCloth") do
BlueCloth.new(markdown).to_html
end
bench.report("Kramdown") do
Kramdown::Document.new(markdown).to_html
end
end
redcarpet-3.5.0/test/smarty_pants_test.rb 0000644 0000041 0000041 00000004021 13520411237 020602 0 ustar www-data www-data # coding: UTF-8
require 'test_helper'
class SmartyPantsTest < Redcarpet::TestCase
def setup
@pants = Redcarpet::Render::SmartyPants
end
def test_that_smart_converts_single_quotes_in_words_that_end_in_re
markdown = @pants.render("
They're not for sale.
")
assert_equal "
They’re not for sale.
", markdown
end
def test_that_smart_converts_single_quotes_in_words_that_end_in_ll
markdown = @pants.render("
Well that'll be the day
")
assert_equal "
Well that’ll be the day
", markdown
end
def test_that_smart_converts_double_quotes_to_curly_quotes
rd = @pants.render(%(
"Quoted text"
))
assert_equal %(
“Quoted text”
), rd
end
def test_that_smart_gives_ve_suffix_a_rsquo
rd = @pants.render("
I've been meaning to tell you ..
")
assert_equal "
I’ve been meaning to tell you ..
", rd
end
def test_that_smart_gives_m_suffix_a_rsquo
rd = @pants.render("
I'm not kidding
")
assert_equal "
I’m not kidding
", rd
end
def test_that_smart_gives_d_suffix_a_rsquo
rd = @pants.render("
what'd you say?
")
assert_equal "
what’d you say?
", rd
end
def test_that_backticks_are_preserved
rd = @pants.render("
single `backticks` in HTML should be preserved
")
assert_equal "
single `backticks` in HTML should be preserved
", rd
end
def test_that_smart_converts_trailing_single_quotes_to_curly_quotes
rd = @pants.render("
Hopin' that this bug gets some fixin'.
")
assert_equal "
Hopin’ that this bug gets some fixin’.
", rd
end
def test_that_is_not_confused_by_fractions
rd = @pants.render('I am 1/4... of the way to 1/4/2000')
assert_equal "I am ¼… of the way to 1/4/2000", rd
end
def test_that_smart_converts_multiple_single_quotes
rd = @pants.render(%(
'First' and 'second' and 'third'
))
assert_equal %(
‘First’ and ‘second’ and ‘third’
), rd
end
end
redcarpet-3.5.0/test/custom_render_test.rb 0000644 0000041 0000041 00000003472 13520411237 020740 0 ustar www-data www-data # coding: UTF-8
require 'test_helper'
class CustomRenderTest < Redcarpet::TestCase
class SimpleRender < Redcarpet::Render::HTML
def emphasis(text)
if @options[:no_intra_emphasis]
return %(#{text})
end
%(#{text})
end
def header(text, level)
"My little poney" if @options[:with_toc_data]
end
end
def test_simple_overload
md = Redcarpet::Markdown.new(SimpleRender)
assert_equal "
This is just a test
\n",
md.render("This is *just* a test")
end
def test_renderer_options
parser = Redcarpet::Markdown.new(SimpleRender.new(with_toc_data: true))
output = parser.render("# A title")
assert_match "My little poney", output
end
def test_markdown_options
parser = Redcarpet::Markdown.new(SimpleRender, no_intra_emphasis: true)
output = parser.render("*foo*")
assert_match "no_intra_emphasis", output
end
def test_original_options_hash_is_not_mutated
options = { with_toc_data: true }
render = SimpleRender.new(options)
parser = Redcarpet::Markdown.new(render, tables: true)
computed_options = render.instance_variable_get(:"@options")
refute_equal computed_options.object_id, options.object_id
end
class NilPreprocessRenderer < Redcarpet::Render::HTML
def preprocess(fulldoc)
nil
end
end
def test_preprocess_returning_nil
md = Redcarpet::Markdown.new(NilPreprocessRenderer)
assert_equal(nil,md.render("Anything"))
end
def test_base_render_without_quote_callback
# Regression test for https://github.com/vmg/redcarpet/issues/569
render = Class.new(Redcarpet::Render::Base)
parser = Redcarpet::Markdown.new render.new, quote: true
assert_equal "", parser.render(%(a "quote"))
end
end
redcarpet-3.5.0/test/html_render_test.rb 0000644 0000041 0000041 00000017714 13520411237 020376 0 ustar www-data www-data # coding: UTF-8
require 'test_helper'
class HTMLRenderTest < Redcarpet::TestCase
def setup
@renderer = Redcarpet::Render::HTML
end
# Hint: overrides filter_html, no_images and no_links
def test_that_escape_html_works
source = <<-HTML.strip_heredoc
Through NO
HTML
expected = <<-HTML.chomp.strip_heredoc
Through <em>NO</em> <script>DOUBLE NO</script>
<script>BAD</script>
<img src="/favicon.ico" />
HTML
assert_equal expected, render(source, with: [:escape_html])
end
def test_that_filter_html_works
markdown = 'Through NO '
output = render(markdown, with: [:filter_html])
assert_equal "
)
assert_equal expected, render(markdown)
assert_equal expected, render(markdown, with: [:escape_html])
end
def test_that_code_emphasis_work
markdown = <<-Markdown.strip_heredoc
This should be **`a bold codespan`**
However, this should be *`an emphasised codespan`*
* **`ABC`** or **`DEF`**
* Foo bar
Markdown
html = <<-HTML.chomp.strip_heredoc
This should be a bold codespan
However, this should be an emphasised codespan
ABC or DEF
Foo bar
HTML
assert_equal html, render(markdown)
end
def test_that_parenthesis_are_handled_into_links
markdown = %(The [bash man page](man:bash(1))!)
expected = %(
HTML
output = render(markdown, with: [:footnotes])
assert_equal html, output
end
def test_footnotes_enabled_but_missing_marker
markdown = <<-Markdown.strip_heredoc
Some text without a marker
[^1] And a trailing definition
Markdown
html = <<-HTML.chomp.strip_heredoc
Some text without a marker
[^1] And a trailing definition
HTML
output = render(markdown, with: [:footnotes])
assert_equal html, output
end
def test_footnotes_enabled_but_missing_definition
markdown = "Some text with a marker[^1] but no definition."
expected = "
Some text with a marker[^1] but no definition.
"
output = render(markdown, with: [:footnotes])
assert_equal expected, output
end
def test_autolink_short_domains
markdown = "Example of uri ftp://auto/short/domains. Email auto@l.n and link http://a/u/t/o/s/h/o/r/t"
output = render(markdown, with: [:autolink])
assert output.include? 'ftp://auto/short/domains'
assert output.include? 'mailto:auto@l.n'
assert output.include? 'http://a/u/t/o/s/h/o/r/t'
end
def test_that_prettify_works
markdown = "\tclass Foo\nend"
output = render(markdown, with: [:prettify])
assert output.include?("