diff --git a/.gitignore b/.gitignore index a61a934..874f5d8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /pkg /doc /.yardoc -Gemfile.lock \ No newline at end of file +/coverage +Gemfile.lock diff --git a/.simplecov b/.simplecov new file mode 100644 index 0000000..6ecefd4 --- /dev/null +++ b/.simplecov @@ -0,0 +1,4 @@ +SimpleCov.start do + add_filter '/spec/' + add_filter '/docs/' +end diff --git a/.travis.yml b/.travis.yml index b2e0b56..badf7c5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,14 +12,11 @@ matrix: gemfile: Gemfile.1.8.7 - rvm: jruby-19mode gemfile: Gemfile - - rvm: rbx-18mode - gemfile: Gemfile.1.8.7 - - rvm: rbx-19mode + - rvm: rbx gemfile: Gemfile branches: only: - master -script: "bundle exec rake spec" - +script: "bundle exec rake test_with_coveralls" diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a4bde4..2d1c35b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,39 +1,379 @@ -0.7.0 +0.7.1 ----- -* Maruku has been relicensed under the MIT license. +* Handles XML comments correctly. +* Handles trailing blanks in tables. +* Better TOC generation. +* In HTML output, don't include TeX source for equations. This is handled + automatically by itex2MML 1.5. +* Removed extraneous newlines from around the output of fenced code blocks. #112 +* Properly handle empty code blocks (``). #108 +* No longer print a warning when headers have entities in them. #113 -* Maruku now uses Nokogiri to parse and output HTML, fixing many bugs and - providing a big speedup. - -* JRuby no longer obfuscates email addresses due to a Nokogiri bug. +0.7.0 +----- +* Many bug fixes. +* Maruku now uses a Nokogiri-based HTML parser. +* Non-ASCII text is generally handled better. +* HTML output is no longer "pretty". This will be fixed in a future release. +* Table of contents no longer includes inline styles. +* Maruku has been relicensed under the MIT license. +* Maruku now uses its own method to output HTML, fixing many bugs. * Maruku produces unicode characters in the output HTML in many cases where before it produced XML entity references. - * Empty link references now match the way other Markdown implementations work. - * Maruku now requires Ruby 1.8.7 or newer. - * Maruku no longer extends NilType or String with its own internal-use methods. - * Backtick-style (```) and tilde-style (~~~) fenced code blocks are now supported, including the language option (```ruby). They must be enabled using the :fenced_code_blocks option. - * Parsing errors and warnings are less repetitive. - * Markdown is parsed within span-level HTML elements. - * Markdown content after HTML tags is no longer lost. - -* Maruku is now tested on MRI 2.0.0, MRI 1.9.3, MRI 1.8.7, Rubinius and JRuby. - +* Maruku is now tested on MRI 2.0.0, MRI 1.9.3, MRI 1.9.2, MRI 1.8.7, Rubinius and JRuby. * Deeply nested lists work correctly in many more cases. - * The maruku CLI exits with a nonzero exit code when given invalid options. 0.6.1 ----- * Fix iconv warning in Ruby 1.9. + +0.5.6 +----- + +* News: + + - Now Maruku is in the official Gentoo Portage tree (done by [Aggelos Orfanakos]) + +* New stuff: + + - Attribute `maruku_signature` defaults to false. (many people asked this) + - unittests scripts are included in the distribution. + - New attribute `filter_html`: if true, raw HTML/XML is discarded. (asked by Marik) + - Command line: if output file is `-`, Maruku writes to stdout. + +* Bug fixes: + + * Another tiny bug in HTML parsing. + * In latex, `\linebreak` was used instead of `\newline` (reported by Sam Kleinman) + * Fixed bug with non-alpha numeric characters in ref.ids (reported by Aggelos Orfanakos) + + +* Pending bugs/feature requests: + + - Maruku does not allow 3-space indented lists. + - Lists item whose first character is UTF8 are not recognized (reported by Aggelos Orfanakos) + - Maruku cannot output `"`-delimited attributes, because `REXML` does not support it. + +[Aggelos Orfanakos]: http://agorf.gr/ + +0.5.5 +----- + +* Features: + + * Input of HTML numeric entities: + + Examples of numeric character references include © or © + for the copyright symbol, Α or Α for the Greek capital + letter alpha, and ا or ا for the Arabic letter alef. + + > Examples of numeric character references include © or © + > for the copyright symbol, Α or Α for the Greek capital + > letter alpha, and ا or ا for the Arabic letter alef. + +* Bug fixes: + + * Alt text was ignored for images. + * Fixed minor bug in reading HTML inside paragraph. + * Changed rules for block-level HTML to make it similar to Markdown.pl. + For example: + + Paragraph +
+ + will be translated to + +

Paragraph +

+ + while this: + + Paragraph + +
+ + becomes + +

Paragraph

+ +
+ +* **Pending bugs**: there are some problems when parsing lists. It is difficult + to get it right because the spec is very fuzzy. At the moment, list items + cannot be indented by more than 1 space. + +0.5.4 +----- + +* Features: + + * [All HTML attributes](http://www.w3.org/TR/html4/index/attributes.html) are supported. + + > Science is a wonderful thing if one does not + > have to earn one's living at it. + {: cite="http://en.wikiquote.org/wiki/Albert_Einstein"} + + * Attribute `doc_prefix`. + + * Math: + + * `\begin{equation}` and `\end{equation}` are understood. + * Math parsing enabled per-instance using the `math_enabled` attribute. + * `math_numbered` attribute. + +* Bug fixes: + + * Runs quietly with `ruby -w`. + * Fixed a bug which could cause data-loss when reading indented lines. + + +0.5.3 +----- + +* Features: + + * [All HTML `table` attributes](http://www.w3.org/TR/html4/struct/tables.html#h-11.2.1) + can be used (`summary`, `width`, `frame`, `rules`, + `border`, `cellspacing`, `cellpadding`). + + The next version will hopefully use all HTML attributes. + + + + +* Bug fixes: + + * Crash on this line: (found by Aggelos Orfanakos) + + [test][]: + + * Regression with attribute system (found by Charles) + +0.5.1 +----- + +* Bug fixes: + + * Workaround for Internet Explorer bug: + be very sure that `'` is always written as `'`. + + * Support for empty images ref: `![image]` and `![image][]`. + + * Fixed bug in parsing attribute lists definitions. + +* Minor things: + + * Now code blocks are written as a `` element inside a `
`, and
+		`` elements have both `class` and `lang` attributes set
+		to the specified language.
+
+		Example:
+
+			    Example
+			{:lang=ruby}
+		{:lang=markdown}
+
+		produces:
+
+			
Example
+ {:lang=xml} + +0.5.0 +----- + +* Syntax changes: + + * Compatibility with newest Markdown.pl: `[text]` as a synonim of `[text][]`. + + * Meta data: the first IAL in a span environment now refers to the parent. + This makes it possible to set attributes for cells: + + Head | Head | + ---------------+-------+-- + {:r} Hello + ... + + {:r: scope='row'} + + The first cell will have the `scope` attribute set to `row`. + +* New settings: + + * Disable the Maruku signature by setting `maruku signature: false` + +* Stricter doctype. By the way -- did I mention it? -- + **Maruku HTML has always been proper validating XHTML strict** + (if a page does not validate, please report it as a bug). + + Of course, this only matters when using `maruku` as a standalone + program. + + * I have updated the XHTML DTD used to support MathML: + currently using XHTML+MathML+SVG. + * Content-type set to `application/xhtml+xml` + * All entities are written as numeric entities. + +* Bug fixes + + * Many fixes in the code handling the sanitizing of inline HTML. + * `markdown=1` did not propagate to children. + * LaTeX: An exception was raised if an unknown entity was used. + +0.4.2 +----- + +* Adapted syntax to the [new meta-data proposal][proposal]. + +* Changes in LaTeX export: + + * Links to external URLs are blue by default. + + * New attributes: `latex_preamble` to add a custom preamble, + and `latex_cjk` to add packages for UTF-8 Japanese characters. + (**support for this is still shaky**). Example: + + Title: my document + LaTeX CJK: true + LaTeX preamble: preamble.tex + + Content + +* Bug fixes + + + Images were not given `id` or `class` attributes. + + + Fixed bug in LaTeX export with handling of `<`,`>` enclosed URLs: ``. + +0.4.1 +----- + +* Implemented SmartyPants support: + + 'Twas a "test" to 'remember' -- in the '90s + --- while I was <>. She was 6\"12\'. + > 'Twas a "test" to 'remember' -- in the '90s --- while I was <>. + > She was 6\"12\'. + + I adapted the code from RubyPants. + +* Server directives between `` are properly preserved. +* Changes in LaTeX export: + + * Now Japanese text rendering sort of works, using the following packages: + + \usepackage[C40]{fontenc} + \usepackage[cjkjis]{ucs} + \usepackage[utf8x]{inputenc} + + Nevertheless, I could only get bitmap fonts working -- probably it's a problem + with my setup. + + A quick test: 日本、中国、ひらがな、カタカナ。 + + * Fixed bugs in rendering of immediate links. + * External packages are `require`d only if needed. + * More symbols supported. + See the symbol list + [in HTML](http://maruku.rubyforge.org/entity_test.html) and + [in PDF](http://maruku.rubyforge.org/entity_test.pdf). + + +0.4 +--- + +* First implementation of [the new meta-data syntax][meta]. +* General refactorization of the code and much cleaner error reporting. +* Created [the RDOC documentation][rdoc]. +* The `add_whitespace` method took too much time -- it was O(n^2). +* Added unit-tests for block-level elements. + +[rdoc]: http://maruku.rubyforge.org/rdoc/ +[meta]: http://maruku.rubyforge.org/proposal.html + + + +[Jacques Distler]: http://golem.ph.utexas.edu/~distler +[itex2MML]: http://golem.ph.utexas.edu/~distler/blog/itex2MML.html +[math]: http://rubyforge.maruku.org/math.html + + +0.3 +--- + +* A real parser is used instead of a regexp-based system, also for span-level + elements. + + Now Maruku is almost 2x faster than Bluecloth, while having more features. + + Here are some benchmarks: + + BlueCloth (to_html): parsing 0.00 sec + rendering 1.54 sec = 1.55 sec + Maruku (to_html): parsing 0.47 sec + rendering 0.38 sec = 0.85 sec + Maruku (to_latex): parsing 0.49 sec + rendering 0.25 sec = 0.73 sec + + This is the result of running `lib/maruku/tests/benchmark.rb` on the Markdown + specification. + +* Prettier HTML output by adding whitespace. + +* Added a full suite of unit-tests for the span-level parser. + +* Error management: Having a real parser, Maruku warns you about syntax issues. + + The default action is to warn and try to continue. If you do this: + + Maruku.new(string, {:on_error => :raise}) + + then syntax errors will cause an exception to be raised (you can catch this + and retry). + +* Fixed a series of bugs in handling inline HTML code. + +Immediate TODO-list: + +* UTF-8 input/output works OK for HTML, however I am having pain trying to export + to LaTeX. I want at least Japanese characters support, so if you know how to + do this you are very welcome to give me an hand. + + For example: in the HTML version, you should see accented characters in this + parenthesis: + + > (àèìòù) + + and Japanese text in these other parentheses: + + > (カタカナで 私の 名前は アンドレア チェンシ です). + > + > (日本のガルは 大好き、でも、日本語は難しですから、そうぞ 英語話すガルを おしえてください). + + In the LaTeX version, these do not appear. I know how to do LaTeX with + ISO-8859-1 encoding (European characters), but I'm struggling with half-baked + solutions for UTF-8 encoded documents. + +* Implement the [new meta-data proposal][proposal]. + +* Exporting to Markdown (pretty printing). + +* Exporting to HTML splitting in multiple files. + +* RubyPants. + +* Support for images in PDF. + + +[proposal]: http://maruku.rubyforge.org/proposal.html +[contact]: http://www.dis.uniroma1.it/~acensi/contact.html +[markdown-discuss]: http://six.pairlist.net/mailman/listinfo/markdown-discuss +[tracker]: http://rubyforge.org/tracker/?group_id=2795 diff --git a/Gemfile b/Gemfile index 242f8a1..8a2745e 100644 --- a/Gemfile +++ b/Gemfile @@ -1,10 +1,30 @@ source "https://rubygems.org" -# dependencies are specified in maruku.gemspec +# Required dependencies are specified in maruku.gemspec gemspec -# itextomml won't build for jRuby, but we should test with it otherwise +# Optional dependencies that we want to test with +gem 'syntax', '~> 1.1.0' +gem 'nokogiri', '~> 1.5' + if RUBY_PLATFORM != 'java' + # itextomml won't build for jRuby, but we should test with it otherwise gem "itextomml", '~> 1.5.0' end + +# Rubinius is gemifying the standard library +platforms :rbx do + gem 'rubysl', '~> 2.0' + gem 'racc' + gem 'json' + gem 'rubinius-coverage' +end + +# Development tools +gem 'rake', '~> 10.1.0' +gem 'rspec', '~> 2.14.1' +gem 'yard', '~> 0.8.7' +gem 'nokogiri-diff', '~> 0.2.0' +gem 'simplecov', '~> 0.7.1' +gem 'coveralls', :require => false diff --git a/README.md b/README.md index db27f14..f80bed9 100644 --- a/README.md +++ b/README.md @@ -8,21 +8,22 @@ Maruku implements: * All the improvements in PHP Markdown Extra. * A new meta-data syntax. -Read more about [Maruku's Markdown syntax](http://rdoc.info/github/bhollis/maruku/master/file/docs/markdown_syntax.md). It also supports [inline math](http://rdoc.info/github/bhollis/maruku/master/file/docs/math.md). [Maruku docs](http://rdoc.info/github/bhollis/maruku/master/). +Read more about [Maruku's Markdown syntax](https://github.com/bhollis/maruku/blob/master/docs/markdown_syntax.md). It also supports [inline math](https://github.com/bhollis/maruku/blob/master/docs/math.md). [Maruku docs](http://rdoc.info/github/bhollis/maruku/master/). News about Maruku is posted at [http://benhollis.net/blog/category/maruku/](http://benhollis.net/blog/category/maruku/) -[![Build Status](https://api.travis-ci.org/bhollis/maruku.png?branch=master)](http://travis-ci.org/bhollis/maruku) +[![Build Status](https://api.travis-ci.org/bhollis/maruku.png?branch=master)][travis] [![Gem Version](https://fury-badge.herokuapp.com/rb/maruku.png)](http://badge.fury.io/rb/maruku) [![Dependency Status](https://gemnasium.com/bhollis/maruku.png)](https://gemnasium.com/bhollis/maruku) [![Code Climate](https://codeclimate.com/github/bhollis/maruku.png)](https://codeclimate.com/github/bhollis/maruku) +[![Coverage Status](https://coveralls.io/repos/bhollis/maruku/badge.png)](https://coveralls.io/r/bhollis/maruku) ## Installing Make sure you have Ruby and RubyGems, then run: gem install maruku - + ## Basic use To convert Markdown from your Ruby programs, first create a new document and then get @@ -78,35 +79,32 @@ then calls `pdflatex` to transform the LaTeX to a PDF: The public interface is the `Maruku` class. Everything else is in the module `MaRuKu`. -## Ruby 1.8.7 - -The maintainers of this project, in concert with the maintainers of Ruby, -**strongly** recommend using the latest patchlevel of Ruby 1.9.2 or later. -[As of July 1, 2013, Ruby 1.8.7 is no longer officially maintained.][retired] -This means fixes will no longer be provided, even for known security -vulnerabilities. +## Dependencies -[retired]: http://www.ruby-lang.org/en/news/2013/06/30/we-retire-1-8-7/ +Maruku will not depend on any gem that is not pure-Ruby. This helps maximize compatibility across Ruby implementations and make Maruku easy to use. Beyond that, Maruku should not depend on any other gem unless absolutely necessary - this make Maruku easy to consume and avoids dependency version conflicts. -With this caveat, if you wish to bundle `maruku` into your application on Ruby -1.8.7, you must add the following line to your `Gemfile`. +## Supported Ruby Versions - gem 'nokogiri', '~> 1.5.0' +This library aims to support and is [tested against][travis] the following Ruby +implementations: -Also, ensure that you are using LibXML version 2.8.0, since there is an -[issue with LibXML version 2.9.0][issue829] ([and 2.9.1][issue904]). +* Ruby 1.8.7 +* Ruby 1.9.2 +* Ruby 1.9.3 +* Ruby 2.0.0 +* JRuby (Travis' version, 1.8 and 1.9 modes) +* Rubinius (Travis' version, 1.8 and 1.9 modes) -[issue829]: https://github.com/sparklemotion/nokogiri/issues/829 -[issue904]: https://github.com/sparklemotion/nokogiri/issues/904 +If something doesn't work on one of these interpreters, it's a bug. ## Contributing * Find something you would like to work on. * Look for anything you can help with in the [issue tracker](https://github.com/bhollis/maruku/issues). - * Look at the [code quality metrics](https://codeclimate.com/github/bhollis/maruku) for anything you can help clean up. + * Look at the [code quality metrics](https://codeclimate.com/github/bhollis/maruku) or [code coverage report](https://coveralls.io/r/bhollis/maruku) for anything you can help clean up or add tests for. * Or anything else! * Fork the project and do your work in a topic branch. - * Make sure your changes will work on both Ruby 1.8.7 and Ruby 1.9 + * Make sure your changes will work on all the Rubies we test on. * Add tests in `spec/block_docs` for the behavior you want to test. * Run all the tests using `bundle exec rake`. * Rebase your branch against `bhollis/maruku` to make sure everything is up to date. @@ -117,3 +115,4 @@ Also, ensure that you are using LibXML version 2.8.0, since there is an Copyright (c) 2006 Andrea Censi. MIT license, see [MIT-LICENSE.txt] for details. [MIT-LICENSE.txt]: https://github.com/bhollis/maruku/blob/master/MIT-LICENSE.txt +[travis]: http://travis-ci.org/bhollis/maruku diff --git a/Rakefile b/Rakefile index b4dcb8c..cff4655 100644 --- a/Rakefile +++ b/Rakefile @@ -15,21 +15,40 @@ end require 'rake/clean' require 'rspec/core/rake_task' require 'yard' +require 'coveralls/rake/task' -task :default => :spec -CLEAN.replace %w(pkg doc .yardoc) +CLEAN.replace %w(pkg doc .yardoc coverage) Bundler::GemHelper.install_tasks desc "Run RSpec" -RSpec::Core::RakeTask.new do |t| +RSpec::Core::RakeTask.new(:core_spec) do |t| t.verbose = false t.rspec_opts = '--color -f nested --tty' end +task :nokogiri_spec do + ENV['HTML_PARSER'] = 'nokogiri' + Rake::Task[:core_spec].reenable + Rake::Task[:core_spec].invoke +end + +task :rexml_spec do + ENV['HTML_PARSER'] = 'rexml' + Rake::Task[:core_spec].reenable + Rake::Task[:core_spec].invoke +end + +task :spec => [:rexml_spec, :nokogiri_spec] + task :default => :spec +task :test => :spec YARD::Rake::YardocTask.new do |t| t.files = FileList["lib/maruku.rb", "lib/maruku/*.rb", "lib/maruku/ext/*.rb", "lib/maruku/ext/math/*.rb"] end + +Coveralls::RakeTask.new +# Travis runs this task +task :test_with_coveralls => [:spec, 'coveralls:push'] diff --git a/bin/maruku b/bin/maruku index b6a5a33..e0261a6 100755 --- a/bin/maruku +++ b/bin/maruku @@ -141,7 +141,7 @@ end.each do |filename, input| out = doc.to_md when :s5 suffix = '_s5slides.html' - out = doc.to_s5(:content_only => false) + out = doc.to_s5(:content_only => false, :print_slides => true) end end diff --git a/maruku.gemspec b/maruku.gemspec index 6078ae9..beb8838 100644 --- a/maruku.gemspec +++ b/maruku.gemspec @@ -31,8 +31,9 @@ Gem::Specification.new do |s| s.required_ruby_version = '>= 1.8.7' s.add_dependency('nokogiri', '~> 1.5', '>= 1.5.6') + s.add_dependency('syntax', '~> 1.1.0') + s.add_dependency('itextomml', '>= 1.5.0') - s.add_development_dependency('syntax', '~> 1.0.0') s.add_development_dependency('rake', '~> 0.9.2') s.add_development_dependency('rspec', '~> 2.12.0') s.add_development_dependency('yard', '~> 0.7.2')