asciidoctor 0.0.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of asciidoctor might be problematic. Click here for more details.

data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) Tom Preston-Werner
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,69 @@
1
+ RakeGem
2
+ =======
3
+
4
+ # DESCRIPTION
5
+
6
+ Ever wanted to manage your RubyGem in a sane way without having to resort to
7
+ external dependencies like Jeweler or Hoe? Ever thought that Rake and a hand
8
+ crafted gemspec should be enough to deal with these problems? If so, then
9
+ RakeGem is here to make your life awesome!
10
+
11
+ RakeGem is not a library. It is just a few simple file templates that you can
12
+ copy into your project and easily customize to match your specific needs. It
13
+ ships with a few Rake tasks to help you keep your gemspec up-to-date, build
14
+ a gem, and release your library and gem to the world.
15
+
16
+ RakeGem assumes you are using Git. This makes the Rake tasks easy to write. If
17
+ you are using something else, you should be able to get RakeGem up and running
18
+ with your system without too much editing.
19
+
20
+ The RakeGem tasks were inspired by the
21
+ [Sinatra](http://github.com/sinatra/sinatra) project.
22
+
23
+ # INSTALLATION
24
+
25
+ Take a look at `Rakefile` and `NAME.gemspec`. For new projects, you can start
26
+ with these files and edit a few lines to make them fit into your library. If
27
+ you have an existing project, you'll probably want to take the RakeGem
28
+ versions and copy any custom stuff from your existing Rakefile and gemspec
29
+ into them. As long as you're careful, the rake tasks should keep working.
30
+
31
+ # ASSUMPTIONS
32
+
33
+ RakeGem makes a few assumptions. You will either need to satisfy these
34
+ assumptions or modify the rake tasks to work with your setup.
35
+
36
+ You should have a file named `lib/NAME.rb` (where NAME is the name of your
37
+ library) that contains a version line. It should look something like this:
38
+
39
+ module NAME
40
+ VERSION = '0.1.0'
41
+ end
42
+
43
+ It is important that you use the constant `VERSION` and that it appear on a
44
+ line by itself.
45
+
46
+ # UPDATING THE VERSION
47
+
48
+ In order to make a new release, you'll want to update the version. With
49
+ RakeGem, you only need to do that in the `lib/NAME.rb` file. Everything else
50
+ will use this find the canonical version of the library.
51
+
52
+ # TASKS
53
+
54
+ RakeGem provides three rake tasks:
55
+
56
+ `rake gemspec` will update your gemspec with the latest version (taken from
57
+ the `lib/NAME.rb` file) and file list (as reported by `git ls-files`).
58
+
59
+ `rake build` will update your gemspec, build your gemspec into a gem, and
60
+ place it in the `pkg` directory.
61
+
62
+ `rake release` will update your gemspec, build your gem, make a commit with
63
+ the message `Release 0.1.0` (with the correct version, obviously), tag the
64
+ commit with `v0.1.0` (again with the correct version), and push the `master`
65
+ branch and new tag to `origin`.
66
+
67
+ Keep in mind that these are just simple Rake tasks and you can edit them
68
+ however you please. Don't want to auto-commit or auto-push? Just delete those
69
+ lines. You can bend RakeGem to your own needs. That's the whole point!
@@ -0,0 +1,150 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'date'
4
+
5
+ #############################################################################
6
+ #
7
+ # Helper functions
8
+ #
9
+ #############################################################################
10
+
11
+ def name
12
+ @name ||= Dir['*.gemspec'].first.split('.').first
13
+ end
14
+
15
+ def version
16
+ line = File.read("lib/#{name}/version.rb")[/^\s*VERSION\s*=\s*.*/]
17
+ line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
18
+ end
19
+
20
+ def date
21
+ Date.today.to_s
22
+ end
23
+
24
+ def rubyforge_project
25
+ name
26
+ end
27
+
28
+ def gemspec_file
29
+ "#{name}.gemspec"
30
+ end
31
+
32
+ def gem_file
33
+ "#{name}-#{version}.gem"
34
+ end
35
+
36
+ def replace_header(head, header_name)
37
+ head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
38
+ end
39
+
40
+ #############################################################################
41
+ #
42
+ # Standard tasks
43
+ #
44
+ #############################################################################
45
+
46
+ task :default => :test
47
+
48
+ require 'rake/testtask'
49
+ Rake::TestTask.new(:test) do |test|
50
+ test.libs << 'lib' << 'test'
51
+ test.pattern = 'test/**/*_test.rb'
52
+ test.verbose = true
53
+ end
54
+
55
+ desc "Generate RCov test coverage and open in your browser"
56
+ task :coverage do
57
+ require 'rcov'
58
+ sh "rm -fr coverage"
59
+ sh "rcov test/test_*.rb"
60
+ sh "open coverage/index.html"
61
+ end
62
+
63
+ require 'rdoc/task'
64
+ Rake::RDocTask.new do |rdoc|
65
+ rdoc.rdoc_dir = 'rdoc'
66
+ rdoc.title = "#{name} #{version}"
67
+ rdoc.rdoc_files.include('README*')
68
+ rdoc.rdoc_files.include('lib/**/*.rb')
69
+ end
70
+
71
+ desc "Open an irb session preloaded with this library"
72
+ task :console do
73
+ sh "irb -rubygems -r ./lib/#{name}.rb"
74
+ end
75
+
76
+ #############################################################################
77
+ #
78
+ # Custom tasks (add your own tasks here)
79
+ #
80
+ #############################################################################
81
+
82
+
83
+
84
+ #############################################################################
85
+ #
86
+ # Packaging tasks
87
+ #
88
+ #############################################################################
89
+
90
+ desc "Create tag v#{version} and build and push #{gem_file} to Rubygems"
91
+ task :release => :build do
92
+ unless `git branch` =~ /^\* master$/
93
+ puts "You must be on the master branch to release!"
94
+ exit!
95
+ end
96
+ sh "git commit --allow-empty -a -m 'Release #{version}'"
97
+ sh "git tag v#{version}"
98
+ sh "git push origin master"
99
+ sh "git push origin v#{version}"
100
+ sh "gem push pkg/#{name}-#{version}.gem"
101
+ end
102
+
103
+ desc "Build #{gem_file} into the pkg directory"
104
+ task :build => :gemspec do
105
+ sh "mkdir -p pkg"
106
+ sh "gem build #{gemspec_file}"
107
+ sh "mv #{gem_file} pkg"
108
+ end
109
+
110
+ desc "Generate #{gemspec_file}"
111
+ task :gemspec => :validate do
112
+ # read spec file and split out manifest section
113
+ spec = File.read(gemspec_file)
114
+ head, manifest, tail = spec.split(" # = MANIFEST =\n")
115
+
116
+ # replace name version and date
117
+ replace_header(head, :name)
118
+ replace_header(head, :version)
119
+ replace_header(head, :date)
120
+ #comment this out if your rubyforge_project has a different name
121
+ replace_header(head, :rubyforge_project)
122
+
123
+ # determine file list from git ls-files
124
+ files = `git ls-files`.
125
+ split("\n").
126
+ sort.
127
+ reject { |file| file =~ /^\./ }.
128
+ reject { |file| file =~ /^(rdoc|pkg)/ }.
129
+ map { |file| " #{file}" }.
130
+ join("\n")
131
+
132
+ # piece file back together and write
133
+ manifest = " s.files = %w[\n#{files}\n ]\n"
134
+ spec = [head, manifest, tail].join(" # = MANIFEST =\n")
135
+ File.open(gemspec_file, 'w') { |io| io.write(spec) }
136
+ puts "Updated #{gemspec_file}"
137
+ end
138
+
139
+ desc "Validate #{gemspec_file}"
140
+ task :validate do
141
+ libfiles = Dir['lib/*'] - ["lib/#{name}.rb", "lib/#{name}"]
142
+ unless libfiles.empty?
143
+ puts "Directory `lib` should only contain a `#{name}.rb` file and `#{name}` dir."
144
+ exit!
145
+ end
146
+ unless Dir['VERSION*'].empty?
147
+ puts "A `VERSION` file at root level violates Gem best practices."
148
+ exit!
149
+ end
150
+ end
@@ -0,0 +1,93 @@
1
+ ## This is the rakegem gemspec template. Make sure you read and understand
2
+ ## all of the comments. Some sections require modification, and others can
3
+ ## be deleted if you don't need them. Once you understand the contents of
4
+ ## this file, feel free to delete any comments that begin with two hash marks.
5
+ ## You can find comprehensive Gem::Specification documentation, at
6
+ ## http://docs.rubygems.org/read/chapter/20
7
+ Gem::Specification.new do |s|
8
+ s.specification_version = 2 if s.respond_to? :specification_version=
9
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
10
+ s.rubygems_version = '1.3.5'
11
+
12
+ ## Leave these as is they will be modified for you by the rake gemspec task.
13
+ ## If your rubyforge_project name is different, then edit it and comment out
14
+ ## the sub! line in the Rakefile
15
+ s.name = 'asciidoctor'
16
+ s.version = '0.0.1'
17
+ s.date = '2012-06-14'
18
+ s.rubyforge_project = 'asciidoctor'
19
+
20
+ ## Make sure your summary is short. The description may be as long
21
+ ## as you like.
22
+ s.summary = "Pure Ruby Asciidoc to HTML rendering."
23
+ s.description = "Render all the AsciiDocs! The time, she is now, for all good renders."
24
+
25
+ ## List the primary authors. If there are a bunch of authors, it's probably
26
+ ## better to set the email to an email list or something. If you don't have
27
+ ## a custom homepage, consider using your GitHub URL or the like.
28
+ s.authors = ["Ryan Waldron", "Jeremy McAnally"]
29
+ s.email = 'rew@erebor.com'
30
+ s.homepage = 'http://github.com/erebor/asciidoctor'
31
+
32
+ ## This gets added to the $LOAD_PATH so that 'lib/NAME.rb' can be required as
33
+ ## require 'NAME.rb' or'/lib/NAME/file.rb' can be as require 'NAME/file.rb'
34
+ s.require_paths = %w[lib]
35
+
36
+ ## If your gem includes any executables, list them here.
37
+ s.executables = ["asciidoctor"]
38
+
39
+ ## Specify any RDoc options here. You'll want to add your README and
40
+ ## LICENSE files to the extra_rdoc_files list.
41
+ s.rdoc_options = ["--charset=UTF-8"]
42
+ s.extra_rdoc_files = %w[LICENSE]
43
+
44
+ ## List your runtime dependencies here. Runtime dependencies are those
45
+ ## that are needed for an end user to actually USE your code.
46
+ s.add_dependency('json')
47
+ s.add_dependency('nokogiri')
48
+
49
+ ## List your development dependencies here. Development dependencies are
50
+ ## those that are only needed during development
51
+ s.add_development_dependency('mocha')
52
+ s.add_development_dependency('nokogiri')
53
+ s.add_development_dependency('htmlentities')
54
+
55
+ ## Leave this section as-is. It will be automatically generated from the
56
+ ## contents of your Git repository via the gemspec task. DO NOT REMOVE
57
+ ## THE MANIFEST COMMENTS, they are used as delimiters by the task.
58
+ # = MANIFEST =
59
+ s.files = %w[
60
+ LICENSE
61
+ README.md
62
+ Rakefile
63
+ asciidoctor.gemspec
64
+ bin/asciidoctor
65
+ lib/asciidoctor.rb
66
+ lib/asciidoctor/block.rb
67
+ lib/asciidoctor/debug.rb
68
+ lib/asciidoctor/document.rb
69
+ lib/asciidoctor/errors.rb
70
+ lib/asciidoctor/list_item.rb
71
+ lib/asciidoctor/render_templates.rb
72
+ lib/asciidoctor/renderer.rb
73
+ lib/asciidoctor/section.rb
74
+ lib/asciidoctor/string.rb
75
+ lib/asciidoctor/version.rb
76
+ noof.rb
77
+ test/document_test.rb
78
+ test/fixtures/asciidoc.txt
79
+ test/fixtures/asciidoc_index.txt
80
+ test/fixtures/ascshort.txt
81
+ test/fixtures/list_elements.asciidoc
82
+ test/headers_test.rb
83
+ test/list_elements_test.rb
84
+ test/paragraphs_test.rb
85
+ test/test_helper.rb
86
+ test/text_test.rb
87
+ ]
88
+ # = MANIFEST =
89
+
90
+ ## Test files will be grabbed from the file list. Make sure the path glob
91
+ ## matches what you actually use.
92
+ s.test_files = s.files.select { |path| path =~ /^test\/.*_test\.rb/ }
93
+ end
@@ -0,0 +1,8 @@
1
+ #!/bin/env ruby
2
+
3
+ $:.unshift File.dirname(__FILE__) + '/../lib'
4
+
5
+ require 'asciidoctor'
6
+ require 'asciidoctor/cli'
7
+
8
+ Asciidoctor::Cli.new.run
@@ -0,0 +1,152 @@
1
+ require 'rubygems'
2
+ require 'cgi'
3
+ require 'erb'
4
+
5
+ $:.unshift(File.dirname(__FILE__))
6
+ $:.unshift(File.join(File.dirname(__FILE__), '..', 'vendor'))
7
+
8
+ # Public: Methods for parsing Asciidoc input files and rendering documents
9
+ # using erb templates.
10
+ #
11
+ # Asciidoc documents comprise a header followed by zero or more sections.
12
+ # Sections are composed of blocks of content. For example:
13
+ #
14
+ # Doc Title
15
+ # =========
16
+ #
17
+ # SECTION 1
18
+ # ---------
19
+ #
20
+ # This is a paragraph block in the first section.
21
+ #
22
+ # SECTION 2
23
+ #
24
+ # This section has a paragraph block and an olist block.
25
+ #
26
+ # 1. Item 1
27
+ # 2. Item 2
28
+ #
29
+ # Examples:
30
+ #
31
+ # lines = File.readlines(filename)
32
+ #
33
+ # doc = Asciidoctor::Document.new(lines)
34
+ # html = doc.render(template_path)
35
+ module Asciidoctor
36
+ REGEXP = {
37
+ # [[Foo]] (also allows, say, [[[]] or [[[Foo[f]], but I don't think it is supposed to (TODO))
38
+ :anchor => /^\[(\[.+\])\]\s*$/,
39
+
40
+ # Foowhatevs [[Bar]]
41
+ :anchor_embedded => /^(.*)\[\[([^\]]+)\]\]\s*$/,
42
+
43
+ # [[[Foo]]] (does not suffer quite the same malady as :anchor, but almost. Allows [ but not ] in internal capture
44
+ :biblio => /\[\[\[([^\]]+)\]\]\]/,
45
+
46
+ # [caption="Foo"]
47
+ :caption => /^\[caption=\"([^\"]+)\"\]/,
48
+
49
+ # <1> Foo
50
+ :colist => /^(\<\d+\>)\s*(.*)/,
51
+
52
+ # // (and then whatever)
53
+ :comment => /^\/\/\s/,
54
+
55
+ # + Note that Asciidoc appears to allow continuations using + at
56
+ # the end of the previous line and indenting
57
+ # the following line (as in :lit_par)
58
+ :continue => /^\+\s*$/,
59
+
60
+ # foo:: || foo;;
61
+ # Should be followed by a definition line, e.g.,
62
+ # foo::
63
+ # That which precedes 'bar' (see also, bar)
64
+ :dlist => /^(\s*)(\S.*)(::|;;)\s*$/,
65
+
66
+ # ====
67
+ :example => /^={4,}\s*$/,
68
+
69
+ # == Foo
70
+ # Yields a Level 2 title, so exactly the same as
71
+ # Foo
72
+ # ~~~
73
+ # would yield. match[1] is the == sequence, whose
74
+ # length determines the level, and match[2] is the
75
+ # title itself.
76
+ :level_title => /^(={2,5})\s+(\S.*)\s*$/,
77
+
78
+ # ====== || ------ || ~~~~~~ || ^^^^^^ || ++++++
79
+ :line => /^([=\-~^\+])+\s*$/,
80
+
81
+ # ----
82
+ :listing => /^\-{4,}\s*$/,
83
+
84
+ # [source, ruby]
85
+ # Treats the next paragraph as a :listing block
86
+ :listing_source => /^\[source,\s*([^\]]+)\]\s*$/,
87
+
88
+ # ....
89
+ :lit_blk => /^\.{4,}\s*$/,
90
+
91
+ # <TAB>Foo or one-or-more-spaces-or-tabs then whatever
92
+ :lit_par => /^([ \t]+.*)$/,
93
+
94
+ # "Wooble" || Wooble
95
+ :name => /^(["A-Za-z].*)\s*$/, # I believe this fails to require " chars to be paired (TODO)
96
+
97
+ # [NOTE]
98
+ :note => /^\[NOTE\]\s*$/,
99
+
100
+ # --
101
+ :oblock => /^\-\-\s*$/,
102
+
103
+ # 1.Foo || 1. Foo || . Foo
104
+ :olist => /^\s*(\d+\.|\. )(.*)$/,
105
+
106
+ # ____
107
+ :quote => /^_{4,}\s*$/,
108
+
109
+ # ____
110
+ :ruler => /^'{3,}\s*$/,
111
+
112
+ # ****
113
+ :sidebar_blk => /^\*{4,}\s*$/,
114
+
115
+ # and blah blah blah
116
+ # ^^^^ <--- whitespace
117
+ :starts_with_whitespace => /\s+(.+)\s+\+\s*$/,
118
+
119
+ # .Foo but not . Foo or ..Foo
120
+ :title => /^\.([^\s\.].*)\s*$/,
121
+
122
+ # * Foo || - Foo
123
+ :ulist => /^\s*([\*\-])\s+(.*)$/,
124
+
125
+ # [verse]
126
+ :verse => /^\[verse\]\s*$/
127
+ }
128
+
129
+ INTRINSICS = Hash.new{|h,k| STDERR.puts "Missing intrinsic: #{k.inspect}"; "{#{k}}"}.merge(
130
+ 'startsb' => '[',
131
+ 'endsb' => ']',
132
+ 'caret' => '^',
133
+ 'asterisk' => '*',
134
+ 'tilde' => '~',
135
+ 'litdd' => '--',
136
+ 'plus' => '+',
137
+ 'apostrophe' => "'",
138
+ 'backslash' => "\\",
139
+ 'backtick' => '`'
140
+ )
141
+
142
+ require 'asciidoctor/block'
143
+ require 'asciidoctor/debug'
144
+ require 'asciidoctor/document'
145
+ require 'asciidoctor/errors'
146
+ require 'asciidoctor/list_item'
147
+ require 'asciidoctor/render_templates'
148
+ require 'asciidoctor/renderer'
149
+ require 'asciidoctor/section'
150
+ require 'asciidoctor/string'
151
+ require 'asciidoctor/version'
152
+ end