It is recommended to use org-ruby: Ruby parses and generates Org format
It is recommended to use org-ruby: Ruby parses and generates Org format
It is recommended to use org- ruby : Ruby parses and generates Org format
org-ruby is a library for parsing and generating Org-mode documents in Ruby .
Project Description
org-ruby
It is a Ruby library that can convert Org mode documents into HTML, PDF or other formats, and can also convert data structures into Org mode strings.- It supports most functions of Org mode, including headers, lists, tables, attributes, etc.
scenes to be used
org-ruby
This is a very useful tool if you need to process Org-mode documents in a Ruby program .- Org mode task lists can be converted to HTML or PDF for easy sharing or printing.
- Org mode schedules can be converted to Google Calendar or other calendar applications.
- Data structures can be converted into textual representations of Org schema for easy editing and sharing.
Features
- Supports most functions of Org mode, including titles, lists, tables, attributes, etc.
- Provides a simple API to easily convert data structures into Org mode strings.
- Org mode documents can be converted to HTML or PDF.
- Very lightweight and easy to integrate into existing Ruby applications.
Sample code
Here is a simple example showing how to org-ruby
convert a document in Org mode to HTML using:
require 'org/ruby'
org_text = <<~END_OF_ORG
* Hello, World!
** This is a sub-heading
*** And this is another one.
* Another heading
** With a list:
- item 1
- item 2
- item 3
END_OF_ORG
html =
begin
require 'nokogiri'
::Nokogiri::HTML(org_to_html(org_text))
rescue LoadError
warn "Nokogiri not available. Falling back to plain text output."
org_text
end
puts html

This will output the following HTML code:
<h1>Hello, World!</h1>
<h2>This is a sub-heading</h2>
<h3>And this is another one.</h3>
<h1>Another heading</h1>
<h2>With a list:</h2>
<ul>
<li>item 1</li>
<li>item 2</li>
<li>item 3</li>
</ul>
As you can see,