Class: NotionToMd
- Inherits:
-
Object
- Object
- NotionToMd
- Includes:
- Callee
- Defined in:
- lib/notion_to_md.rb,
lib/notion_to_md/page.rb,
lib/notion_to_md/text.rb,
lib/notion_to_md/blocks.rb,
lib/notion_to_md/logger.rb,
lib/notion_to_md/version.rb,
lib/notion_to_md/converter.rb,
lib/notion_to_md/blocks/block.rb,
lib/notion_to_md/blocks/types.rb,
lib/notion_to_md/page_property.rb,
lib/notion_to_md/blocks/builder.rb,
lib/notion_to_md/blocks/factory.rb,
lib/notion_to_md/text_annotation.rb,
lib/notion_to_md/blocks/normalizer.rb,
lib/notion_to_md/blocks/table_block.rb,
lib/notion_to_md/blocks/table_row_block.rb,
lib/notion_to_md/helpers/yaml_sanitizer.rb,
lib/notion_to_md/blocks/to_do_list_block.rb,
lib/notion_to_md/blocks/bulleted_list_block.rb,
lib/notion_to_md/blocks/numbered_list_block.rb,
lib/notion_to_md/blocks/to_do_list_item_block.rb,
lib/notion_to_md/blocks/bulleted_list_item_block.rb,
lib/notion_to_md/blocks/numbered_list_item_block.rb
Overview
The NotionToMd class allows to transform notion pages to markdown documents.
Defined Under Namespace
Modules: Blocks, Helpers Classes: Converter, Logger, Page, PageProperty, Text, TextAnnotation
Constant Summary collapse
- VERSION =
'2.5.0'
Instance Attribute Summary collapse
-
#frontmatter ⇒ Object
readonly
Returns the value of attribute frontmatter.
-
#page_id ⇒ Object
readonly
Returns the value of attribute page_id.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Class Method Summary collapse
-
.convert(page_id:, token: nil, frontmatter: false) ⇒ Object
Parameters page_id:: A string representing the notion page id.
Instance Method Summary collapse
- #call {|md| ... } ⇒ Object
-
#initialize(page_id:, token: nil, frontmatter: false) ⇒ NotionToMd
constructor
A new instance of NotionToMd.
Constructor Details
#initialize(page_id:, token: nil, frontmatter: false) ⇒ NotionToMd
Returns a new instance of NotionToMd.
24 25 26 27 28 |
# File 'lib/notion_to_md.rb', line 24 def initialize(page_id:, token: nil, frontmatter: false) @page_id = page_id @token = token || ENV['NOTION_TOKEN'] @frontmatter = frontmatter end |
Instance Attribute Details
#frontmatter ⇒ Object (readonly)
Returns the value of attribute frontmatter.
22 23 24 |
# File 'lib/notion_to_md.rb', line 22 def frontmatter @frontmatter end |
#page_id ⇒ Object (readonly)
Returns the value of attribute page_id.
22 23 24 |
# File 'lib/notion_to_md.rb', line 22 def page_id @page_id end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
22 23 24 |
# File 'lib/notion_to_md.rb', line 22 def token @token end |
Class Method Details
.convert(page_id:, token: nil, frontmatter: false) ⇒ Object
Parameters
- page_id
-
A string representing the notion page id.
- token
-
The notion API secret token. The token can replaced by the environment variable NOTION_TOKEN.
- frontmatter
-
A boolean indicating whether to include the page properties as frontmatter.
Returns
The string that represent the markdown document.
41 42 43 |
# File 'lib/notion_to_md.rb', line 41 def self.convert(page_id:, token: nil, frontmatter: false) Converter.new(page_id: page_id, token: token).convert(frontmatter: frontmatter) end |
Instance Method Details
#call {|md| ... } ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/notion_to_md.rb', line 45 def call md = self.class.convert(page_id: page_id, token: token, frontmatter: frontmatter) yield md if block_given? md end |