rdiscount-2.1.8/ 0000755 0000041 0000041 00000000000 12477017312 013570 5 ustar www-data www-data rdiscount-2.1.8/Rakefile 0000644 0000041 0000041 00000015005 12477017312 015236 0 ustar www-data www-data require 'date'
require 'rake/clean'
require 'digest/md5'
task :default => :test
# ==========================================================
# Ruby Extension
# ==========================================================
DLEXT = RbConfig::MAKEFILE_CONFIG['DLEXT']
RUBYDIGEST = Digest::MD5.hexdigest(`ruby --version`)
file "ext/ruby-#{RUBYDIGEST}" do |f|
rm_f FileList["ext/ruby-*"]
touch f.name
end
CLEAN.include "ext/ruby-*"
file 'ext/Makefile' => FileList['ext/*.{c,h,rb}', "ext/ruby-#{RUBYDIGEST}"] do
chdir('ext') { ruby 'extconf.rb' }
end
CLEAN.include 'ext/Makefile', 'ext/mkmf.log'
file "ext/rdiscount.#{DLEXT}" => FileList["ext/Makefile"] do |f|
sh 'cd ext && make clean && make && rm -rf conftest.dSYM'
end
CLEAN.include 'ext/*.{o,bundle,so,dll}'
file "lib/rdiscount.#{DLEXT}" => "ext/rdiscount.#{DLEXT}" do |f|
cp f.prerequisites, "lib/", :preserve => true
end
desc 'Build the rdiscount extension'
task :build => "lib/rdiscount.#{DLEXT}"
# ==========================================================
# Manual
# ==========================================================
file 'man/rdiscount.1' => 'man/rdiscount.1.ronn' do
sh "ronn --manual=RUBY -b man/rdiscount.1.ronn"
end
CLOBBER.include 'man/rdiscount.1'
desc 'Build manpages'
task :man => 'man/rdiscount.1'
# ==========================================================
# Testing
# ==========================================================
require 'rake/testtask'
Rake::TestTask.new('test:unit') do |t|
t.test_files = FileList['test/*_test.rb']
t.ruby_opts += ['-rubygems'] if defined? Gem
end
task 'test:unit' => [:build]
desc 'Run conformance tests (MARKDOWN_TEST_VER=1.0)'
task 'test:conformance' => [:build] do |t|
script = "#{pwd}/bin/rdiscount"
test_version = ENV['MARKDOWN_TEST_VER'] || '1.0.3'
lib_dir = "#{pwd}/lib"
chdir("test/MarkdownTest_#{test_version}") do
result = `RUBYLIB=#{lib_dir} ./MarkdownTest.pl --script='#{script}' --tidy`
print result
fail unless result.include? "; 0 failed."
end
end
desc 'Run version 1.0 conformance suite'
task 'test:conformance:1.0' => [:build] do |t|
ENV['MARKDOWN_TEST_VER'] = '1.0'
Rake::Task['test:conformance'].invoke
end
desc 'Run 1.0.3 conformance suite'
task 'test:conformance:1.0.3' => [:build] do |t|
ENV['MARKDOWN_TEST_VER'] = '1.0.3'
Rake::Task['test:conformance'].invoke
end
desc 'Run unit and conformance tests'
task :test => %w[test:unit test:conformance]
desc 'Run benchmarks'
task :benchmark => :build do |t|
$:.unshift 'lib'
load 'test/benchmark.rb'
end
# ==========================================================
# Documentation
# ==========================================================
desc 'Generate API documentation'
task :doc => 'doc/index.html'
file 'doc/index.html' => FileList['lib/*.rb'] do |f|
sh((<<-end).gsub(/\s+/, ' '))
hanna --charset utf8 --fmt html --inline-source --line-numbers \
--main RDiscount --op doc --title 'RDiscount API Documentation' \
#{f.prerequisites.join(' ')}
end
end
CLEAN.include 'doc'
# ==========================================================
# Update package's Discount sources
# ==========================================================
desc 'Gather required discount sources into extension directory'
task :gather => 'discount/markdown.h' do |t|
# Files unique to /ext that should not be overridden
rdiscount_ext_files = [
"config.h",
"extconf.rb",
"rdiscount.c",
]
# Files in /discount that have a main function and should not be copied to /ext
discount_c_files_with_main_function = [
"main.c",
"makepage.c",
"mkd2html.c",
"theme.c",
]
# Ensure configure.sh was run
if not File.exists? 'discount/mkdio.h'
abort "discount/mkdio.h not found. Did you run ./configure.sh in the discount directory?"
end
# Delete all *.c and *.h files from ext that are not specific to RDiscount.
Dir.chdir("ext") do
c_files_to_delete = Dir["*.c"].select { |e| !rdiscount_ext_files.include? e }
h_files_to_delete = Dir["*.h"].select { |e| !rdiscount_ext_files.include? e }
rm (c_files_to_delete + h_files_to_delete),
:verbose => true
end
# Copy all *.c and *.h files from discount -> ext except those that
# RDiscount overrides. Also exclude Discount files with main functions.
Dir.chdir("discount") do
c_files_to_copy = Dir["*.c"].select { |e|
(!rdiscount_ext_files.include? e) &&
(!discount_c_files_with_main_function.include? e)
}
h_files_to_copy = Dir["*.h"].select { |e| !rdiscount_ext_files.include? e }
cp (c_files_to_copy + h_files_to_copy), '../ext/',
:preserve => true,
:verbose => true
end
# Copy special files from discount -> ext
cp 'discount/blocktags', 'ext/'
cp 'discount/VERSION', 'ext/'
# Copy man page
cp 'discount/markdown.7', 'man/'
end
file 'discount/markdown.h' do |t|
abort "The discount submodule is required. See the file BUILDING for getting set up."
end
# PACKAGING =================================================================
require 'rubygems'
$spec = eval(File.read('rdiscount.gemspec'))
def package(ext='')
"pkg/rdiscount-#{$spec.version}" + ext
end
desc 'Build packages'
task :package => %w[.gem .tar.gz].map {|e| package(e)}
desc 'Build and install as local gem'
task :install => package('.gem') do
sh "gem install #{package('.gem')}"
end
directory 'pkg/'
file package('.gem') => %w[pkg/ rdiscount.gemspec] + $spec.files do |f|
sh "gem build rdiscount.gemspec"
mv File.basename(f.name), f.name
end
file package('.tar.gz') => %w[pkg/] + $spec.files do |f|
sh "git archive --format=tar HEAD | gzip > #{f.name}"
end
# GEMSPEC HELPERS ==========================================================
def source_version
line = File.read('lib/rdiscount.rb')[/^\s*VERSION = .*/]
line.match(/.*VERSION = '(.*)'/)[1]
end
file 'rdiscount.gemspec' => FileList['Rakefile','lib/rdiscount.rb'] do |f|
# read spec file and split out manifest section
spec = File.read(f.name)
head, manifest, tail = spec.split(" # = MANIFEST =\n")
head.sub!(/\.version = '.*'/, ".version = '#{source_version}'")
head.sub!(/\.date = '.*'/, ".date = '#{Date.today.to_s}'")
# determine file list from git ls-files
files = `git ls-files`.
split("\n").
sort.
reject{ |file| file =~ /^\./ || file =~ /^test\/MarkdownTest/ }.
map{ |file| " #{file}" }.
join("\n")
# piece file back together and write...
manifest = " s.files = %w[\n#{files}\n ]\n"
spec = [head,manifest,tail].join(" # = MANIFEST =\n")
File.open(f.name, 'w') { |io| io.write(spec) }
puts "updated #{f.name}"
end
rdiscount-2.1.8/bin/ 0000755 0000041 0000041 00000000000 12477017312 014340 5 ustar www-data www-data rdiscount-2.1.8/bin/rdiscount 0000755 0000041 0000041 00000000631 12477017312 016300 0 ustar www-data www-data #!/usr/bin/env ruby
# Usage: rdiscount [ Hello World. Hello World! start _ foo_bar bar_baz _ end italic bold blah Run 'rake radiant:extensions:rbac_base:migrate' Through <em>NO</em> <script>DOUBLE NO</script> They’re not for sale. Well that’ll be the day before after Para 1 Para 2 Link Lorem, A wise man once said: Isn't it wonderful just to be alive. foo bar baz foo bar baz By Candice Yellowflower Now is the time for all good men to come to
the aid of their country. This is just a
regular paragraph. The quick brown fox jumped over the lazy
dog's back. This is a blockquote. This is the second paragraph in the blockquote. Some of these words are emphasized.
Some of these words are emphasized also. Use two asterisks for strong emphasis.
Or, if you prefer, use two underscores instead. ` tags for the
list item text. You can create multi-paragraph list items by indenting
the paragraphs by 4 spaces or 1 tab:
* A list item.
With multiple paragraphs.
* Another item in the list.
Output:
A list item. With multiple paragraphs. Another item in the list. This is an
example link. This is an
example link. I get 10 times more traffic from Google than from Yahoo or MSN. I start my morning with a cup of coffee and
The New York Times. tags from the output.
attr_accessor :no_image
# Do not process [] and remove tags from the output.
attr_accessor :no_links
# Do not process tables
attr_accessor :no_tables
# Disable superscript and relaxed emphasis processing.
attr_accessor :strict
# Convert URL in links, even if they aren't encased in <>
attr_accessor :autolink
# Don't make hyperlinks from [][] links that have unknown URL types.
attr_accessor :safelink
# Do not process pseudo-protocols like [](id:name)
attr_accessor :no_pseudo_protocols
# Disable superscript processing.
attr_accessor :no_superscript
# Disable strikethrough processing.
attr_accessor :no_strikethrough
# Create a RDiscount Markdown processor. The +text+ argument
# should be a string containing Markdown text. Additional arguments may be
# supplied to set various processing options:
#
# * :smart - Enable SmartyPants processing.
# * :filter_styles - Do not output tags.
# * :filter_html - Do not output any raw HTML tags included in
# the source text.
# * :fold_lines - RedCloth compatible line folding (not used).
# * :footnotes - PHP markdown extra-style footnotes.
# * :generate_toc - Enable Table Of Contents generation
# * :no_image - Do not output any
tags.
# * :no_links - Do not output any tags.
# * :no_tables - Do not output any tables.
# * :strict - Disable superscript and relaxed emphasis processing.
# * :autolink - Greedily urlify links.
# * :safelink - Do not make links for unknown URL types.
# * :no_pseudo_protocols - Do not process pseudo-protocols.
# * :no_superscript - Disable superscript processing.
# * :no_strikethrough - Disable strikethrough processing.
#
def initialize(text, *extensions)
@text = text
extensions.each { |e| send("#{e}=", true) }
end
end
Markdown = RDiscount unless defined? Markdown
require 'rdiscount.so'
rdiscount-2.1.8/lib/markdown.rb 0000644 0000041 0000041 00000000024 12477017312 016501 0 ustar www-data www-data require 'rdiscount'
rdiscount-2.1.8/README.markdown 0000644 0000041 0000041 00000004311 12477017312 016270 0 ustar www-data www-data Discount Markdown Processor for Ruby
====================================
[](https://travis-ci.org/davidfstr/rdiscount)
Discount is an implementation of John Gruber's Markdown markup language in C. It
implements all of the language described in [the markdown syntax document][1] and
passes the [Markdown 1.0 test suite][2].
CODE: `git clone git://github.com/davidfstr/rdiscount.git`
HOME:
HTML block\n
HTML block\n
\nipsum
\n",
markdown.to_html
end
def test_ul_with_zero_space_indent
markdown = Markdown.new("- foo\n\n- bar\n\n baz\n")
assert_equal "
",
markdown.to_html.gsub("\n", "")
end
def test_ul_with_single_space_indent
markdown = Markdown.new(" - foo\n\n - bar\n\n baz\n")
assert_equal "
",
markdown.to_html.gsub("\n", "")
end
# http://github.com/davidfstr/rdiscount/issues/#issue/13
def test_headings_with_trailing_space
text = "The Ant-Sugar Tales \n" +
"=================== \n\n" +
"By Candice Yellowflower \n"
markdown = Markdown.new(text)
assert_equal "The Ant-Sugar Tales
\n\n` and `
` are created by
"underlining" with equal signs (`=`) and hyphens (`-`), respectively.
To create an atx-style header, you put 1-6 hash marks (`#`) at the
beginning of the line -- the number of hashes equals the resulting
HTML header level.
Blockquotes are indicated using email-style '`>`' angle brackets.
Markdown:
A First Level Header
====================
A Second Level Header
---------------------
Now is the time for all good men to come to
the aid of their country. This is just a
regular paragraph.
The quick brown fox jumped over the lazy
dog's back.
### Header 3
> This is a blockquote.
>
> This is the second paragraph in the blockquote.
>
> ## This is an H2 in a blockquote
Output:
A First Level Header
A Second Level Header
Header 3
### Phrase Emphasis ###
Markdown uses asterisks and underscores to indicate spans of emphasis.
Markdown:
Some of these words *are emphasized*.
Some of these words _are emphasized also_.
Use two asterisks for **strong emphasis**.
Or, if you prefer, __use two underscores instead__.
Output:
This is an H2 in a blockquote
Ordered (numbered) lists use regular numbers, followed by periods, as
list markers:
1. Red
2. Green
3. Blue
Output:
If you put blank lines between items, you'll get `
### Links ###
Markdown supports two styles for creating links: *inline* and
*reference*. With both styles, you use square brackets to delimit the
text you want to turn into a link.
Inline-style links use parentheses immediately after the link text.
For example:
This is an [example link](http://example.com/).
Output:
### Code ###
In a regular paragraph, you can create code span by wrapping text in
backtick quotes. Any ampersands (`&`) and angle brackets (`<` or
`>`) will automatically be translated into HTML entities. This makes
it easy to use Markdown to write about HTML example code:
I strongly recommend against using any `
http://github.com/davidfstr/rdiscount
\n", rd.to_html end def test_that_safelink_flag_works rd = RDiscount.new("[IRC](irc://chat.freenode.org/#freenode)", :safelink) assert_equal "[IRC](irc://chat.freenode.org/#freenode)
\n", rd.to_html end def test_that_no_pseudo_protocols_flag_works rd = RDiscount.new("[foo](id:bar)", :no_pseudo_protocols) assert_equal "[foo](id:bar)
\n", rd.to_html end def test_that_no_superscript_flag_works rd = RDiscount.new("A^B", :no_superscript) assert_equal "A^B
\n", rd.to_html rd = RDiscount.new("A^B") assert_equal "AB
\n", rd.to_html end def test_that_no_strikethrough_flag_works rd = RDiscount.new("~~A~~", :no_strikethrough) assert_equal "~~A~~
\n", rd.to_html rd = RDiscount.new("~~A~~") assert_equal "A
foo
A–B
\n", rd.to_html rd = RDiscount.new("A---B", :smart) assert_equal "A—B
\n", rd.to_html end def test_that_superscripts_can_be_escaped rd = RDiscount.new("A\\^B") assert_equal "A^B
\n", rd.to_html rd = RDiscount.new("A^B") assert_equal "AB
\n", rd.to_html end def test_that_style_tag_is_not_filtered_by_default rd = RDiscount.new("Hello") assert_equal "Hello
\n", rd.to_html end def test_that_tables_can_have_leading_and_trailing_pipes rd = RDiscount.new(<line 1\n\nline 2\n
\n", rd.to_html
end
def test_that_gfm_code_blocks_work_with_language
rd = RDiscount.new(<line 1\n\nline 2\n
\n", rd.to_html
end
def test_that_pandoc_code_blocks_work
rd = RDiscount.new(<line 1\n\nline 2\n
\n", rd.to_html
end
def test_that_discount_definition_lists_work
rd = RDiscount.new(<foo ä bar
\n), rd.to_html rd = RDiscount.new(%(*ä foobar*)) assert_equal %(ä foobar
\n), rd.to_html rd = RDiscount.new(%(*foobar ä*)) assert_equal %(foobar ä
\n), rd.to_html end end rdiscount-2.1.8/man/ 0000755 0000041 0000041 00000000000 12477017312 014343 5 ustar www-data www-data rdiscount-2.1.8/man/rdiscount.1 0000644 0000041 0000041 00000001240 12477017312 016434 0 ustar www-data www-data .\" generated with Ronn/v0.6.8 .\" http://github.com/rtomayko/ronn/ . .TH "RDISCOUNT" "1" "April 2010" "" "RUBY" . .SH "NAME" \fBrdiscount\fR \- humane markup to HTML conversion tool . .SH "SYNOPSIS" \fBrdiscount\fR [\fIfile\fR\.\.\.] . .SH "DESCRIPTION" The \fBrdiscount\fR utility reads one or more markdown(7)\-formatted text \fIfile\fRs and writes HTML to standard output\. With no \fIfile\fR, or when \fIfile\fR is \'\-\', \fBrdiscount\fR reads source text from standard input\. . .SH "RETURN VALUES" The \fBrdiscount\fR utility exits 0 on success, and > 0 if an error occurs\. . .SH "SEE ALSO" markdown(7) . .SH "AUTHOR" Ryan Tomayko \fIhttp://tomayko\.com/about\fR rdiscount-2.1.8/man/markdown.7 0000644 0000041 0000041 00000071176 12477017312 016271 0 ustar www-data www-data .\" .Dd Dec 22, 2007 .Dt MARKDOWN 7 .Os MASTODON .Sh NAME .Nm Markdown .Nd The Markdown text formatting syntax .Sh DESCRIPTION .Ss Philosophy .Nm Markdown is intended to be as easy-to-read and easy-to-write as is feasible. .Pp Readability, however, is emphasized above all else. 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 -- including .Em Setext , .Em atx , .Em Textile , .Em reStructuredText , .Em Grutatext , and .Em EtText \-\- the single biggest source of inspiration for Markdown's syntax is the format of plain text email. .Pp To this end, Markdown's syntax is comprised entirely of punctuation characters, which punctuation characters have been carefully chosen so as to look like what they mean. E.g., asterisks around a word actually look like *emphasis*. Markdown lists look like, well, lists. Even blockquotes look like quoted passages of text, assuming you've ever used email. .Ss Inline HTML Markdown's syntax is intended for one purpose: to be used as a format for .Em writing for the web. .Pp .Nm is not a replacement for HTML, or even close to it. Its syntax is very small, corresponding only to a very small subset of HTML tags. The idea is .Em not to create a syntax that makes it easier to insert HTML tags. In my opinion, HTML tags are already easy to insert. The idea for Markdown is to make it easy to read, write, and edit prose. HTML is a .Em publishing format; Markdown is a .Em writing format. Thus, Markdown's formatting syntax only addresses issues that can be conveyed in plain text. .Pp For any markup that is not covered by Markdown's syntax, you simply use HTML itself. There's no need to preface it or delimit it to indicate that you're switching from Markdown to HTML; you just use the tags. .Pp The only restrictions are that block-level HTML elements -- e.g. .Li \