Module: Coradoc::AsciiDoc::Builder::ElementBuilder
- Included in:
- Coradoc::AsciiDoc::Builder
- Defined in:
- lib/coradoc/asciidoc/builder/element_builder.rb
Instance Method Summary collapse
- #build_attribute(ast) ⇒ Object
- #build_bibliography_entry(ast) ⇒ Object
- #build_comment_block(ast) ⇒ Object
- #build_comment_line(ast) ⇒ Object
- #build_generic_element(ast) ⇒ Object
- #build_header(ast) ⇒ Object
- #build_include(ast) ⇒ Object
- #build_line_break(ast) ⇒ Object
- #build_section(ast) ⇒ Object
- #build_section_contents(contents_ast) ⇒ Object
- #build_subsections(sections_ast) ⇒ Object
- #build_table(ast) ⇒ Object
- #build_tag(ast) ⇒ Object
- #build_unparsed(ast) ⇒ Object
Instance Method Details
#build_attribute(ast) ⇒ Object
115 116 117 118 119 120 |
# File 'lib/coradoc/asciidoc/builder/element_builder.rb', line 115 def build_attribute(ast) Coradoc::CoreModel::ElementAttribute.new( name: ast[:key], value: ast[:value] ) end |
#build_bibliography_entry(ast) ⇒ Object
98 99 100 101 102 103 104 105 106 |
# File 'lib/coradoc/asciidoc/builder/element_builder.rb', line 98 def build_bibliography_entry(ast) bib_ast = ast[:bibliography_entry] || ast['bibliography_entry'] || ast Coradoc::CoreModel::BibliographyEntry.new( anchor_name: bib_ast[:anchor_name] || bib_ast['anchor_name'], document_id: bib_ast[:document_id] || bib_ast['document_id'], ref_text: bib_ast[:ref_text] || bib_ast['ref_text'] ) end |
#build_comment_block(ast) ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/coradoc/asciidoc/builder/element_builder.rb', line 55 def build_comment_block(ast) comment_ast = ast[:comment_block] || ast['comment_block'] || ast Coradoc::CoreModel::CommentBlock.new( content: comment_ast[:comment_text] || comment_ast['comment_text'] ) end |
#build_comment_line(ast) ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/coradoc/asciidoc/builder/element_builder.rb', line 47 def build_comment_line(ast) comment_ast = ast[:comment_line] || ast['comment_line'] || ast Coradoc::CoreModel::CommentBlock.new( content: comment_ast[:comment_text] || comment_ast['comment_text'] ) end |
#build_generic_element(ast) ⇒ Object
108 109 110 111 112 113 |
# File 'lib/coradoc/asciidoc/builder/element_builder.rb', line 108 def build_generic_element(ast) Coradoc::CoreModel::Block.new( block_semantic_type: 'unknown', content: ast.to_s ) end |
#build_header(ast) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/coradoc/asciidoc/builder/element_builder.rb', line 7 def build_header(ast) header_ast = ast[:header] || ast Coradoc::CoreModel::HeaderElement.new( title: extract_text_content(header_ast[:title]), id: header_ast[:id] ) end |
#build_include(ast) ⇒ Object
63 64 65 66 67 68 69 70 |
# File 'lib/coradoc/asciidoc/builder/element_builder.rb', line 63 def build_include(ast) include_ast = ast[:include] || ast['include'] || ast Coradoc::CoreModel::Block.new( block_semantic_type: 'include', content: include_ast[:path] || include_ast['path'] ) end |
#build_line_break(ast) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/coradoc/asciidoc/builder/element_builder.rb', line 40 def build_line_break(ast) Coradoc::CoreModel::Block.new( block_semantic_type: 'line_break', content: ast[:line_break] || ast['line_break'] ) end |
#build_section(ast) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/coradoc/asciidoc/builder/element_builder.rb', line 16 def build_section(ast) section_ast = ast[:section] || ast Coradoc::CoreModel::SectionElement.new( title: extract_text_content(section_ast[:title]), id: section_ast[:id], level: extract_level(section_ast), children: build_section_contents(section_ast[:contents]) + build_subsections(section_ast[:sections]) ) end |
#build_section_contents(contents_ast) ⇒ Object
28 29 30 31 32 |
# File 'lib/coradoc/asciidoc/builder/element_builder.rb', line 28 def build_section_contents(contents_ast) return [] unless contents_ast Array(contents_ast).map { |content| build_element(content) }.compact end |
#build_subsections(sections_ast) ⇒ Object
34 35 36 37 38 |
# File 'lib/coradoc/asciidoc/builder/element_builder.rb', line 34 def build_subsections(sections_ast) return [] unless sections_ast Array(sections_ast).map { |section| build_element(section) }.compact end |
#build_table(ast) ⇒ Object
72 73 74 75 76 77 78 79 80 |
# File 'lib/coradoc/asciidoc/builder/element_builder.rb', line 72 def build_table(ast) table_ast = ast[:table] || ast['table'] || ast Coradoc::CoreModel::Table.new( title: table_ast[:title] || table_ast['title'], id: table_ast[:id] || table_ast['id'], rows: table_ast[:rows] || table_ast['rows'] || [] ) end |
#build_tag(ast) ⇒ Object
89 90 91 92 93 94 95 96 |
# File 'lib/coradoc/asciidoc/builder/element_builder.rb', line 89 def build_tag(ast) tag_ast = ast[:tag] || ast['tag'] || ast Coradoc::CoreModel::Block.new( block_semantic_type: 'tag', content: tag_ast[:name] || tag_ast['name'] ) end |
#build_unparsed(ast) ⇒ Object
82 83 84 85 86 87 |
# File 'lib/coradoc/asciidoc/builder/element_builder.rb', line 82 def build_unparsed(ast) Coradoc::CoreModel::Block.new( block_semantic_type: 'unparsed', content: (ast[:unparsed] || ast['unparsed']).to_s ) end |