notion_to_md
Notion Markdown Exporter in Ruby.
Installation
Use gem to install.
$ gem install 'notion_to_md'
Or add it to the Gemfile.
# Gemfile
gem 'notion_to_md'
Usage
Before using the gem create an integration and generate a secret token. Check notion getting started guide to learn more.
Pass the page id and secret token to the constructor and execute the convert method.
require 'notion_to_md'
notion_converter = NotionToMd::Converter.new(page_id: 'b91d5...', token: 'secret_...')
md = notion_converter.convert
If the secret token is provided as an environment variable —NOTION_TOKEN—, there's no need to pass it as an argument to the constructor.
$ export NOTION_TOKEN=<secret_...>
require 'notion_to_md'
notion_converter = NotionToMd::Converter.new(page_id: 'b91d5...')
md = notion_converter.convert
And that's all. The md is a string variable containing the notion page formatted in markdown.
Test
$ ruby -Ilib:test test/notion_to_md/converter_spec.rb