Module: HtmlToMarkdown::NodeContent
- Extended by:
- T::Helpers, T::Sig
- Included in:
- NodeContentCode, NodeContentDefinitionItem, NodeContentDefinitionList, NodeContentGroup, NodeContentHeading, NodeContentImage, NodeContentList, NodeContentListItem, NodeContentMetadataBlock, NodeContentParagraph, NodeContentQuote, NodeContentRawBlock, NodeContentTable
- Defined in:
- lib/html_to_markdown/native.rb
Overview
The semantic content type of a document node.
Uses internally tagged representation (‘“node_type”: “heading”`) for JSON serialization.
Class Method Summary collapse
Class Method Details
.from_hash(hash) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/html_to_markdown/native.rb', line 48 def self.from_hash(hash) discriminator = hash[:node_type] || hash["node_type"] case discriminator when "heading" then NodeContentHeading.from_hash(hash) when "paragraph" then NodeContentParagraph.from_hash(hash) when "list" then NodeContentList.from_hash(hash) when "list_item" then NodeContentListItem.from_hash(hash) when "table" then NodeContentTable.from_hash(hash) when "image" then NodeContentImage.from_hash(hash) when "code" then NodeContentCode.from_hash(hash) when "quote" then NodeContentQuote.from_hash(hash) when "definition_list" then NodeContentDefinitionList.from_hash(hash) when "definition_item" then NodeContentDefinitionItem.from_hash(hash) when "raw_block" then NodeContentRawBlock.from_hash(hash) when "metadata_block" then NodeContentMetadataBlock.from_hash(hash) when "group" then NodeContentGroup.from_hash(hash) else raise "Unknown discriminator: #{discriminator}" end end |