redcarpet-3.5.1/ 0000755 0000041 0000041 00000000000 13774070206 013527 5 ustar www-data www-data redcarpet-3.5.1/COPYING 0000644 0000041 0000041 00000002104 13774070206 014557 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.1/test/ 0000755 0000041 0000041 00000000000 13774070206 014506 5 ustar www-data www-data redcarpet-3.5.1/test/redcarpet_compat_test.rb 0000644 0000041 0000041 00000002543 13774070206 021412 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.1/test/pathological_inputs_test.rb 0000644 0000041 0000041 00000001426 13774070206 022145 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.1/test/html_toc_render_test.rb 0000644 0000041 0000041 00000006020 13774070206 021240 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.1/test/fixtures/ 0000755 0000041 0000041 00000000000 13774070206 016357 5 ustar www-data www-data redcarpet-3.5.1/test/fixtures/benchmark.md 0000644 0000041 0000041 00000020053 13774070206 020633 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.1/test/markdown_test.rb 0000644 0000041 0000041 00000031144 13774070206 017717 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 "