{"id":13463235,"url":"https://github.com/xwmx/pandoc-ruby","last_synced_at":"2025-05-15T17:08:43.159Z","repository":{"id":691037,"uuid":"335231","full_name":"xwmx/pandoc-ruby","owner":"xwmx","description":"Ruby wrapper for Pandoc","archived":false,"fork":false,"pushed_at":"2023-11-25T00:18:22.000Z","size":259,"stargazers_count":344,"open_issues_count":5,"forks_count":43,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-31T21:49:20.153Z","etag":null,"topics":["markdown","markup","markup-language","pandoc","restructuredtext","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xwmx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null},"funding":{"github":["xwmx"],"custom":"https://paypal.me/WilliamMelody"}},"created_at":"2009-10-12T19:51:17.000Z","updated_at":"2025-03-27T00:12:15.000Z","dependencies_parsed_at":"2024-01-13T17:50:25.223Z","dependency_job_id":"b1384083-719c-4474-a16f-caa0ed206991","html_url":"https://github.com/xwmx/pandoc-ruby","commit_stats":{"total_commits":299,"total_committers":11,"mean_commits":"27.181818181818183","dds":0.2775919732441472,"last_synced_commit":"7855de63a2d3fa4c2c7e863754a3a3ca60d49bce"},"previous_names":["alphabetum/pandoc-ruby"],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xwmx%2Fpandoc-ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xwmx%2Fpandoc-ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xwmx%2Fpandoc-ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xwmx%2Fpandoc-ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xwmx","download_url":"https://codeload.github.com/xwmx/pandoc-ruby/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247737788,"owners_count":20987721,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["markdown","markup","markup-language","pandoc","restructuredtext","ruby"],"created_at":"2024-07-31T13:00:48.691Z","updated_at":"2025-04-07T22:10:22.176Z","avatar_url":"https://github.com/xwmx.png","language":"Ruby","funding_links":["https://github.com/sponsors/xwmx","https://paypal.me/WilliamMelody"],"categories":["HTML \u0026 Markup","Programming Language Libraries","Ruby"],"sub_categories":["Markup processors","Ruby"],"readme":"# PandocRuby\n\n[![Build Status](https://img.shields.io/github/actions/workflow/status/xwmx/pandoc-ruby/tests.yml?branch=master)](https://github.com/xwmx/pandoc-ruby/actions)\n[![Gem Version](https://img.shields.io/gem/v/pandoc-ruby)](http://rubygems.org/gems/pandoc-ruby)\n[![Gem Downloads](https://img.shields.io/gem/dt/pandoc-ruby)](http://rubygems.org/gems/pandoc-ruby)\n\nPandocRuby is a wrapper for [Pandoc](http://johnmacfarlane.net/pandoc/), a\nHaskell library with command line tools for converting one markup format to\nanother.\n\nPandoc can convert documents from a variety of formats including markdown,\nreStructuredText, textile, HTML, DocBook, LaTeX, and MediaWiki markup to a\nvariety of other formats, including markdown, reStructuredText, HTML, LaTeX,\nConTeXt, PDF, RTF, DocBook XML, OpenDocument XML, ODT, GNU Texinfo, MediaWiki\nmarkup, groff man pages, HTML slide shows, EPUB, Microsoft Word docx, and more.\n\n## Installation\n\nFirst, [install Pandoc](http://johnmacfarlane.net/pandoc/installing.html).\n\nPandocRuby is available on [RubyGems](http://rubygems.org/gems/pandoc-ruby):\n\n```bash\ngem install pandoc-ruby\n```\n\nTo install with [Bundler](https://bundler.io/), add the following to your\nGemfile:\n\n```ruby\ngem 'pandoc-ruby'\n```\n\nThen run `bundle install`\n\n## Usage\n\n```ruby\nrequire 'pandoc-ruby'\n@converter = PandocRuby.new('# Markdown Title', from: :markdown, to: :rst)\nputs @converter.convert\n```\n\nThis takes the Markdown formatted string and converts it to reStructuredText.\n\nYou can also use the `#convert` class method:\n\n```ruby\nputs PandocRuby.convert('# Markdown Title', from: :markdown, to: :html)\n```\n\nOther arguments are simply converted into command line options, accepting\nsymbols and strings for options and hashes for options with arguments.\n\n```ruby\nPandocRuby.convert('# Markdown Title', :s, {f: :markdown, to: :rst}, '--wrap=none', :table_of_contents)\n```\n\nis equivalent to\n\n```bash\necho \"# Markdown Title\" | pandoc -s -f markdown --to=rst --wrap=none --table-of-contents\n```\n\nAlso provided are `#to_[writer]` instance methods for each of the writers,\nand these can also accept options:\n\n```ruby\nPandocRuby.new('# Example').to_html(:ascii)\n# =\u003e \"\u003ch1 id=\"example\"\u003eExample\u003c/h1\u003e\"\n# or\nPandocRuby.new(\"# Example\").to_rst\n# =\u003e \"Example\n#     =======\"\n```\n\nSimilarly, there are class methods for each of the readers, so readers\nand writers can be specified like this:\n\n```ruby\nPandocRuby.html(\"\u003ch1\u003ehello\u003c/h1\u003e\").to_latex\n# =\u003e \"\\\\section{hello}\"\n```\n\nAvailable readers and writers are can be found in the following\nvariables:\n- [`PandocRuby::READERS`](lib/pandoc-ruby.rb#L10)\n- [`PandocRuby::STRING_WRITERS`](lib/pandoc-ruby.rb#L48)\n- [`PandocRuby::BINARY_WRITERS`](lib/pandoc-ruby.rb#L104)\n- [`PandocRuby::WRITERS`](lib/pandoc-ruby.rb#L113)\n\nPandocRuby assumes the `pandoc` executable is in your environment's `$PATH`\nvariable.  If you'd like to set an explicit path to the `pandoc` executable,\nyou can do so with  `PandocRuby.pandoc_path = '/path/to/pandoc'`\n\n### Converting Files\n\nPandocRuby can also take an array of one or more file paths as the first\nargument. The files will be concatenated together with a blank line between\neach and used as input.\n\n```ruby\n# One file path as a single-element array.\nPandocRuby.new(['/path/to/file1.docx'], from: 'docx').to_html\n# Multiple file paths as an array.\nPandocRuby.new(['/path/to/file1.docx', '/path/to/file1.docx'], from: 'docx').to_html\n```\n\nIf you are trying to generate a standalone file with full file headers rather\nthan just a marked up fragment, remember to pass the `:standalone` option so\nthe correct header and footer are added.\n\n```ruby\nPandocRuby.new(\"# Some title\", :standalone).to_rtf\n```\n\n### Extensions\n\nPandoc [extensions](https://pandoc.org/MANUAL.html#extensions) can be\nused to modify the behavior of readers and writers. To use an extension,\nadd the extension with a `+` or `-` after the reader or writer name:\n\n```ruby\n# Without extension:\nPandocRuby.new(\"Line 1\\n# Heading\", from: 'markdown_strict').to_html\n# =\u003e \"\u003cp\u003eLine 1\u003c/p\u003e\\n\u003ch1\u003eHeading\u003c/h1\u003e\\n\"\n\n# With `+blank_before_header` extension:\nPandocRuby.new(\"Line 1\\n# Heading\", from: 'markdown_strict+blank_before_header').to_html\n# =\u003e \"\u003cp\u003eLine 1 # Heading\u003c/p\u003e\\n\n```\n\n### More Information\n\nFor more information on Pandoc, see the\n[Pandoc documentation](http://johnmacfarlane.net/pandoc/)\nor run `man pandoc`\n([also available here](http://johnmacfarlane.net/pandoc/pandoc.1.html)).\n\nIf you'd prefer a pure-Ruby extended markdown interpreter that can output a\nfew different formats, take a look at\n[kramdown](https://kramdown.gettalong.org/). If you want to use the full\nreStructuredText syntax from within Ruby, check out\n[RbST](https://github.com/xwmx/rbst), a docutils wrapper.\n\nThis gem was inspired by [Albino](http://github.com/github/albino). For a\nslightly different approach to using Pandoc with Ruby, see\n[Pandoku](http://github.com/dahlia/pandoku).\n\n## Note on Patches/Pull Requests\n\n* Fork the project.\n* Make your feature addition or bug fix.\n* Add tests for it. This is important so I don't break it in a\n  future version unintentionally.\n* Commit, do not mess with rakefile, version, or history.\n  (if you want to have your own version, that is fine but\n  bump version in a commit by itself I can ignore when I pull)\n* Send me a pull request. Bonus points for topic branches.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxwmx%2Fpandoc-ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxwmx%2Fpandoc-ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxwmx%2Fpandoc-ruby/lists"}