test/test_pandoc_ruby.rb in pandoc-ruby-2.1.0 vs test/test_pandoc_ruby.rb in pandoc-ruby-2.1.1

- old
+ new

@@ -73,11 +73,11 @@ .with('pandoc -s -f markdown --to rst --no-wrap') \ .returns(true) assert converter.convert(:s, { :f => :markdown, :to => :rst }, 'no-wrap') end - it 'converts underscore symbol ares to hyphenated long options' do + it 'converts underscore symbol args to hyphenated long options' do converter = PandocRuby.new(@string, { :email_obfuscation => :javascript }, :table_of_contents) converter \ .expects(:execute) \ @@ -90,10 +90,48 @@ converter = PandocRuby.new(@string, 'toc') converter.expects(:execute).with('pandoc --toc').returns(true) assert converter.convert end + it 'supports reader extensions' do + assert_equal( + PandocRuby.convert( + "Line 1\n# Heading", + :from => 'markdown_strict', + :to => 'html' + ), + "<p>Line 1</p>\n<h1>Heading</h1>\n" + ) + assert_equal( + PandocRuby.convert( + "Line 1\n# Heading", + :from => 'markdown_strict+blank_before_header', + :to => 'html' + ), + "<p>Line 1 # Heading</p>\n" + ) + end + + it 'supports writer extensions' do + assert_equal( + PandocRuby.convert( + "<sub>example</sub>\n", + :from => 'html', + :to => 'markdown' + ), + "~example~\n" + ) + assert_equal( + PandocRuby.convert( + "<sub>example</sub>\n", + :from => 'html', + :to => 'markdown-subscript' + ), + "<sub>example</sub>\n" + ) + end + it 'raises RuntimeError from pandoc executable error' do assert_raises(RuntimeError) do PandocRuby.new('# hello', 'badopt').to_html5 end end @@ -175,48 +213,112 @@ ) end end it 'has reader and writer constants' do - assert_equal PandocRuby::READERS, - 'html' => 'HTML', - 'latex' => 'LaTeX', - 'textile' => 'textile', - 'native' => 'pandoc native', - 'markdown' => 'markdown', - 'json' => 'pandoc JSON', - 'rst' => 'reStructuredText' + assert_equal( + PandocRuby::READERS, + 'commonmark' => 'CommonMark Markdown', + 'creole' => 'Creole 1.0', + 'csv' => 'CSV table', + 'docbook' => 'DocBook', + 'docx' => 'Word docx', + 'dokuwiki' => 'DokuWiki markup', + 'epub' => 'EPUB', + 'fb2' => 'FictionBook2 e-book', + 'gfm' => 'GitHub-Flavored Markdown', + 'haddock' => 'Haddock markup', + 'html' => 'HTML', + 'ipynb' => 'Jupyter notebook', + 'jats' => 'JATS XML', + 'jira' => 'Jira wiki markup', + 'json' => 'JSON version of native AST', + 'latex' => 'LaTex', + 'man' => 'roff man', + 'markdown' => "Pandoc's Markdown", + 'markdown_mmd' => 'MultiMarkdown', + 'markdown_phpextra' => 'PHP Markdown Extra', + 'markdown_strict' => 'original unextended Markdown', + 'mediawiki' => 'MediaWiki markup', + 'muse' => 'Muse', + 'native' => 'native Haskell', + 'odt' => 'ODT', + 'opml' => 'OPML', + 'org' => 'Emacs Org mode', + 'rst' => 'reStructuredText', + 't2t' => 'txt2tags', + 'textile' => 'Textile', + 'tikiwiki' => 'TikiWiki markup', + 'twiki' => 'TWiki markup', + 'vimwiki' => 'Vimwiki' + ) - assert_equal PandocRuby::STRING_WRITERS, - 'mediawiki' => 'MediaWiki markup', - 'html' => 'HTML', - 'plain' => 'plain', - 'latex' => 'LaTeX', - 's5' => 'S5 HTML slideshow', - 'textile' => 'textile', - 'texinfo' => 'GNU Texinfo', - 'docbook' => 'DocBook XML', - 'html5' => 'HTML5', - 'native' => 'pandoc native', - 'org' => 'emacs org mode', - 'rtf' => 'rich text format', - 'markdown' => 'markdown', - 'man' => 'groff man', - 'dzslides' => 'Dzslides HTML slideshow', - 'beamer' => 'Beamer PDF slideshow', - 'json' => 'pandoc JSON', - 'opendocument' => 'OpenDocument XML', - 'slidy' => 'Slidy HTML slideshow', - 'rst' => 'reStructuredText', - 'context' => 'ConTeXt', - 'asciidoc' => 'asciidoc' + assert_equal( + PandocRuby::STRING_WRITERS, + 'asciidoc' => 'AsciiDoc', + 'asciidoctor' => 'AsciiDoctor', + 'beamer' => 'LaTeX beamer slide show', + 'commonmark' => 'CommonMark Markdown', + 'context' => 'ConTeXt', + 'docbook' => 'DocBook 4', + 'docbook4' => 'DocBook 4', + 'docbook5' => 'DocBook 5', + 'dokuwiki' => 'DokuWiki markup', + 'fb2' => 'FictionBook2 e-book', + 'gfm' => 'GitHub-Flavored Markdown', + 'haddock' => 'Haddock markup', + 'html' => 'HTML, i.e. HTML5/XHTML polyglot markup', + 'html5' => 'HTML, i.e. HTML5/XHTML polyglot markup', + 'html4' => 'XHTML 1.0 Transitional', + 'icml' => 'InDesign ICML', + 'ipynb' => 'Jupyter notebook', + 'jats_archiving' => 'JATS XML, Archiving and Interchange Tag Set', + 'jats_articleauthoring' => 'JATS XML, Article Authoring Tag Set', + 'jats_publishing' => 'JATS XML, Journal Publishing Tag Set', + 'jats' => 'alias for jats_archiving', + 'jira' => 'Jira wiki markup', + 'json' => 'JSON version of native AST', + 'latex' => 'LaTex', + 'man' => 'roff man', + 'markdown' => "Pandoc's Markdown", + 'markdown_mmd' => 'MultiMarkdown', + 'markdown_phpextra' => 'PHP Markdown Extra', + 'markdown_strict' => 'original unextended Markdown', + 'mediawiki' => 'MediaWiki markup', + 'ms' => 'roff ms', + 'muse' => 'Muse', + 'native' => 'native Haskell', + 'opml' => 'OPML', + 'opendocument' => 'OpenDocument', + 'org' => 'Emacs Org mode', + 'pdf' => 'PDF', + 'plain' => 'plain text', + 'pptx' => 'PowerPoint slide show', + 'rst' => 'reStructuredText', + 'rtf' => 'Rich Text Format', + 'texinfo' => 'GNU Texinfo', + 'textile' => 'Textile', + 'slideous' => 'Slideous HTML and JavaScript slide show', + 'slidy' => 'Slidy HTML and JavaScript slide show', + 'dzslides' => 'DZSlides HTML5 + JavaScript slide show', + 'revealjs' => 'reveal.js HTML5 + JavaScript slide show', + 's5' => 'S5 HTML and JavaScript slide show', + 'tei' => 'TEI Simple', + 'xwiki' => 'XWiki markup', + 'zimwiki' => 'ZimWiki markup' + ) - assert_equal PandocRuby::BINARY_WRITERS, - 'odt' => 'OpenDocument', - 'docx' => 'Word docx', - 'epub' => 'EPUB V2', - 'epub3' => 'EPUB V3' + assert_equal( + PandocRuby::BINARY_WRITERS, + 'odt' => 'OpenOffice text document', + 'docx' => 'Word docx', + 'epub' => 'EPUB v2', + 'epub2' => 'EPUB v2', + 'epub3' => 'EPUB v3' + ) - assert_equal PandocRuby::WRITERS, - PandocRuby::STRING_WRITERS.merge(PandocRuby::BINARY_WRITERS) + assert_equal( + PandocRuby::WRITERS, + PandocRuby::STRING_WRITERS.merge(PandocRuby::BINARY_WRITERS) + ) end end