nora_mark 0.2beta7 → 0.2beta8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/.travis.yml +1 -1
 - data/README.md +149 -73
 - data/Rakefile +1 -3
 - data/bin/nora2html +1 -1
 - data/emacs-mode/noramark-mode.el +497 -0
 - data/example/koujin.nora +13 -0
 - data/example/nora-simple.css +27 -2
 - data/example/noramark-reference-ja.nora +446 -64
 - data/example/noramark-reference-ja_00001.xhtml +485 -85
 - data/lib/nora_mark.rb +5 -67
 - data/lib/nora_mark/document.rb +89 -0
 - data/lib/nora_mark/extensions.rb +26 -0
 - data/lib/nora_mark/html/context.rb +2 -3
 - data/lib/nora_mark/html/default_transformer.rb +151 -0
 - data/lib/nora_mark/html/generator.rb +25 -149
 - data/lib/nora_mark/html/paragraph_writer.rb +4 -4
 - data/lib/nora_mark/html/tag_writer.rb +13 -10
 - data/lib/nora_mark/node.rb +196 -72
 - data/lib/nora_mark/node_set.rb +13 -0
 - data/lib/nora_mark/node_util.rb +29 -16
 - data/lib/nora_mark/parser.kpeg +210 -74
 - data/lib/nora_mark/parser.kpeg.rb +1353 -401
 - data/lib/nora_mark/parser.rb +1 -1
 - data/lib/nora_mark/transformer.rb +35 -10
 - data/lib/nora_mark/version.rb +1 -1
 - data/nora_mark.gemspec +3 -2
 - data/spec/node_spec.rb +280 -0
 - data/spec/nora_mark_spec.rb +1189 -1025
 - data/spec/spec_helper.rb +2 -0
 - data/spec/transformer_spec.rb +37 -0
 - metadata +27 -6
 - data/lib/nora_mark/html/writer_selector.rb +0 -24
 - data/lib/nora_mark/node_builder.rb +0 -18
 
    
        data/lib/nora_mark/parser.rb
    CHANGED
    
    
| 
         @@ -1,18 +1,35 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module NoraMark
         
     | 
| 
       2 
2 
     | 
    
         
             
              class Transformer
         
     | 
| 
      
 3 
     | 
    
         
            +
                include NodeUtil
         
     | 
| 
      
 4 
     | 
    
         
            +
                attr_accessor :options
         
     | 
| 
       3 
5 
     | 
    
         
             
                def initialize(rules, options)
         
     | 
| 
       4 
6 
     | 
    
         
             
                  @rules = rules
         
     | 
| 
       5 
7 
     | 
    
         
             
                  @options = options
         
     | 
| 
       6 
8 
     | 
    
         
             
                end
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
       7 
10 
     | 
    
         
             
                def transform(node)
         
     | 
| 
       8 
     | 
    
         
            -
                  node. 
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
      
 11 
     | 
    
         
            +
                  frontmatter_node = node.find_node :type => :Frontmatter
         
     | 
| 
      
 12 
     | 
    
         
            +
                  @frontmatter = frontmatter_node.yaml if frontmatter_node
         
     | 
| 
      
 13 
     | 
    
         
            +
                  node.all_nodes.unshift(node).each do 
         
     | 
| 
      
 14 
     | 
    
         
            +
                    |n|
         
     | 
| 
      
 15 
     | 
    
         
            +
                    if match_rule = @rules.find { |rule| n.match?(rule[0]) }
         
     | 
| 
      
 16 
     | 
    
         
            +
                      action, p = match_rule[1,2]
         
     | 
| 
      
 17 
     | 
    
         
            +
                      @node = n
         
     | 
| 
      
 18 
     | 
    
         
            +
                      send(action, &p)
         
     | 
| 
       13 
19 
     | 
    
         
             
                    end 
         
     | 
| 
       14 
     | 
    
         
            -
                  end 
     | 
| 
      
 20 
     | 
    
         
            +
                  end
         
     | 
| 
      
 21 
     | 
    
         
            +
                  node
         
     | 
| 
      
 22 
     | 
    
         
            +
                end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                def modify(&block)
         
     | 
| 
      
 25 
     | 
    
         
            +
                  instance_eval(&block)
         
     | 
| 
       15 
26 
     | 
    
         
             
                end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                def replace(&block)
         
     | 
| 
      
 29 
     | 
    
         
            +
                  new_node = instance_eval(&block)
         
     | 
| 
      
 30 
     | 
    
         
            +
                  @node.replace new_node if new_node
         
     | 
| 
      
 31 
     | 
    
         
            +
                end
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
       16 
33 
     | 
    
         
             
              end
         
     | 
| 
       17 
34 
     | 
    
         | 
| 
       18 
35 
     | 
    
         
             
              class TransformerFactory
         
     | 
| 
         @@ -26,7 +43,7 @@ module NoraMark 
     | 
|
| 
       26 
43 
     | 
    
         
             
                    if text
         
     | 
| 
       27 
44 
     | 
    
         
             
                      instance_eval text
         
     | 
| 
       28 
45 
     | 
    
         
             
                    else
         
     | 
| 
       29 
     | 
    
         
            -
                      instance_eval 
     | 
| 
      
 46 
     | 
    
         
            +
                      instance_eval(&block)
         
     | 
| 
       30 
47 
     | 
    
         
             
                    end
         
     | 
| 
       31 
48 
     | 
    
         
             
                    Transformer.new(@rules, @options)
         
     | 
| 
       32 
49 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -36,8 +53,16 @@ module NoraMark 
     | 
|
| 
       36 
53 
     | 
    
         
             
                  (@options ||= {}).merge options 
         
     | 
| 
       37 
54 
     | 
    
         
             
                end
         
     | 
| 
       38 
55 
     | 
    
         | 
| 
       39 
     | 
    
         
            -
                def  
     | 
| 
       40 
     | 
    
         
            -
                  @rules << [ selector,  
     | 
| 
       41 
     | 
    
         
            -
                end 
     | 
| 
      
 56 
     | 
    
         
            +
                def modify(selector, &block)
         
     | 
| 
      
 57 
     | 
    
         
            +
                  @rules << [ selector, :modify, block ]
         
     | 
| 
      
 58 
     | 
    
         
            +
                end
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
                def replace(selector, &block)
         
     | 
| 
      
 61 
     | 
    
         
            +
                  @rules << [ selector, :replace, block ]
         
     | 
| 
      
 62 
     | 
    
         
            +
                end
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
                def rename(selector, name)
         
     | 
| 
      
 65 
     | 
    
         
            +
                  @rules << [ selector, :modify, proc { @node.name = name } ]
         
     | 
| 
      
 66 
     | 
    
         
            +
                end
         
     | 
| 
       42 
67 
     | 
    
         
             
              end
         
     | 
| 
       43 
68 
     | 
    
         
             
            end
         
     | 
    
        data/lib/nora_mark/version.rb
    CHANGED
    
    
    
        data/nora_mark.gemspec
    CHANGED
    
    | 
         @@ -4,8 +4,8 @@ require File.expand_path('../lib/nora_mark/version', __FILE__) 
     | 
|
| 
       4 
4 
     | 
    
         
             
            Gem::Specification.new do |gem|
         
     | 
| 
       5 
5 
     | 
    
         
             
              gem.authors       = ["KOJIMA Satoshi"]
         
     | 
| 
       6 
6 
     | 
    
         
             
              gem.email         = ["skoji@mac.com"]
         
     | 
| 
       7 
     | 
    
         
            -
              gem.description   = %q{ 
     | 
| 
       8 
     | 
    
         
            -
              gem.summary       = %q{ 
     | 
| 
      
 7 
     | 
    
         
            +
              gem.description   = %q{Simple and customizable text markup language for EPUB/XHTML}
         
     | 
| 
      
 8 
     | 
    
         
            +
              gem.summary       = %q{Simple and customizable text markup language for EPUB/XHTML}
         
     | 
| 
       9 
9 
     | 
    
         
             
              gem.homepage      = ""
         
     | 
| 
       10 
10 
     | 
    
         | 
| 
       11 
11 
     | 
    
         
             
              gem.files         = `git ls-files`.split($\)
         
     | 
| 
         @@ -19,5 +19,6 @@ Gem::Specification.new do |gem| 
     | 
|
| 
       19 
19 
     | 
    
         
             
              gem.add_dependency "kpeg"
         
     | 
| 
       20 
20 
     | 
    
         
             
              gem.add_development_dependency "rspec", "~> 2.14"
         
     | 
| 
       21 
21 
     | 
    
         
             
              gem.add_development_dependency "rake"
         
     | 
| 
      
 22 
     | 
    
         
            +
              gem.add_development_dependency "byebug"
         
     | 
| 
       22 
23 
     | 
    
         
             
              gem.add_development_dependency "nokogiri", "~> 1.6.0"
         
     | 
| 
       23 
24 
     | 
    
         
             
            end
         
     | 
    
        data/spec/node_spec.rb
    ADDED
    
    | 
         @@ -0,0 +1,280 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require File.dirname(__FILE__) + '/spec_helper.rb'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require File.dirname(__FILE__) + '/../lib/nora_mark'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'nokogiri'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require File.dirname(__FILE__) + '/nokogiri_test_helper.rb'
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            describe NoraMark::Node do 
         
     | 
| 
      
 7 
     | 
    
         
            +
              describe 'node manipulation' do
         
     | 
| 
      
 8 
     | 
    
         
            +
                before do
         
     | 
| 
      
 9 
     | 
    
         
            +
                  @text = <<EOF
         
     | 
| 
      
 10 
     | 
    
         
            +
            1st line.
         
     | 
| 
      
 11 
     | 
    
         
            +
            d.the_class {
         
     | 
| 
      
 12 
     | 
    
         
            +
            3rd line.
         
     | 
| 
      
 13 
     | 
    
         
            +
            }
         
     | 
| 
      
 14 
     | 
    
         
            +
            5th line.
         
     | 
| 
      
 15 
     | 
    
         
            +
            EOF
         
     | 
| 
      
 16 
     | 
    
         
            +
                end
         
     | 
| 
      
 17 
     | 
    
         
            +
                it 'should access line number' do
         
     | 
| 
      
 18 
     | 
    
         
            +
                  noramark = NoraMark::Document.parse(@text)
         
     | 
| 
      
 19 
     | 
    
         
            +
                  page = noramark.root.children[0]
         
     | 
| 
      
 20 
     | 
    
         
            +
                  expect(page.children.size).to eq 3
         
     | 
| 
      
 21 
     | 
    
         
            +
                  expect(page.line_no).to eq 1
         
     | 
| 
      
 22 
     | 
    
         
            +
                  expect(page.children[0].line_no).to eq 1
         
     | 
| 
      
 23 
     | 
    
         
            +
                  expect(page.children[1].line_no).to eq 2
         
     | 
| 
      
 24 
     | 
    
         
            +
                  expect(page.children[2].children[0].line_no).to eq 5
         
     | 
| 
      
 25 
     | 
    
         
            +
                end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                it 'replace existing node'  do
         
     | 
| 
      
 28 
     | 
    
         
            +
                  noramark = NoraMark::Document.parse(@text)
         
     | 
| 
      
 29 
     | 
    
         
            +
                  page = noramark.root.children[0]
         
     | 
| 
      
 30 
     | 
    
         
            +
                  first_pgroup = page.children[0]
         
     | 
| 
      
 31 
     | 
    
         
            +
                  line_no = first_pgroup.line_no
         
     | 
| 
      
 32 
     | 
    
         
            +
                  new_node = NoraMark::ParagraphGroup.new(['the_id'], ['the_class'], [], {}, [ NoraMark::Text.new("replaced.", line_no)],  line_no)
         
     | 
| 
      
 33 
     | 
    
         
            +
                  first_pgroup.replace(new_node)
         
     | 
| 
      
 34 
     | 
    
         
            +
                  body = Nokogiri::XML::Document.parse(noramark.html[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 35 
     | 
    
         
            +
                  expect(body.element_children[0].selector_and_children(remove_id: false))
         
     | 
| 
      
 36 
     | 
    
         
            +
                    .to eq(
         
     | 
| 
      
 37 
     | 
    
         
            +
                           ['p#the_id.the_class', 'replaced.'])
         
     | 
| 
      
 38 
     | 
    
         
            +
                end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
                it 'replace existing node by multiple nodes' do
         
     | 
| 
      
 41 
     | 
    
         
            +
                  noramark = NoraMark::Document.parse(@text)
         
     | 
| 
      
 42 
     | 
    
         
            +
                  page = noramark.root.children[0]
         
     | 
| 
      
 43 
     | 
    
         
            +
                  first_pgroup = page.children[0]
         
     | 
| 
      
 44 
     | 
    
         
            +
                  line_no = first_pgroup.line_no
         
     | 
| 
      
 45 
     | 
    
         
            +
                  new_node1 = NoraMark::ParagraphGroup.new(['the_id'], ['the_class'], [], {}, [ NoraMark::Text.new("replaced.", line_no)],  line_no)
         
     | 
| 
      
 46 
     | 
    
         
            +
                  new_node2 = NoraMark::ParagraphGroup.new(['the_id2'], ['the_class2'], [], {}, [ NoraMark::Text.new("replaced2.", line_no)],  line_no)
         
     | 
| 
      
 47 
     | 
    
         
            +
                  first_pgroup.replace([new_node1, new_node2])
         
     | 
| 
      
 48 
     | 
    
         
            +
                  body = Nokogiri::XML::Document.parse(noramark.html[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 49 
     | 
    
         
            +
                  expect(body.element_children[0].selector_and_children(remove_id: false))
         
     | 
| 
      
 50 
     | 
    
         
            +
                    .to eq(
         
     | 
| 
      
 51 
     | 
    
         
            +
                           ['p#the_id.the_class', 'replaced.'])
         
     | 
| 
      
 52 
     | 
    
         
            +
                  expect(body.element_children[1].selector_and_children(remove_id: false))
         
     | 
| 
      
 53 
     | 
    
         
            +
                    .to eq(
         
     | 
| 
      
 54 
     | 
    
         
            +
                           ['p#the_id2.the_class2', 'replaced2.'])
         
     | 
| 
      
 55 
     | 
    
         
            +
                  expect(body.element_children[2].selector_and_children(remove_id: false))
         
     | 
| 
      
 56 
     | 
    
         
            +
                    .to eq(
         
     | 
| 
      
 57 
     | 
    
         
            +
                           ['div.the_class', ['p', '3rd line.']])
         
     | 
| 
      
 58 
     | 
    
         
            +
                end
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
                it 'wraps existing node'  do
         
     | 
| 
      
 61 
     | 
    
         
            +
                  noramark = NoraMark::Document.parse(@text)
         
     | 
| 
      
 62 
     | 
    
         
            +
                  page = noramark.root.children[0]
         
     | 
| 
      
 63 
     | 
    
         
            +
                  first_pgroup = page.children[0]
         
     | 
| 
      
 64 
     | 
    
         
            +
                  line_no = first_pgroup.line_no
         
     | 
| 
      
 65 
     | 
    
         
            +
                  new_node = NoraMark::Block.new('div', ['the_id'], ['the_class'], [], {}, [
         
     | 
| 
      
 66 
     | 
    
         
            +
                                                                                            NoraMark::Block.new('p', [], [], [], {}, [
         
     | 
| 
      
 67 
     | 
    
         
            +
                                                                                            NoraMark::Text.new("replaced.", line_no)], line_no)
         
     | 
| 
      
 68 
     | 
    
         
            +
                                                                                           ],  line_no)
         
     | 
| 
      
 69 
     | 
    
         
            +
                  first_pgroup.wrap(new_node)
         
     | 
| 
      
 70 
     | 
    
         
            +
                  body = Nokogiri::XML::Document.parse(noramark.html[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 71 
     | 
    
         
            +
                  expect(body.element_children[0].selector_and_children(remove_id: false))
         
     | 
| 
      
 72 
     | 
    
         
            +
                    .to eq(['div#the_id.the_class', ['p', '1st line.'], ['p', 'replaced.']])
         
     | 
| 
      
 73 
     | 
    
         
            +
                end
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
                it 'append to  existing node'  do
         
     | 
| 
      
 76 
     | 
    
         
            +
                  noramark = NoraMark::Document.parse(@text)
         
     | 
| 
      
 77 
     | 
    
         
            +
                  page = noramark.root.children[0]
         
     | 
| 
      
 78 
     | 
    
         
            +
                  first_pgroup = page.children[0]
         
     | 
| 
      
 79 
     | 
    
         
            +
                  line_no = first_pgroup.line_no
         
     | 
| 
      
 80 
     | 
    
         
            +
                  new_node = NoraMark::ParagraphGroup.new(['the_id'], ['the_class'], [], {}, [ NoraMark::Text.new("added.", line_no)],  line_no)
         
     | 
| 
      
 81 
     | 
    
         
            +
                  first_pgroup.after(new_node)
         
     | 
| 
      
 82 
     | 
    
         
            +
                  body = Nokogiri::XML::Document.parse(noramark.html[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 83 
     | 
    
         
            +
                  expect(body.element_children[0].selector_and_children(remove_id: false))
         
     | 
| 
      
 84 
     | 
    
         
            +
                    .to eq(
         
     | 
| 
      
 85 
     | 
    
         
            +
                           ['p', '1st line.'])
         
     | 
| 
      
 86 
     | 
    
         
            +
                  expect(body.element_children[1].selector_and_children(remove_id: false))
         
     | 
| 
      
 87 
     | 
    
         
            +
                    .to eq(
         
     | 
| 
      
 88 
     | 
    
         
            +
                           ['p#the_id.the_class', 'added.'])
         
     | 
| 
      
 89 
     | 
    
         
            +
                  expect(body.element_children[2].selector_and_children(remove_id: false))
         
     | 
| 
      
 90 
     | 
    
         
            +
                    .to eq(
         
     | 
| 
      
 91 
     | 
    
         
            +
                           ['div.the_class', ['p', '3rd line.']])
         
     | 
| 
      
 92 
     | 
    
         
            +
                end
         
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
      
 94 
     | 
    
         
            +
                it 'append to the last existing node'  do
         
     | 
| 
      
 95 
     | 
    
         
            +
                  noramark = NoraMark::Document.parse(@text)
         
     | 
| 
      
 96 
     | 
    
         
            +
                  page = noramark.root.children[0]
         
     | 
| 
      
 97 
     | 
    
         
            +
                  last_pgroup = page.children[2]
         
     | 
| 
      
 98 
     | 
    
         
            +
                  line_no = last_pgroup.line_no
         
     | 
| 
      
 99 
     | 
    
         
            +
                  new_node = NoraMark::ParagraphGroup.new(['the_id'], ['the_class'], [], {}, [ NoraMark::Text.new("added.", line_no)],  line_no)
         
     | 
| 
      
 100 
     | 
    
         
            +
                  last_pgroup.after(new_node)
         
     | 
| 
      
 101 
     | 
    
         
            +
                  body = Nokogiri::XML::Document.parse(noramark.html[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 102 
     | 
    
         
            +
                  expect(body.element_children[1].selector_and_children(remove_id: false))
         
     | 
| 
      
 103 
     | 
    
         
            +
                    .to eq(
         
     | 
| 
      
 104 
     | 
    
         
            +
                           ['div.the_class', ['p', '3rd line.']])
         
     | 
| 
      
 105 
     | 
    
         
            +
                  expect(body.element_children[2].selector_and_children(remove_id: false))
         
     | 
| 
      
 106 
     | 
    
         
            +
                    .to eq(
         
     | 
| 
      
 107 
     | 
    
         
            +
                           ['p', '5th line.'])
         
     | 
| 
      
 108 
     | 
    
         
            +
                  expect(body.element_children[3].selector_and_children(remove_id: false))
         
     | 
| 
      
 109 
     | 
    
         
            +
                    .to eq(
         
     | 
| 
      
 110 
     | 
    
         
            +
                           ['p#the_id.the_class', 'added.'])
         
     | 
| 
      
 111 
     | 
    
         
            +
                end
         
     | 
| 
      
 112 
     | 
    
         
            +
                
         
     | 
| 
      
 113 
     | 
    
         
            +
                it 'prepend to existing node'  do
         
     | 
| 
      
 114 
     | 
    
         
            +
                  noramark = NoraMark::Document.parse(@text)
         
     | 
| 
      
 115 
     | 
    
         
            +
                  page = noramark.root.children[0]
         
     | 
| 
      
 116 
     | 
    
         
            +
                  first_pgroup = page.children[0]
         
     | 
| 
      
 117 
     | 
    
         
            +
                  line_no = first_pgroup.line_no
         
     | 
| 
      
 118 
     | 
    
         
            +
                  new_node = NoraMark::ParagraphGroup.new(['the_id'], ['the_class'], [], {}, [ NoraMark::Text.new("added.", line_no)],  line_no)
         
     | 
| 
      
 119 
     | 
    
         
            +
                  first_pgroup.before(new_node)
         
     | 
| 
      
 120 
     | 
    
         
            +
                  body = Nokogiri::XML::Document.parse(noramark.html[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 121 
     | 
    
         
            +
                  expect(body.element_children[0].selector_and_children(remove_id: false))
         
     | 
| 
      
 122 
     | 
    
         
            +
                    .to eq(
         
     | 
| 
      
 123 
     | 
    
         
            +
                           ['p#the_id.the_class', 'added.'])
         
     | 
| 
      
 124 
     | 
    
         
            +
                  expect(body.element_children[1].selector_and_children(remove_id: false))
         
     | 
| 
      
 125 
     | 
    
         
            +
                    .to eq(
         
     | 
| 
      
 126 
     | 
    
         
            +
                           ['p', '1st line.'])
         
     | 
| 
      
 127 
     | 
    
         
            +
                  expect(body.element_children[2].selector_and_children(remove_id: false))
         
     | 
| 
      
 128 
     | 
    
         
            +
                    .to eq(
         
     | 
| 
      
 129 
     | 
    
         
            +
                           ['div.the_class', ['p', '3rd line.']])
         
     | 
| 
      
 130 
     | 
    
         
            +
                end
         
     | 
| 
      
 131 
     | 
    
         
            +
             
     | 
| 
      
 132 
     | 
    
         
            +
                it 'modify existing node by DSL' do
         
     | 
| 
      
 133 
     | 
    
         
            +
                  text = "1st line.\nfoobar(title)[level: 3] {\n in the section.\n}\n# section 2."
         
     | 
| 
      
 134 
     | 
    
         
            +
                  noramark = NoraMark::Document.parse(text, lang: 'ja')
         
     | 
| 
      
 135 
     | 
    
         
            +
             
     | 
| 
      
 136 
     | 
    
         
            +
                  noramark.add_transformer(generator: :html) do
         
     | 
| 
      
 137 
     | 
    
         
            +
                    modify 'foobar' do
         
     | 
| 
      
 138 
     | 
    
         
            +
                      @node.name = 'section'
         
     | 
| 
      
 139 
     | 
    
         
            +
                      @node.prepend_child block("h#{@node.n[:level]}", @node.p[0])
         
     | 
| 
      
 140 
     | 
    
         
            +
                    end
         
     | 
| 
      
 141 
     | 
    
         
            +
                  end
         
     | 
| 
      
 142 
     | 
    
         
            +
                  body = Nokogiri::XML::Document.parse(noramark.html[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 143 
     | 
    
         
            +
                  expect(body.element_children[0].selector_and_children())
         
     | 
| 
      
 144 
     | 
    
         
            +
                    .to eq(
         
     | 
| 
      
 145 
     | 
    
         
            +
                           ['div.pgroup', [ 'p', '1st line.' ]])
         
     | 
| 
      
 146 
     | 
    
         
            +
                  expect(body.element_children[1].selector_and_children())
         
     | 
| 
      
 147 
     | 
    
         
            +
                    .to eq(
         
     | 
| 
      
 148 
     | 
    
         
            +
                           ['section', [ 'h3', 'title' ], ['div.pgroup',  ['p', 'in the section.']]])
         
     | 
| 
      
 149 
     | 
    
         
            +
                  expect(body.element_children[2].selector_and_children())
         
     | 
| 
      
 150 
     | 
    
         
            +
                    .to eq(
         
     | 
| 
      
 151 
     | 
    
         
            +
                           ['section', [ 'h1','section 2.' ]])
         
     | 
| 
      
 152 
     | 
    
         
            +
                end
         
     | 
| 
      
 153 
     | 
    
         
            +
                it 'replace existing node by DSL' do
         
     | 
| 
      
 154 
     | 
    
         
            +
                  text = "1st line.\nfoobar(title)[level: 3] {\n in the section.\n}\n# section 2."
         
     | 
| 
      
 155 
     | 
    
         
            +
                  noramark = NoraMark::Document.parse(text, lang: 'ja')
         
     | 
| 
      
 156 
     | 
    
         
            +
             
     | 
| 
      
 157 
     | 
    
         
            +
                  noramark.add_transformer(generator: :html) do
         
     | 
| 
      
 158 
     | 
    
         
            +
                    replace 'foobar' do
         
     | 
| 
      
 159 
     | 
    
         
            +
                      block('section',
         
     | 
| 
      
 160 
     | 
    
         
            +
                            [
         
     | 
| 
      
 161 
     | 
    
         
            +
                             block( "h#{@node.named_params[:level]}", @node.params[0]),
         
     | 
| 
      
 162 
     | 
    
         
            +
                            ] + @node.children)
         
     | 
| 
      
 163 
     | 
    
         
            +
                    end
         
     | 
| 
      
 164 
     | 
    
         
            +
                  end
         
     | 
| 
      
 165 
     | 
    
         
            +
                  body = Nokogiri::XML::Document.parse(noramark.html[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 166 
     | 
    
         
            +
                  expect(body.element_children[0].selector_and_children())
         
     | 
| 
      
 167 
     | 
    
         
            +
                    .to eq(
         
     | 
| 
      
 168 
     | 
    
         
            +
                           ['div.pgroup', [ 'p', '1st line.' ]])
         
     | 
| 
      
 169 
     | 
    
         
            +
                  expect(body.element_children[1].selector_and_children())
         
     | 
| 
      
 170 
     | 
    
         
            +
                    .to eq(
         
     | 
| 
      
 171 
     | 
    
         
            +
                           ['section', [ 'h3', 'title' ], ['div.pgroup',  ['p', 'in the section.']]])
         
     | 
| 
      
 172 
     | 
    
         
            +
                  expect(body.element_children[2].selector_and_children())
         
     | 
| 
      
 173 
     | 
    
         
            +
                    .to eq(
         
     | 
| 
      
 174 
     | 
    
         
            +
                           ['section', [ 'h1','section 2.' ]])
         
     | 
| 
      
 175 
     | 
    
         
            +
                end
         
     | 
| 
      
 176 
     | 
    
         
            +
                it 'generate complex-style headed section' do
         
     | 
| 
      
 177 
     | 
    
         
            +
                  text = <<EOF
         
     | 
| 
      
 178 
     | 
    
         
            +
            ---
         
     | 
| 
      
 179 
     | 
    
         
            +
            lang: ja
         
     | 
| 
      
 180 
     | 
    
         
            +
            ---
         
     | 
| 
      
 181 
     | 
    
         
            +
             
     | 
| 
      
 182 
     | 
    
         
            +
            # 見出し
         
     | 
| 
      
 183 
     | 
    
         
            +
            sub: 副見出し
         
     | 
| 
      
 184 
     | 
    
         
            +
             
     | 
| 
      
 185 
     | 
    
         
            +
            パラグラフ。
         
     | 
| 
      
 186 
     | 
    
         
            +
            パラグラフ。
         
     | 
| 
      
 187 
     | 
    
         
            +
             
     | 
| 
      
 188 
     | 
    
         
            +
            EOF
         
     | 
| 
      
 189 
     | 
    
         
            +
                  noramark = NoraMark::Document.parse(text)
         
     | 
| 
      
 190 
     | 
    
         
            +
                  noramark.add_transformer(generator: :html) do
         
     | 
| 
      
 191 
     | 
    
         
            +
                    replace({:type => :HeadedSection}) do
         
     | 
| 
      
 192 
     | 
    
         
            +
                      header = block('header',
         
     | 
| 
      
 193 
     | 
    
         
            +
                                     block('div',
         
     | 
| 
      
 194 
     | 
    
         
            +
                                           block("h#{@node.level}", @node.heading),
         
     | 
| 
      
 195 
     | 
    
         
            +
                                           classes: ['hgroup'])) 
         
     | 
| 
      
 196 
     | 
    
         
            +
                      if (fc = @node.first_child).name == 'sub'
         
     | 
| 
      
 197 
     | 
    
         
            +
                        fc.name = 'p'
         
     | 
| 
      
 198 
     | 
    
         
            +
                        fc.classes = ['subh']
         
     | 
| 
      
 199 
     | 
    
         
            +
                        header.first_child.append_child fc 
         
     | 
| 
      
 200 
     | 
    
         
            +
                      end
         
     | 
| 
      
 201 
     | 
    
         
            +
                      body = block('div', @node.children, classes:['section-body'])
         
     | 
| 
      
 202 
     | 
    
         
            +
                      block('section', [ header, body ], template: @node)
         
     | 
| 
      
 203 
     | 
    
         
            +
                    end
         
     | 
| 
      
 204 
     | 
    
         
            +
                  end
         
     | 
| 
      
 205 
     | 
    
         
            +
                  body = Nokogiri::XML::Document.parse(noramark.html[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 206 
     | 
    
         
            +
                  expect(body.element_children[0].selector_and_children())
         
     | 
| 
      
 207 
     | 
    
         
            +
                    .to eq(
         
     | 
| 
      
 208 
     | 
    
         
            +
                           ['section', [ 'header', ['div.hgroup', ['h1', '見出し'], ['p.subh', '副見出し']]],
         
     | 
| 
      
 209 
     | 
    
         
            +
                            ['div.section-body',
         
     | 
| 
      
 210 
     | 
    
         
            +
                             ['div.pgroup', ['p', 'パラグラフ。'], ['p', 'パラグラフ。']]]])
         
     | 
| 
      
 211 
     | 
    
         
            +
                end
         
     | 
| 
      
 212 
     | 
    
         
            +
                it 'converts my markup' do
         
     | 
| 
      
 213 
     | 
    
         
            +
                  text = "speak(Alice): Alice is speaking.\nspeak(Bob): and this is Bob."
         
     | 
| 
      
 214 
     | 
    
         
            +
                  noramark = NoraMark::Document.parse(text)
         
     | 
| 
      
 215 
     | 
    
         
            +
                  noramark.add_transformer(generator: :html) do
         
     | 
| 
      
 216 
     | 
    
         
            +
                    modify "speak" do
         
     | 
| 
      
 217 
     | 
    
         
            +
                      @node.name = 'p'
         
     | 
| 
      
 218 
     | 
    
         
            +
                      @node.prepend_child inline('span', @node.params[0], classes: ['speaker'])
         
     | 
| 
      
 219 
     | 
    
         
            +
                    end
         
     | 
| 
      
 220 
     | 
    
         
            +
                  end
         
     | 
| 
      
 221 
     | 
    
         
            +
                  body = Nokogiri::XML::Document.parse(noramark.html[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 222 
     | 
    
         
            +
                  expect(body.element_children[0].selector_and_children())
         
     | 
| 
      
 223 
     | 
    
         
            +
                    .to eq(
         
     | 
| 
      
 224 
     | 
    
         
            +
                           ['p', ['span.speaker', 'Alice'], 'Alice is speaking.'])
         
     | 
| 
      
 225 
     | 
    
         
            +
                  expect(body.element_children[1].selector_and_children())
         
     | 
| 
      
 226 
     | 
    
         
            +
                    .to eq(
         
     | 
| 
      
 227 
     | 
    
         
            +
                           ['p', ['span.speaker', 'Bob'], 'and this is Bob.'])
         
     | 
| 
      
 228 
     | 
    
         
            +
             
     | 
| 
      
 229 
     | 
    
         
            +
                end
         
     | 
| 
      
 230 
     | 
    
         
            +
                
         
     | 
| 
      
 231 
     | 
    
         
            +
             
     | 
| 
      
 232 
     | 
    
         
            +
                it 'should reparent tree' do
         
     | 
| 
      
 233 
     | 
    
         
            +
                  text = <<EOF
         
     | 
| 
      
 234 
     | 
    
         
            +
            1st line.
         
     | 
| 
      
 235 
     | 
    
         
            +
            d {
         
     | 
| 
      
 236 
     | 
    
         
            +
            in the div
         
     | 
| 
      
 237 
     | 
    
         
            +
            }
         
     | 
| 
      
 238 
     | 
    
         
            +
            *: ul item
         
     | 
| 
      
 239 
     | 
    
         
            +
            text [s{with inline}] within
         
     | 
| 
      
 240 
     | 
    
         
            +
            EOF
         
     | 
| 
      
 241 
     | 
    
         
            +
                  root = NoraMark::Document.parse(text).root
         
     | 
| 
      
 242 
     | 
    
         
            +
             
     | 
| 
      
 243 
     | 
    
         
            +
                  expect(root.parent).to be nil
         
     | 
| 
      
 244 
     | 
    
         
            +
                  expect(root.prev).to be nil
         
     | 
| 
      
 245 
     | 
    
         
            +
                  expect(root.next).to be nil
         
     | 
| 
      
 246 
     | 
    
         
            +
                  expect(root.content).to be nil
         
     | 
| 
      
 247 
     | 
    
         
            +
             
     | 
| 
      
 248 
     | 
    
         
            +
                  expect(root.children.size).to eq 1
         
     | 
| 
      
 249 
     | 
    
         
            +
                  page = root.first_child
         
     | 
| 
      
 250 
     | 
    
         
            +
                  expect(root.children[0]).to eq page
         
     | 
| 
      
 251 
     | 
    
         
            +
                  expect(root.last_child).to eq page
         
     | 
| 
      
 252 
     | 
    
         
            +
                  expect(page.parent).to eq root
         
     | 
| 
      
 253 
     | 
    
         
            +
                  expect(page.prev).to be nil
         
     | 
| 
      
 254 
     | 
    
         
            +
                  expect(page.next).to be nil
         
     | 
| 
      
 255 
     | 
    
         
            +
             
     | 
| 
      
 256 
     | 
    
         
            +
                  first_pgroup = page.first_child
         
     | 
| 
      
 257 
     | 
    
         
            +
                  expect(first_pgroup.class).to be NoraMark::ParagraphGroup
         
     | 
| 
      
 258 
     | 
    
         
            +
                  expect(first_pgroup.parent).to eq page
         
     | 
| 
      
 259 
     | 
    
         
            +
                  expect(first_pgroup.children.size).to eq 1
         
     | 
| 
      
 260 
     | 
    
         
            +
                  expect(first_pgroup.prev).to be nil
         
     | 
| 
      
 261 
     | 
    
         
            +
             
     | 
| 
      
 262 
     | 
    
         
            +
                  paragraph = first_pgroup.first_child
         
     | 
| 
      
 263 
     | 
    
         
            +
                  expect(paragraph.class).to be NoraMark::Paragraph
         
     | 
| 
      
 264 
     | 
    
         
            +
                  expect(paragraph.parent).to be first_pgroup
         
     | 
| 
      
 265 
     | 
    
         
            +
                  expect(paragraph.prev).to be nil
         
     | 
| 
      
 266 
     | 
    
         
            +
                  expect(paragraph.next).to be nil
         
     | 
| 
      
 267 
     | 
    
         
            +
                  expect(paragraph.children.size).to eq 1
         
     | 
| 
      
 268 
     | 
    
         
            +
                  text = paragraph.first_child
         
     | 
| 
      
 269 
     | 
    
         
            +
                  expect(text.class).to be NoraMark::Text
         
     | 
| 
      
 270 
     | 
    
         
            +
                  expect(text.content).to eq '1st line.'
         
     | 
| 
      
 271 
     | 
    
         
            +
                  expect(text.children.size).to eq 0
         
     | 
| 
      
 272 
     | 
    
         
            +
                  expect(text.prev).to be nil
         
     | 
| 
      
 273 
     | 
    
         
            +
                  expect(text.next).to be nil
         
     | 
| 
      
 274 
     | 
    
         
            +
                  expect(text.parent).to eq paragraph
         
     | 
| 
      
 275 
     | 
    
         
            +
             
     | 
| 
      
 276 
     | 
    
         
            +
                  second_div = first_pgroup.next
         
     | 
| 
      
 277 
     | 
    
         
            +
                  expect(second_div.class).to be NoraMark::Block
         
     | 
| 
      
 278 
     | 
    
         
            +
                end
         
     | 
| 
      
 279 
     | 
    
         
            +
              end
         
     | 
| 
      
 280 
     | 
    
         
            +
            end
         
     | 
    
        data/spec/nora_mark_spec.rb
    CHANGED
    
    | 
         @@ -4,825 +4,971 @@ require File.dirname(__FILE__) + '/../lib/nora_mark' 
     | 
|
| 
       4 
4 
     | 
    
         
             
            require 'nokogiri'
         
     | 
| 
       5 
5 
     | 
    
         
             
            require File.dirname(__FILE__) + '/nokogiri_test_helper.rb'
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
     | 
    
         
            -
            describe NoraMark do 
         
     | 
| 
       8 
     | 
    
         
            -
              describe ' 
     | 
| 
       9 
     | 
    
         
            -
                it ' 
     | 
| 
      
 7 
     | 
    
         
            +
            describe NoraMark::Document do 
         
     | 
| 
      
 8 
     | 
    
         
            +
              describe 'parse' do
         
     | 
| 
      
 9 
     | 
    
         
            +
                it 'generate valid xhtml' do
         
     | 
| 
       10 
10 
     | 
    
         
             
                  text = 'some text'
         
     | 
| 
       11 
11 
     | 
    
         
             
                  noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
       12 
12 
     | 
    
         
             
                  xhtml = Nokogiri::XML::Document.parse(noramark.html[0])
         
     | 
| 
       13 
13 
     | 
    
         
             
                  expect(xhtml.root.name).to eq('html')
         
     | 
| 
       14 
     | 
    
         
            -
                  expect(xhtml.root.namespaces['xmlns']) 
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
      
 14 
     | 
    
         
            +
                  expect(xhtml.root.namespaces['xmlns'])
         
     | 
| 
      
 15 
     | 
    
         
            +
                    .to eq('http://www.w3.org/1999/xhtml')
         
     | 
| 
      
 16 
     | 
    
         
            +
                  expect(xhtml.root['xml:lang'])
         
     | 
| 
      
 17 
     | 
    
         
            +
                    .to eq('ja')
         
     | 
| 
       16 
18 
     | 
    
         
             
                  expect(xhtml.root.element_children[0].name).to eq 'head'
         
     | 
| 
       17 
     | 
    
         
            -
                  expect(xhtml.root.at_xpath('xmlns:head/xmlns:title').text) 
     | 
| 
      
 19 
     | 
    
         
            +
                  expect(xhtml.root.at_xpath('xmlns:head/xmlns:title').text)
         
     | 
| 
      
 20 
     | 
    
         
            +
                    .to eq('the title')
         
     | 
| 
       18 
21 
     | 
    
         
             
                  expect(xhtml.root.element_children[1].name).to eq 'body'
         
     | 
| 
       19 
22 
     | 
    
         
             
                end
         
     | 
| 
       20 
     | 
    
         
            -
                 
     | 
| 
       21 
     | 
    
         
            -
                   
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
                    [ 
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
       41 
     | 
    
         
            -
                   
     | 
| 
       42 
     | 
    
         
            -
                   
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
       46 
     | 
    
         
            -
                    [ 
     | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
       54 
     | 
    
         
            -
             
     | 
| 
       55 
     | 
    
         
            -
             
     | 
| 
       56 
     | 
    
         
            -
             
     | 
| 
       57 
     | 
    
         
            -
             
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
       60 
     | 
    
         
            -
             
     | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
       62 
     | 
    
         
            -
                   
     | 
| 
       63 
     | 
    
         
            -
                  body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
       64 
     | 
    
         
            -
                  expect(body.element_children.size).to eq 2
         
     | 
| 
       65 
     | 
    
         
            -
                  expect(body.element_children[0].selector_and_children).to eq(
         
     | 
| 
       66 
     | 
    
         
            -
                    ['p', 
         
     | 
| 
       67 
     | 
    
         
            -
                     'paragraph begins.', ['br', ''],
         
     | 
| 
       68 
     | 
    
         
            -
                     '2nd line.', ['br', ''],
         
     | 
| 
       69 
     | 
    
         
            -
                     '3rd line.'
         
     | 
| 
       70 
     | 
    
         
            -
                    ]
         
     | 
| 
       71 
     | 
    
         
            -
                  )
         
     | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
       73 
     | 
    
         
            -
                  expect(body.element_children[1].selector_and_children).to eq(
         
     | 
| 
       74 
     | 
    
         
            -
                    ['p', 'next paragraph.']
         
     | 
| 
       75 
     | 
    
         
            -
                  )
         
     | 
| 
       76 
     | 
    
         
            -
                end
         
     | 
| 
       77 
     | 
    
         
            -
             
     | 
| 
       78 
     | 
    
         
            -
             
     | 
| 
       79 
     | 
    
         
            -
                it 'should convert simple paragraph in english mode specified in frontmatter' do
         
     | 
| 
       80 
     | 
    
         
            -
                  text = "---\nlang: en\ntitle: the title\n---\n\n\n\nparagraph begins.\n2nd line.\n 3rd line.\n\n\n next paragraph."
         
     | 
| 
       81 
     | 
    
         
            -
                  noramark = NoraMark::Document.parse(text)
         
     | 
| 
       82 
     | 
    
         
            -
                  converted = noramark.html
         
     | 
| 
       83 
     | 
    
         
            -
                  body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
       84 
     | 
    
         
            -
                  expect(body.element_children.size).to eq 2
         
     | 
| 
       85 
     | 
    
         
            -
                  expect(body.element_children[0].selector_and_children).to eq(
         
     | 
| 
       86 
     | 
    
         
            -
                    ['p', 
         
     | 
| 
       87 
     | 
    
         
            -
                     'paragraph begins.', ['br', ''],
         
     | 
| 
       88 
     | 
    
         
            -
                     '2nd line.', ['br', ''],
         
     | 
| 
       89 
     | 
    
         
            -
                     '3rd line.'
         
     | 
| 
       90 
     | 
    
         
            -
                    ]
         
     | 
| 
       91 
     | 
    
         
            -
                  )
         
     | 
| 
       92 
     | 
    
         
            -
             
     | 
| 
       93 
     | 
    
         
            -
                  expect(body.element_children[1].selector_and_children).to eq(
         
     | 
| 
       94 
     | 
    
         
            -
                    ['p', 'next paragraph.']
         
     | 
| 
       95 
     | 
    
         
            -
                  )
         
     | 
| 
       96 
     | 
    
         
            -
                end
         
     | 
| 
       97 
     | 
    
         
            -
             
     | 
| 
       98 
     | 
    
         
            -
                it 'should convert simple paragraph in japanese mode, but paragraph mode is default' do
         
     | 
| 
       99 
     | 
    
         
            -
                  text = "paragraph begins.\n2nd line.\n 3rd line.\n\n\n next paragraph."
         
     | 
| 
       100 
     | 
    
         
            -
                  noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title', paragraph_style: :default)
         
     | 
| 
       101 
     | 
    
         
            -
                  converted = noramark.html
         
     | 
| 
       102 
     | 
    
         
            -
                  body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
       103 
     | 
    
         
            -
                  expect(body.element_children.size).to eq 2
         
     | 
| 
       104 
     | 
    
         
            -
                  expect(body.element_children[0].selector_and_children).to eq(
         
     | 
| 
       105 
     | 
    
         
            -
                    ['p', 
         
     | 
| 
       106 
     | 
    
         
            -
                     'paragraph begins.', ['br', ''],
         
     | 
| 
       107 
     | 
    
         
            -
                     '2nd line.', ['br', ''],
         
     | 
| 
       108 
     | 
    
         
            -
                     '3rd line.'
         
     | 
| 
       109 
     | 
    
         
            -
                    ]
         
     | 
| 
       110 
     | 
    
         
            -
                  )
         
     | 
| 
       111 
     | 
    
         
            -
             
     | 
| 
       112 
     | 
    
         
            -
                  expect(body.element_children[1].selector_and_children).to eq(
         
     | 
| 
       113 
     | 
    
         
            -
                    ['p', 'next paragraph.']
         
     | 
| 
       114 
     | 
    
         
            -
                  )
         
     | 
| 
       115 
     | 
    
         
            -
                end
         
     | 
| 
      
 23 
     | 
    
         
            +
                describe 'implicit markup' do
         
     | 
| 
      
 24 
     | 
    
         
            +
                  it 'convert simple paragraph' do
         
     | 
| 
      
 25 
     | 
    
         
            +
                    text = "ここから、パラグラフがはじまります。\n「二行目です。」\n三行目です。\n\n\n ここから、次のパラグラフです。"
         
     | 
| 
      
 26 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 27 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 28 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 29 
     | 
    
         
            +
                    expect(body.element_children.size).to eq 2
         
     | 
| 
      
 30 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 31 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 32 
     | 
    
         
            +
                             ['div.pgroup', 
         
     | 
| 
      
 33 
     | 
    
         
            +
                              ['p', 'ここから、パラグラフがはじまります。'],
         
     | 
| 
      
 34 
     | 
    
         
            +
                              ['p.noindent', '「二行目です。」'],
         
     | 
| 
      
 35 
     | 
    
         
            +
                              ['p', '三行目です。']
         
     | 
| 
      
 36 
     | 
    
         
            +
                             ]
         
     | 
| 
      
 37 
     | 
    
         
            +
                             )
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                    expect(body.element_children[1].selector_and_children)
         
     | 
| 
      
 40 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 41 
     | 
    
         
            +
                             ['div.pgroup',
         
     | 
| 
      
 42 
     | 
    
         
            +
                              ['p', 'ここから、次のパラグラフです。']]
         
     | 
| 
      
 43 
     | 
    
         
            +
                             )
         
     | 
| 
      
 44 
     | 
    
         
            +
                  end
         
     | 
| 
      
 45 
     | 
    
         
            +
                  it 'convert simple paragraph with BOM' do
         
     | 
| 
      
 46 
     | 
    
         
            +
                    text = "\uFEFFここから、パラグラフがはじまります。\n「二行目です。」\n三行目です。\n\n\n ここから、次のパラグラフです。"
         
     | 
| 
      
 47 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 48 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 49 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 50 
     | 
    
         
            +
                    expect(body.element_children.size).to eq 2
         
     | 
| 
      
 51 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 52 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 53 
     | 
    
         
            +
                             ['div.pgroup', 
         
     | 
| 
      
 54 
     | 
    
         
            +
                              ['p', 'ここから、パラグラフがはじまります。'],
         
     | 
| 
      
 55 
     | 
    
         
            +
                              ['p.noindent', '「二行目です。」'],
         
     | 
| 
      
 56 
     | 
    
         
            +
                              ['p', '三行目です。']
         
     | 
| 
      
 57 
     | 
    
         
            +
                             ]
         
     | 
| 
      
 58 
     | 
    
         
            +
                             )
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
                    expect(body.element_children[1].selector_and_children)
         
     | 
| 
      
 61 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 62 
     | 
    
         
            +
                             ['div.pgroup',
         
     | 
| 
      
 63 
     | 
    
         
            +
                              ['p', 'ここから、次のパラグラフです。']]
         
     | 
| 
      
 64 
     | 
    
         
            +
                             )
         
     | 
| 
      
 65 
     | 
    
         
            +
                  end
         
     | 
| 
       116 
66 
     | 
    
         | 
| 
       117 
     | 
    
         
            -
             
     | 
| 
       118 
     | 
    
         
            -
             
     | 
| 
       119 
     | 
    
         
            -
             
     | 
| 
       120 
     | 
    
         
            -
             
     | 
| 
       121 
     | 
    
         
            -
             
     | 
| 
       122 
     | 
    
         
            -
             
     | 
| 
       123 
     | 
    
         
            -
             
     | 
| 
       124 
     | 
    
         
            -
             
     | 
| 
       125 
     | 
    
         
            -
             
     | 
| 
       126 
     | 
    
         
            -
             
     | 
| 
       127 
     | 
    
         
            -
             
     | 
| 
       128 
     | 
    
         
            -
             
     | 
| 
       129 
     | 
    
         
            -
             
     | 
| 
       130 
     | 
    
         
            -
             
     | 
| 
       131 
     | 
    
         
            -
             
     | 
| 
       132 
     | 
    
         
            -
                    [ 
     | 
| 
       133 
     | 
    
         
            -
             
     | 
| 
       134 
     | 
    
         
            -
             
     | 
| 
      
 67 
     | 
    
         
            +
                  it 'convert simple paragraph in english mode' do
         
     | 
| 
      
 68 
     | 
    
         
            +
                    text = "paragraph begins.\n2nd line.\n 3rd line.\n\n\n next paragraph."
         
     | 
| 
      
 69 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'en', title: 'the title')
         
     | 
| 
      
 70 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 71 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 72 
     | 
    
         
            +
                    expect(body.element_children.size).to eq 2
         
     | 
| 
      
 73 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 74 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 75 
     | 
    
         
            +
                             ['p', 
         
     | 
| 
      
 76 
     | 
    
         
            +
                              'paragraph begins.', ['br', ''],
         
     | 
| 
      
 77 
     | 
    
         
            +
                              '2nd line.', ['br', ''],
         
     | 
| 
      
 78 
     | 
    
         
            +
                              '3rd line.'
         
     | 
| 
      
 79 
     | 
    
         
            +
                             ]
         
     | 
| 
      
 80 
     | 
    
         
            +
                             )
         
     | 
| 
      
 81 
     | 
    
         
            +
             
     | 
| 
      
 82 
     | 
    
         
            +
                    expect(body.element_children[1].selector_and_children)
         
     | 
| 
      
 83 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 84 
     | 
    
         
            +
                             ['p', 'next paragraph.']
         
     | 
| 
      
 85 
     | 
    
         
            +
                             )
         
     | 
| 
      
 86 
     | 
    
         
            +
                  end
         
     | 
| 
       135 
87 
     | 
    
         | 
| 
       136 
     | 
    
         
            -
                it 'should convert paragraph with header' do
         
     | 
| 
       137 
     | 
    
         
            -
                  text = "h1: タイトルです。\r\nここから、パラグラフがはじまります。\n\nh2.column:ふたつめの見出しです。\n ここから、次のパラグラフです。\nh3.third.foo: クラスが複数ある見出しです"
         
     | 
| 
       138 
     | 
    
         
            -
                  noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
       139 
     | 
    
         
            -
                  converted = noramark.html
         
     | 
| 
       140 
     | 
    
         
            -
                  body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
       141 
     | 
    
         
            -
                  expect(body.element_children.size).to eq 5
         
     | 
| 
       142 
     | 
    
         
            -
                  expect(body.element_children[0].a).to eq ['h1', 'タイトルです。']
         
     | 
| 
       143 
     | 
    
         
            -
                  expect(body.element_children[1].selector_and_children).to eq(
         
     | 
| 
       144 
     | 
    
         
            -
                    ['div.pgroup',
         
     | 
| 
       145 
     | 
    
         
            -
                      ['p', 'ここから、パラグラフがはじまります。']
         
     | 
| 
       146 
     | 
    
         
            -
                    ]
         
     | 
| 
       147 
     | 
    
         
            -
                  )
         
     | 
| 
       148 
     | 
    
         
            -
                  expect(body.element_children[2].a).to eq ['h2.column', 'ふたつめの見出しです。']
         
     | 
| 
       149 
     | 
    
         
            -
                  expect(body.element_children[3].selector_and_children).to eq(
         
     | 
| 
       150 
     | 
    
         
            -
                    ['div.pgroup',
         
     | 
| 
       151 
     | 
    
         
            -
                     ['p', 'ここから、次のパラグラフです。']
         
     | 
| 
       152 
     | 
    
         
            -
                    ]
         
     | 
| 
       153 
     | 
    
         
            -
                  )
         
     | 
| 
       154 
     | 
    
         
            -
                  expect(body.element_children[4].a).to eq ['h3.third.foo', 'クラスが複数ある見出しです']
         
     | 
| 
       155 
     | 
    
         
            -
                end
         
     | 
| 
       156 
88 
     | 
    
         | 
| 
       157 
     | 
    
         
            -
             
     | 
| 
       158 
     | 
    
         
            -
             
     | 
| 
       159 
     | 
    
         
            -
             
     | 
| 
       160 
     | 
    
         
            -
             
     | 
| 
       161 
     | 
    
         
            -
             
     | 
| 
       162 
     | 
    
         
            -
             
     | 
| 
       163 
     | 
    
         
            -
                    [ 
     | 
| 
       164 
     | 
    
         
            -
                       
     | 
| 
       165 
     | 
    
         
            -
             
     | 
| 
       166 
     | 
    
         
            -
             
     | 
| 
       167 
     | 
    
         
            -
             
     | 
| 
       168 
     | 
    
         
            -
             
     | 
| 
       169 
     | 
    
         
            -
             
     | 
| 
      
 89 
     | 
    
         
            +
                  it 'convert simple paragraph in english mode specified in frontmatter' do
         
     | 
| 
      
 90 
     | 
    
         
            +
                    text = "---\nlang: en\ntitle: the title\n---\n\n\n\nparagraph begins.\n2nd line.\n 3rd line.\n\n\n next paragraph."
         
     | 
| 
      
 91 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text)
         
     | 
| 
      
 92 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 93 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 94 
     | 
    
         
            +
                    expect(body.element_children.size).to eq 2
         
     | 
| 
      
 95 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 96 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 97 
     | 
    
         
            +
                             ['p', 
         
     | 
| 
      
 98 
     | 
    
         
            +
                              'paragraph begins.', ['br', ''],
         
     | 
| 
      
 99 
     | 
    
         
            +
                              '2nd line.', ['br', ''],
         
     | 
| 
      
 100 
     | 
    
         
            +
                              '3rd line.'
         
     | 
| 
      
 101 
     | 
    
         
            +
                             ]
         
     | 
| 
      
 102 
     | 
    
         
            +
                             )
         
     | 
| 
      
 103 
     | 
    
         
            +
             
     | 
| 
      
 104 
     | 
    
         
            +
                    expect(body.element_children[1].selector_and_children)
         
     | 
| 
      
 105 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 106 
     | 
    
         
            +
                             ['p', 'next paragraph.']
         
     | 
| 
      
 107 
     | 
    
         
            +
                             )
         
     | 
| 
      
 108 
     | 
    
         
            +
                  end
         
     | 
| 
       170 
109 
     | 
    
         | 
| 
      
 110 
     | 
    
         
            +
                  it 'convert simple paragraph in japanese mode, but paragraph mode is default' do
         
     | 
| 
      
 111 
     | 
    
         
            +
                    text = "paragraph begins.\n2nd line.\n 3rd line.\n\n\n next paragraph."
         
     | 
| 
      
 112 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title', paragraph_style: :default)
         
     | 
| 
      
 113 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 114 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 115 
     | 
    
         
            +
                    expect(body.element_children.size).to eq 2
         
     | 
| 
      
 116 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 117 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 118 
     | 
    
         
            +
                             ['p', 
         
     | 
| 
      
 119 
     | 
    
         
            +
                              'paragraph begins.', ['br', ''],
         
     | 
| 
      
 120 
     | 
    
         
            +
                              '2nd line.', ['br', ''],
         
     | 
| 
      
 121 
     | 
    
         
            +
                              '3rd line.'
         
     | 
| 
      
 122 
     | 
    
         
            +
                             ]
         
     | 
| 
      
 123 
     | 
    
         
            +
                             )
         
     | 
| 
      
 124 
     | 
    
         
            +
             
     | 
| 
      
 125 
     | 
    
         
            +
                    expect(body.element_children[1].selector_and_children)
         
     | 
| 
      
 126 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 127 
     | 
    
         
            +
                             ['p', 'next paragraph.']
         
     | 
| 
      
 128 
     | 
    
         
            +
                             )
         
     | 
| 
      
 129 
     | 
    
         
            +
                  end
         
     | 
| 
       171 
130 
     | 
    
         | 
| 
       172 
     | 
    
         
            -
             
     | 
| 
       173 
     | 
    
         
            -
             
     | 
| 
       174 
     | 
    
         
            -
             
     | 
| 
       175 
     | 
    
         
            -
             
     | 
| 
       176 
     | 
    
         
            -
             
     | 
| 
       177 
     | 
    
         
            -
             
     | 
| 
       178 
     | 
    
         
            -
                    [ 
     | 
| 
       179 
     | 
    
         
            -
             
     | 
| 
       180 
     | 
    
         
            -
             
     | 
| 
       181 
     | 
    
         
            -
             
     | 
| 
      
 131 
     | 
    
         
            +
                  it 'convert simple paragraph in japanese mode, but paragraph mode is default (using frontmatter)' do
         
     | 
| 
      
 132 
     | 
    
         
            +
                    text = "---\nlang: ja\ntitle: the title\nparagraph_style: default\n---\nparagraph begins.\n2nd line.\n 3rd line.\n\n\n next paragraph."
         
     | 
| 
      
 133 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title', paragraph_styl: :default)
         
     | 
| 
      
 134 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 135 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 136 
     | 
    
         
            +
                    expect(body.element_children.size).to eq 2
         
     | 
| 
      
 137 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 138 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 139 
     | 
    
         
            +
                             ['p', 
         
     | 
| 
      
 140 
     | 
    
         
            +
                              'paragraph begins.', ['br', ''],
         
     | 
| 
      
 141 
     | 
    
         
            +
                              '2nd line.', ['br', ''],
         
     | 
| 
      
 142 
     | 
    
         
            +
                              '3rd line.'
         
     | 
| 
      
 143 
     | 
    
         
            +
                             ]
         
     | 
| 
      
 144 
     | 
    
         
            +
                             )
         
     | 
| 
      
 145 
     | 
    
         
            +
             
     | 
| 
      
 146 
     | 
    
         
            +
                    expect(body.element_children[1].selector_and_children)
         
     | 
| 
      
 147 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 148 
     | 
    
         
            +
                             ['p', 'next paragraph.']
         
     | 
| 
      
 149 
     | 
    
         
            +
                             )
         
     | 
| 
      
 150 
     | 
    
         
            +
                  end
         
     | 
| 
       182 
151 
     | 
    
         
             
                end
         
     | 
| 
      
 152 
     | 
    
         
            +
                describe 'divs and hN headers' do
         
     | 
| 
      
 153 
     | 
    
         
            +
                  it 'parse paragraph with header' do
         
     | 
| 
      
 154 
     | 
    
         
            +
                    text = "h1: タイトルです。\r\nここから、パラグラフがはじまります。\n\nh2.column:ふたつめの見出しです。\n ここから、次のパラグラフです。\nh3.third.foo: クラスが複数ある見出しです"
         
     | 
| 
      
 155 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 156 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 157 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 158 
     | 
    
         
            +
                    expect(body.element_children.size).to eq 5
         
     | 
| 
      
 159 
     | 
    
         
            +
                    expect(body.element_children[0].a).to eq ['h1', 'タイトルです。']
         
     | 
| 
      
 160 
     | 
    
         
            +
                    expect(body.element_children[1].selector_and_children)
         
     | 
| 
      
 161 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 162 
     | 
    
         
            +
                             ['div.pgroup',
         
     | 
| 
      
 163 
     | 
    
         
            +
                              ['p', 'ここから、パラグラフがはじまります。']
         
     | 
| 
      
 164 
     | 
    
         
            +
                             ]
         
     | 
| 
      
 165 
     | 
    
         
            +
                             )
         
     | 
| 
      
 166 
     | 
    
         
            +
                    expect(body.element_children[2].a).to eq ['h2.column', 'ふたつめの見出しです。']
         
     | 
| 
      
 167 
     | 
    
         
            +
                    expect(body.element_children[3].selector_and_children)
         
     | 
| 
      
 168 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 169 
     | 
    
         
            +
                             ['div.pgroup',
         
     | 
| 
      
 170 
     | 
    
         
            +
                              ['p', 'ここから、次のパラグラフです。']
         
     | 
| 
      
 171 
     | 
    
         
            +
                             ]
         
     | 
| 
      
 172 
     | 
    
         
            +
                             )
         
     | 
| 
      
 173 
     | 
    
         
            +
                    expect(body.element_children[4].a).to eq ['h3.third.foo', 'クラスが複数ある見出しです']
         
     | 
| 
      
 174 
     | 
    
         
            +
                  end
         
     | 
| 
       183 
175 
     | 
    
         | 
| 
       184 
     | 
    
         
            -
             
     | 
| 
       185 
     | 
    
         
            -
             
     | 
| 
       186 
     | 
    
         
            -
             
     | 
| 
       187 
     | 
    
         
            -
             
     | 
| 
       188 
     | 
    
         
            -
             
     | 
| 
       189 
     | 
    
         
            -
             
     | 
| 
       190 
     | 
    
         
            -
             
     | 
| 
       191 
     | 
    
         
            -
             
     | 
| 
       192 
     | 
    
         
            -
             
     | 
| 
       193 
     | 
    
         
            -
             
     | 
| 
       194 
     | 
    
         
            -
             
     | 
| 
       195 
     | 
    
         
            -
             
     | 
| 
       196 
     | 
    
         
            -
             
     | 
| 
      
 176 
     | 
    
         
            +
                  it 'parse div and paragraph' do
         
     | 
| 
      
 177 
     | 
    
         
            +
                    text = "d {\n1st line. \n}"
         
     | 
| 
      
 178 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the document title')
         
     | 
| 
      
 179 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 180 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 181 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 182 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 183 
     | 
    
         
            +
                             ['div',
         
     | 
| 
      
 184 
     | 
    
         
            +
                              ['div.pgroup',
         
     | 
| 
      
 185 
     | 
    
         
            +
                               ['p', '1st line.']
         
     | 
| 
      
 186 
     | 
    
         
            +
                              ]
         
     | 
| 
      
 187 
     | 
    
         
            +
                             ]
         
     | 
| 
      
 188 
     | 
    
         
            +
                             )
         
     | 
| 
      
 189 
     | 
    
         
            +
                  end
         
     | 
| 
       197 
190 
     | 
    
         | 
| 
       198 
     | 
    
         
            -
                it 'should handle divs with empty lines' do
         
     | 
| 
       199 
     | 
    
         
            -
                  text = "\n\n\nd('wo-pgroup') {\n\n\n1st line. \n\n\n}\n\n\nd {\n 2nd div.\n}"
         
     | 
| 
       200 
     | 
    
         
            -
                  noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
       201 
     | 
    
         
            -
                  converted = noramark.html
         
     | 
| 
       202 
     | 
    
         
            -
                  body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
       203 
     | 
    
         
            -
                  expect(body.element_children[0].selector_and_children).to eq(
         
     | 
| 
       204 
     | 
    
         
            -
                    ['div',
         
     | 
| 
       205 
     | 
    
         
            -
                       ['p', '1st line.']
         
     | 
| 
       206 
     | 
    
         
            -
                    ])
         
     | 
| 
       207 
     | 
    
         
            -
                  expect(body.element_children[1].selector_and_children).to eq(
         
     | 
| 
       208 
     | 
    
         
            -
                    ['div',
         
     | 
| 
       209 
     | 
    
         
            -
                      ['div.pgroup',
         
     | 
| 
       210 
     | 
    
         
            -
                       ['p', '2nd div.']]
         
     | 
| 
       211 
     | 
    
         
            -
                    ]
         
     | 
| 
       212 
     | 
    
         
            -
             
     | 
| 
       213 
     | 
    
         
            -
                  )
         
     | 
| 
       214 
     | 
    
         
            -
                end
         
     | 
| 
       215 
191 
     | 
    
         | 
| 
       216 
     | 
    
         
            -
             
     | 
| 
       217 
     | 
    
         
            -
             
     | 
| 
       218 
     | 
    
         
            -
             
     | 
| 
       219 
     | 
    
         
            -
             
     | 
| 
       220 
     | 
    
         
            -
             
     | 
| 
       221 
     | 
    
         
            -
             
     | 
| 
       222 
     | 
    
         
            -
             
     | 
| 
       223 
     | 
    
         
            -
             
     | 
| 
       224 
     | 
    
         
            -
             
     | 
| 
       225 
     | 
    
         
            -
             
     | 
| 
       226 
     | 
    
         
            -
             
     | 
| 
       227 
     | 
    
         
            -
                   
     | 
| 
       228 
     | 
    
         
            -
                    ['div',
         
     | 
| 
       229 
     | 
    
         
            -
                      ['div.pgroup',
         
     | 
| 
       230 
     | 
    
         
            -
                       ['p', 'in pgroup']
         
     | 
| 
       231 
     | 
    
         
            -
                     ]
         
     | 
| 
       232 
     | 
    
         
            -
                    ])
         
     | 
| 
       233 
     | 
    
         
            -
                end
         
     | 
| 
      
 192 
     | 
    
         
            +
                  it 'parse div without pgroup' do
         
     | 
| 
      
 193 
     | 
    
         
            +
                    text = "d('wo-pgroup') {\n1st line. \n}"
         
     | 
| 
      
 194 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 195 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 196 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 197 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 198 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 199 
     | 
    
         
            +
                             ['div',
         
     | 
| 
      
 200 
     | 
    
         
            +
                              ['p', '1st line.']
         
     | 
| 
      
 201 
     | 
    
         
            +
                             ]
         
     | 
| 
      
 202 
     | 
    
         
            +
                             )
         
     | 
| 
      
 203 
     | 
    
         
            +
                  end
         
     | 
| 
       234 
204 
     | 
    
         | 
| 
      
 205 
     | 
    
         
            +
                  it 'parse nested div without pgroup' do
         
     | 
| 
      
 206 
     | 
    
         
            +
                    text = "d(wo-pgroup) {\nd {\nnested.\n} \n}"
         
     | 
| 
      
 207 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 208 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 209 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 210 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 211 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 212 
     | 
    
         
            +
                             ['div',
         
     | 
| 
      
 213 
     | 
    
         
            +
                              ['div',
         
     | 
| 
      
 214 
     | 
    
         
            +
                               ['p', 'nested.']
         
     | 
| 
      
 215 
     | 
    
         
            +
                              ]
         
     | 
| 
      
 216 
     | 
    
         
            +
                             ]
         
     | 
| 
      
 217 
     | 
    
         
            +
                             )
         
     | 
| 
      
 218 
     | 
    
         
            +
                  end
         
     | 
| 
       235 
219 
     | 
    
         | 
| 
       236 
     | 
    
         
            -
             
     | 
| 
       237 
     | 
    
         
            -
             
     | 
| 
       238 
     | 
    
         
            -
             
     | 
| 
       239 
     | 
    
         
            -
             
     | 
| 
       240 
     | 
    
         
            -
             
     | 
| 
       241 
     | 
    
         
            -
             
     | 
| 
       242 
     | 
    
         
            -
             
     | 
| 
       243 
     | 
    
         
            -
             
     | 
| 
       244 
     | 
    
         
            -
             
     | 
| 
       245 
     | 
    
         
            -
             
     | 
| 
       246 
     | 
    
         
            -
             
     | 
| 
      
 220 
     | 
    
         
            +
                  it 'handle divs with empty lines' do
         
     | 
| 
      
 221 
     | 
    
         
            +
                    text = "\n\n\nd('wo-pgroup') {\n\n\n1st line. \n\n\n}\n\n\nd {\n 2nd div.\n}"
         
     | 
| 
      
 222 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 223 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 224 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 225 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 226 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 227 
     | 
    
         
            +
                             ['div',
         
     | 
| 
      
 228 
     | 
    
         
            +
                              ['p', '1st line.']
         
     | 
| 
      
 229 
     | 
    
         
            +
                             ])
         
     | 
| 
      
 230 
     | 
    
         
            +
                    expect(body.element_children[1].selector_and_children)
         
     | 
| 
      
 231 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 232 
     | 
    
         
            +
                             ['div',
         
     | 
| 
      
 233 
     | 
    
         
            +
                              ['div.pgroup',
         
     | 
| 
      
 234 
     | 
    
         
            +
                               ['p', '2nd div.']]
         
     | 
| 
      
 235 
     | 
    
         
            +
                             ]
         
     | 
| 
      
 236 
     | 
    
         
            +
             
     | 
| 
      
 237 
     | 
    
         
            +
                             )
         
     | 
| 
      
 238 
     | 
    
         
            +
                  end
         
     | 
| 
       247 
239 
     | 
    
         | 
| 
       248 
     | 
    
         
            -
             
     | 
| 
       249 
     | 
    
         
            -
             
     | 
| 
       250 
     | 
    
         
            -
             
     | 
| 
       251 
     | 
    
         
            -
             
     | 
| 
       252 
     | 
    
         
            -
             
     | 
| 
       253 
     | 
    
         
            -
             
     | 
| 
       254 
     | 
    
         
            -
             
     | 
| 
       255 
     | 
    
         
            -
             
     | 
| 
       256 
     | 
    
         
            -
             
     | 
| 
       257 
     | 
    
         
            -
             
     | 
| 
       258 
     | 
    
         
            -
             
     | 
| 
      
 240 
     | 
    
         
            +
                  it 'parse nested div without pgroup and with pgroup' do
         
     | 
| 
      
 241 
     | 
    
         
            +
                    text = "d(wo-pgroup) {\nd {\nnested.\n} \n}\n\nd {\nin pgroup\n}"
         
     | 
| 
      
 242 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 243 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 244 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 245 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 246 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 247 
     | 
    
         
            +
                             ['div',
         
     | 
| 
      
 248 
     | 
    
         
            +
                              ['div',
         
     | 
| 
      
 249 
     | 
    
         
            +
                               ['p', 'nested.']
         
     | 
| 
      
 250 
     | 
    
         
            +
                              ]
         
     | 
| 
      
 251 
     | 
    
         
            +
                             ])                                                                   
         
     | 
| 
      
 252 
     | 
    
         
            +
                    expect(body.element_children[1].selector_and_children)
         
     | 
| 
      
 253 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 254 
     | 
    
         
            +
                             ['div',
         
     | 
| 
      
 255 
     | 
    
         
            +
                              ['div.pgroup',
         
     | 
| 
      
 256 
     | 
    
         
            +
                               ['p', 'in pgroup']
         
     | 
| 
      
 257 
     | 
    
         
            +
                              ]
         
     | 
| 
      
 258 
     | 
    
         
            +
                             ])
         
     | 
| 
      
 259 
     | 
    
         
            +
                  end
         
     | 
| 
       259 
260 
     | 
    
         | 
| 
       260 
     | 
    
         
            -
             
     | 
| 
       261 
     | 
    
         
            -
             
     | 
| 
       262 
     | 
    
         
            -
             
     | 
| 
       263 
     | 
    
         
            -
             
     | 
| 
       264 
     | 
    
         
            -
             
     | 
| 
       265 
     | 
    
         
            -
             
     | 
| 
       266 
     | 
    
         
            -
             
     | 
| 
       267 
     | 
    
         
            -
             
     | 
| 
       268 
     | 
    
         
            -
             
     | 
| 
       269 
     | 
    
         
            -
             
     | 
| 
       270 
     | 
    
         
            -
             
     | 
| 
       271 
     | 
    
         
            -
             
     | 
| 
       272 
     | 
    
         
            -
                       ['p', 'nested!']
         
     | 
| 
       273 
     | 
    
         
            -
                      ]
         
     | 
| 
       274 
     | 
    
         
            -
                     ],
         
     | 
| 
       275 
     | 
    
         
            -
                     ['div.pgroup',
         
     | 
| 
       276 
     | 
    
         
            -
                      ['p', 'outer div again.']
         
     | 
| 
       277 
     | 
    
         
            -
                     ],
         
     | 
| 
       278 
     | 
    
         
            -
                    ]
         
     | 
| 
       279 
     | 
    
         
            -
                  )
         
     | 
| 
       280 
     | 
    
         
            -
                end
         
     | 
| 
      
 261 
     | 
    
         
            +
                  it 'parse div with class' do
         
     | 
| 
      
 262 
     | 
    
         
            +
                    text = "d.preface-one {\n h1: title.\n}"
         
     | 
| 
      
 263 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 264 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 265 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 266 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 267 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 268 
     | 
    
         
            +
                             ['div.preface-one',
         
     | 
| 
      
 269 
     | 
    
         
            +
                              ['h1', 'title.']
         
     | 
| 
      
 270 
     | 
    
         
            +
                             ]
         
     | 
| 
      
 271 
     | 
    
         
            +
                             )
         
     | 
| 
      
 272 
     | 
    
         
            +
                  end
         
     | 
| 
       281 
273 
     | 
    
         | 
| 
       282 
     | 
    
         
            -
             
     | 
| 
       283 
     | 
    
         
            -
             
     | 
| 
       284 
     | 
    
         
            -
             
     | 
| 
       285 
     | 
    
         
            -
             
     | 
| 
       286 
     | 
    
         
            -
             
     | 
| 
       287 
     | 
    
         
            -
             
     | 
| 
       288 
     | 
    
         
            -
             
     | 
| 
       289 
     | 
    
         
            -
             
     | 
| 
       290 
     | 
    
         
            -
             
     | 
| 
       291 
     | 
    
         
            -
             
     | 
| 
       292 
     | 
    
         
            -
             
     | 
| 
       293 
     | 
    
         
            -
             
     | 
| 
       294 
     | 
    
         
            -
                end
         
     | 
| 
      
 274 
     | 
    
         
            +
                  it 'parse div with id and class' do
         
     | 
| 
      
 275 
     | 
    
         
            +
                    text = "d#thecontents.preface-one {\nh1: title.\n}"
         
     | 
| 
      
 276 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 277 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 278 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 279 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children(remove_id: false))
         
     | 
| 
      
 280 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 281 
     | 
    
         
            +
                             ['div#thecontents.preface-one',
         
     | 
| 
      
 282 
     | 
    
         
            +
                              ['h1#heading_index_1', 'title.']
         
     | 
| 
      
 283 
     | 
    
         
            +
                             ]
         
     | 
| 
      
 284 
     | 
    
         
            +
                             )
         
     | 
| 
      
 285 
     | 
    
         
            +
                  end
         
     | 
| 
       295 
286 
     | 
    
         | 
| 
       296 
     | 
    
         
            -
             
     | 
| 
       297 
     | 
    
         
            -
             
     | 
| 
       298 
     | 
    
         
            -
             
     | 
| 
       299 
     | 
    
         
            -
             
     | 
| 
       300 
     | 
    
         
            -
             
     | 
| 
       301 
     | 
    
         
            -
             
     | 
| 
       302 
     | 
    
         
            -
             
     | 
| 
       303 
     | 
    
         
            -
             
     | 
| 
       304 
     | 
    
         
            -
             
     | 
| 
       305 
     | 
    
         
            -
             
     | 
| 
       306 
     | 
    
         
            -
             
     | 
| 
       307 
     | 
    
         
            -
             
     | 
| 
      
 287 
     | 
    
         
            +
                  it 'parse nested div' do
         
     | 
| 
      
 288 
     | 
    
         
            +
                    text = "d.preface {\n outer div. \n d.nested {\n nested!\n}\nouter div again.\n}"
         
     | 
| 
      
 289 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 290 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 291 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 292 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 293 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 294 
     | 
    
         
            +
                             ['div.preface',
         
     | 
| 
      
 295 
     | 
    
         
            +
                              ['div.pgroup',
         
     | 
| 
      
 296 
     | 
    
         
            +
                               ['p', 'outer div.']
         
     | 
| 
      
 297 
     | 
    
         
            +
                              ],
         
     | 
| 
      
 298 
     | 
    
         
            +
                              ['div.nested',
         
     | 
| 
      
 299 
     | 
    
         
            +
                               ['div.pgroup',
         
     | 
| 
      
 300 
     | 
    
         
            +
                                ['p', 'nested!']
         
     | 
| 
      
 301 
     | 
    
         
            +
                               ]
         
     | 
| 
      
 302 
     | 
    
         
            +
                              ],
         
     | 
| 
      
 303 
     | 
    
         
            +
                              ['div.pgroup',
         
     | 
| 
      
 304 
     | 
    
         
            +
                               ['p', 'outer div again.']
         
     | 
| 
      
 305 
     | 
    
         
            +
                              ],
         
     | 
| 
      
 306 
     | 
    
         
            +
                             ]
         
     | 
| 
      
 307 
     | 
    
         
            +
                             )
         
     | 
| 
      
 308 
     | 
    
         
            +
                  end
         
     | 
| 
       308 
309 
     | 
    
         
             
                end
         
     | 
| 
      
 310 
     | 
    
         
            +
                describe 'article and section' do
         
     | 
| 
      
 311 
     | 
    
         
            +
                  it 'parse article' do
         
     | 
| 
      
 312 
     | 
    
         
            +
                    text = "art {\n in the article.\n}"
         
     | 
| 
      
 313 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 314 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 315 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 316 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 317 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 318 
     | 
    
         
            +
                             ['article',
         
     | 
| 
      
 319 
     | 
    
         
            +
                              ['div.pgroup',
         
     | 
| 
      
 320 
     | 
    
         
            +
                               ['p', 'in the article.']
         
     | 
| 
      
 321 
     | 
    
         
            +
                              ]
         
     | 
| 
      
 322 
     | 
    
         
            +
                             ]
         
     | 
| 
      
 323 
     | 
    
         
            +
                             ) 
         
     | 
| 
      
 324 
     | 
    
         
            +
                  end
         
     | 
| 
       309 
325 
     | 
    
         | 
| 
       310 
     | 
    
         
            -
             
     | 
| 
       311 
     | 
    
         
            -
             
     | 
| 
       312 
     | 
    
         
            -
             
     | 
| 
       313 
     | 
    
         
            -
             
     | 
| 
       314 
     | 
    
         
            -
             
     | 
| 
       315 
     | 
    
         
            -
             
     | 
| 
       316 
     | 
    
         
            -
             
     | 
| 
       317 
     | 
    
         
            -
             
     | 
| 
       318 
     | 
    
         
            -
             
     | 
| 
       319 
     | 
    
         
            -
             
     | 
| 
       320 
     | 
    
         
            -
             
     | 
| 
       321 
     | 
    
         
            -
             
     | 
| 
       322 
     | 
    
         
            -
             
     | 
| 
      
 326 
     | 
    
         
            +
                  it 'parse article with other notation' do
         
     | 
| 
      
 327 
     | 
    
         
            +
                    text = "arti {\n in the article.\n}"
         
     | 
| 
      
 328 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 329 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 330 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 331 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 332 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 333 
     | 
    
         
            +
                             ['article',
         
     | 
| 
      
 334 
     | 
    
         
            +
                              ['div.pgroup',
         
     | 
| 
      
 335 
     | 
    
         
            +
                               ['p', 'in the article.']
         
     | 
| 
      
 336 
     | 
    
         
            +
                              ]
         
     | 
| 
      
 337 
     | 
    
         
            +
                             ]
         
     | 
| 
      
 338 
     | 
    
         
            +
                             ) 
         
     | 
| 
      
 339 
     | 
    
         
            +
                  end
         
     | 
| 
       323 
340 
     | 
    
         | 
| 
       324 
     | 
    
         
            -
             
     | 
| 
       325 
     | 
    
         
            -
             
     | 
| 
       326 
     | 
    
         
            -
             
     | 
| 
       327 
     | 
    
         
            -
             
     | 
| 
       328 
     | 
    
         
            -
             
     | 
| 
       329 
     | 
    
         
            -
             
     | 
| 
       330 
     | 
    
         
            -
             
     | 
| 
       331 
     | 
    
         
            -
             
     | 
| 
       332 
     | 
    
         
            -
             
     | 
| 
       333 
     | 
    
         
            -
             
     | 
| 
       334 
     | 
    
         
            -
             
     | 
| 
       335 
     | 
    
         
            -
             
     | 
| 
       336 
     | 
    
         
            -
             
     | 
| 
       337 
     | 
    
         
            -
             
     | 
| 
       338 
     | 
    
         
            -
                end
         
     | 
| 
      
 341 
     | 
    
         
            +
                  it 'parse article with yet anther notation' do
         
     | 
| 
      
 342 
     | 
    
         
            +
                    text = "article {\n in the article.\n}"
         
     | 
| 
      
 343 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 344 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 345 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 346 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 347 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 348 
     | 
    
         
            +
                             ['article',
         
     | 
| 
      
 349 
     | 
    
         
            +
                              ['div.pgroup',
         
     | 
| 
      
 350 
     | 
    
         
            +
                               ['p', 'in the article.']
         
     | 
| 
      
 351 
     | 
    
         
            +
                              ]
         
     | 
| 
      
 352 
     | 
    
         
            +
                             ]
         
     | 
| 
      
 353 
     | 
    
         
            +
                             ) 
         
     | 
| 
      
 354 
     | 
    
         
            +
                  end
         
     | 
| 
       339 
355 
     | 
    
         | 
| 
       340 
     | 
    
         
            -
             
     | 
| 
       341 
     | 
    
         
            -
             
     | 
| 
       342 
     | 
    
         
            -
             
     | 
| 
       343 
     | 
    
         
            -
             
     | 
| 
       344 
     | 
    
         
            -
             
     | 
| 
       345 
     | 
    
         
            -
             
     | 
| 
       346 
     | 
    
         
            -
             
     | 
| 
       347 
     | 
    
         
            -
             
     | 
| 
       348 
     | 
    
         
            -
             
     | 
| 
       349 
     | 
    
         
            -
             
     | 
| 
       350 
     | 
    
         
            -
             
     | 
| 
       351 
     | 
    
         
            -
             
     | 
| 
       352 
     | 
    
         
            -
             
     | 
| 
       353 
     | 
    
         
            -
             
     | 
| 
       354 
     | 
    
         
            -
             
     | 
| 
      
 356 
     | 
    
         
            +
                  it 'parse section ' do
         
     | 
| 
      
 357 
     | 
    
         
            +
                    text = "art {\nsec {\n section in the article. \n}\n}"
         
     | 
| 
      
 358 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 359 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 360 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 361 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 362 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 363 
     | 
    
         
            +
                             ['article',
         
     | 
| 
      
 364 
     | 
    
         
            +
                              ['section',
         
     | 
| 
      
 365 
     | 
    
         
            +
                               ['div.pgroup',
         
     | 
| 
      
 366 
     | 
    
         
            +
                                ['p', 'section in the article.']
         
     | 
| 
      
 367 
     | 
    
         
            +
                               ]
         
     | 
| 
      
 368 
     | 
    
         
            +
                              ]
         
     | 
| 
      
 369 
     | 
    
         
            +
                             ]
         
     | 
| 
      
 370 
     | 
    
         
            +
                             ) 
         
     | 
| 
      
 371 
     | 
    
         
            +
                  end
         
     | 
| 
       355 
372 
     | 
    
         | 
| 
       356 
     | 
    
         
            -
             
     | 
| 
       357 
     | 
    
         
            -
             
     | 
| 
       358 
     | 
    
         
            -
             
     | 
| 
       359 
     | 
    
         
            -
             
     | 
| 
       360 
     | 
    
         
            -
             
     | 
| 
       361 
     | 
    
         
            -
             
     | 
| 
       362 
     | 
    
         
            -
             
     | 
| 
       363 
     | 
    
         
            -
             
     | 
| 
       364 
     | 
    
         
            -
             
     | 
| 
       365 
     | 
    
         
            -
             
     | 
| 
       366 
     | 
    
         
            -
             
     | 
| 
       367 
     | 
    
         
            -
             
     | 
| 
       368 
     | 
    
         
            -
             
     | 
| 
       369 
     | 
    
         
            -
             
     | 
| 
       370 
     | 
    
         
            -
             
     | 
| 
      
 373 
     | 
    
         
            +
                  it 'parse section with other notation' do
         
     | 
| 
      
 374 
     | 
    
         
            +
                    text = "art {\nsect {\n section in the article. \n}\n}"
         
     | 
| 
      
 375 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 376 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 377 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 378 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 379 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 380 
     | 
    
         
            +
                             ['article',
         
     | 
| 
      
 381 
     | 
    
         
            +
                              ['section',
         
     | 
| 
      
 382 
     | 
    
         
            +
                               ['div.pgroup',
         
     | 
| 
      
 383 
     | 
    
         
            +
                                ['p', 'section in the article.']
         
     | 
| 
      
 384 
     | 
    
         
            +
                               ]
         
     | 
| 
      
 385 
     | 
    
         
            +
                              ]
         
     | 
| 
      
 386 
     | 
    
         
            +
                             ]
         
     | 
| 
      
 387 
     | 
    
         
            +
                             ) 
         
     | 
| 
      
 388 
     | 
    
         
            +
                  end
         
     | 
| 
       371 
389 
     | 
    
         | 
| 
       372 
     | 
    
         
            -
             
     | 
| 
       373 
     | 
    
         
            -
             
     | 
| 
       374 
     | 
    
         
            -
             
     | 
| 
       375 
     | 
    
         
            -
             
     | 
| 
       376 
     | 
    
         
            -
             
     | 
| 
       377 
     | 
    
         
            -
             
     | 
| 
       378 
     | 
    
         
            -
             
     | 
| 
       379 
     | 
    
         
            -
             
     | 
| 
       380 
     | 
    
         
            -
             
     | 
| 
       381 
     | 
    
         
            -
             
     | 
| 
       382 
     | 
    
         
            -
             
     | 
| 
       383 
     | 
    
         
            -
             
     | 
| 
       384 
     | 
    
         
            -
             
     | 
| 
       385 
     | 
    
         
            -
             
     | 
| 
       386 
     | 
    
         
            -
             
     | 
| 
       387 
     | 
    
         
            -
                   
     | 
| 
      
 390 
     | 
    
         
            +
                  it 'parse section with yet other notation' do
         
     | 
| 
      
 391 
     | 
    
         
            +
                    text = "art {\nsection {\n section in the article. \n}\n}"
         
     | 
| 
      
 392 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 393 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 394 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 395 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 396 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 397 
     | 
    
         
            +
                             ['article',
         
     | 
| 
      
 398 
     | 
    
         
            +
                              ['section',
         
     | 
| 
      
 399 
     | 
    
         
            +
                               ['div.pgroup',
         
     | 
| 
      
 400 
     | 
    
         
            +
                                ['p', 'section in the article.']
         
     | 
| 
      
 401 
     | 
    
         
            +
                               ]
         
     | 
| 
      
 402 
     | 
    
         
            +
                              ]
         
     | 
| 
      
 403 
     | 
    
         
            +
                             ]
         
     | 
| 
      
 404 
     | 
    
         
            +
                             ) 
         
     | 
| 
      
 405 
     | 
    
         
            +
                  end
         
     | 
| 
       388 
406 
     | 
    
         
             
                end
         
     | 
| 
      
 407 
     | 
    
         
            +
                describe 'other block command' do
         
     | 
| 
      
 408 
     | 
    
         
            +
                  it 'handle block image' do
         
     | 
| 
      
 409 
     | 
    
         
            +
                    text = "this is normal line.\nimage(./image1.jpg, \"alt text\"): caption text"
         
     | 
| 
      
 410 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 411 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 412 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 413 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 414 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 415 
     | 
    
         
            +
                             ['div.pgroup',
         
     | 
| 
      
 416 
     | 
    
         
            +
                              ['p', 'this is normal line.']
         
     | 
| 
      
 417 
     | 
    
         
            +
                             ]
         
     | 
| 
      
 418 
     | 
    
         
            +
                             )      
         
     | 
| 
      
 419 
     | 
    
         
            +
                    expect(body.element_children[1].selector_and_children)
         
     | 
| 
      
 420 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 421 
     | 
    
         
            +
                             ['figure.img-wrap',
         
     | 
| 
      
 422 
     | 
    
         
            +
                              ["img[src='./image1.jpg'][alt='alt text']", ''],
         
     | 
| 
      
 423 
     | 
    
         
            +
                              ['figcaption', 'caption text']
         
     | 
| 
      
 424 
     | 
    
         
            +
                             ]
         
     | 
| 
      
 425 
     | 
    
         
            +
                             )      
         
     | 
| 
      
 426 
     | 
    
         
            +
                  end
         
     | 
| 
       389 
427 
     | 
    
         | 
| 
       390 
     | 
    
         
            -
             
     | 
| 
       391 
     | 
    
         
            -
             
     | 
| 
       392 
     | 
    
         
            -
             
     | 
| 
       393 
     | 
    
         
            -
             
     | 
| 
       394 
     | 
    
         
            -
             
     | 
| 
       395 
     | 
    
         
            -
             
     | 
| 
       396 
     | 
    
         
            -
             
     | 
| 
       397 
     | 
    
         
            -
             
     | 
| 
       398 
     | 
    
         
            -
             
     | 
| 
       399 
     | 
    
         
            -
             
     | 
| 
       400 
     | 
    
         
            -
                   
     | 
| 
       401 
     | 
    
         
            -
             
     | 
| 
       402 
     | 
    
         
            -
             
     | 
| 
       403 
     | 
    
         
            -
             
     | 
| 
       404 
     | 
    
         
            -
             
     | 
| 
       405 
     | 
    
         
            -
             
     | 
| 
       406 
     | 
    
         
            -
             
     | 
| 
      
 428 
     | 
    
         
            +
                  it 'handle block image with before caption' do
         
     | 
| 
      
 429 
     | 
    
         
            +
                    text = "this is normal line.\nimage(./image1.jpg, alt text)[caption_before: 'true']: caption text"
         
     | 
| 
      
 430 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 431 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 432 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 433 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 434 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 435 
     | 
    
         
            +
                             ['div.pgroup',
         
     | 
| 
      
 436 
     | 
    
         
            +
                              ['p', 'this is normal line.']
         
     | 
| 
      
 437 
     | 
    
         
            +
                             ]
         
     | 
| 
      
 438 
     | 
    
         
            +
                             )      
         
     | 
| 
      
 439 
     | 
    
         
            +
                    expect(body.element_children[1].selector_and_children)
         
     | 
| 
      
 440 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 441 
     | 
    
         
            +
                             ['figure.img-wrap',
         
     | 
| 
      
 442 
     | 
    
         
            +
                              ['figcaption', 'caption text'],
         
     | 
| 
      
 443 
     | 
    
         
            +
                              ["img[src='./image1.jpg'][alt='alt text']", '']
         
     | 
| 
      
 444 
     | 
    
         
            +
                             ]
         
     | 
| 
      
 445 
     | 
    
         
            +
                             )      
         
     | 
| 
      
 446 
     | 
    
         
            +
                  end
         
     | 
| 
       407 
447 
     | 
    
         | 
| 
       408 
     | 
    
         
            -
             
     | 
| 
       409 
     | 
    
         
            -
             
     | 
| 
       410 
     | 
    
         
            -
             
     | 
| 
       411 
     | 
    
         
            -
             
     | 
| 
       412 
     | 
    
         
            -
             
     | 
| 
       413 
     | 
    
         
            -
             
     | 
| 
       414 
     | 
    
         
            -
             
     | 
| 
       415 
     | 
    
         
            -
             
     | 
| 
       416 
     | 
    
         
            -
             
     | 
| 
       417 
     | 
    
         
            -
             
     | 
| 
       418 
     | 
    
         
            -
                   
     | 
| 
       419 
     | 
    
         
            -
             
     | 
| 
       420 
     | 
    
         
            -
             
     | 
| 
       421 
     | 
    
         
            -
             
     | 
| 
       422 
     | 
    
         
            -
             
     | 
| 
       423 
     | 
    
         
            -
             
     | 
| 
      
 448 
     | 
    
         
            +
                  it 'handle block image without caption' do
         
     | 
| 
      
 449 
     | 
    
         
            +
                    text = "this is normal line.\nimage(./image1.jpg, alt text):"
         
     | 
| 
      
 450 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 451 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 452 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 453 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 454 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 455 
     | 
    
         
            +
                             ['div.pgroup',
         
     | 
| 
      
 456 
     | 
    
         
            +
                              ['p', 'this is normal line.']
         
     | 
| 
      
 457 
     | 
    
         
            +
                             ]
         
     | 
| 
      
 458 
     | 
    
         
            +
                             )      
         
     | 
| 
      
 459 
     | 
    
         
            +
                    expect(body.element_children[1].selector_and_children)
         
     | 
| 
      
 460 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 461 
     | 
    
         
            +
                             ['figure.img-wrap',
         
     | 
| 
      
 462 
     | 
    
         
            +
                              ["img[src='./image1.jpg'][alt='alt text']", '']
         
     | 
| 
      
 463 
     | 
    
         
            +
                             ]
         
     | 
| 
      
 464 
     | 
    
         
            +
                             )      
         
     | 
| 
      
 465 
     | 
    
         
            +
                  end
         
     | 
| 
       424 
466 
     | 
    
         | 
| 
       425 
     | 
    
         
            -
             
     | 
| 
       426 
     | 
    
         
            -
             
     | 
| 
       427 
     | 
    
         
            -
             
     | 
| 
       428 
     | 
    
         
            -
             
     | 
| 
       429 
     | 
    
         
            -
             
     | 
| 
       430 
     | 
    
         
            -
             
     | 
| 
       431 
     | 
    
         
            -
             
     | 
| 
       432 
     | 
    
         
            -
             
     | 
| 
       433 
     | 
    
         
            -
             
     | 
| 
       434 
     | 
    
         
            -
             
     | 
| 
       435 
     | 
    
         
            -
             
     | 
| 
       436 
     | 
    
         
            -
             
     | 
| 
       437 
     | 
    
         
            -
             
     | 
| 
       438 
     | 
    
         
            -
             
     | 
| 
       439 
     | 
    
         
            -
             
     | 
| 
       440 
     | 
    
         
            -
             
     | 
| 
       441 
     | 
    
         
            -
             
     | 
| 
       442 
     | 
    
         
            -
             
     | 
| 
       443 
     | 
    
         
            -
             
     | 
| 
       444 
     | 
    
         
            -
             
     | 
| 
       445 
     | 
    
         
            -
             
     | 
| 
       446 
     | 
    
         
            -
             
     | 
| 
       447 
     | 
    
         
            -
             
     | 
| 
       448 
     | 
    
         
            -
             
     | 
| 
       449 
     | 
    
         
            -
             
     | 
| 
       450 
     | 
    
         
            -
             
     | 
| 
       451 
     | 
    
         
            -
                    [ 
     | 
| 
       452 
     | 
    
         
            -
             
     | 
| 
       453 
     | 
    
         
            -
             
     | 
| 
       454 
     | 
    
         
            -
             
     | 
| 
      
 467 
     | 
    
         
            +
                  it 'handle page change article' do
         
     | 
| 
      
 468 
     | 
    
         
            +
                    text = "this is start.\nnewpage:\n---\ntitle: page changed\n---\n\nthis is second page.\nnewpage:\nand the third."
         
     | 
| 
      
 469 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 470 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 471 
     | 
    
         
            +
                    expect(converted.size).to eq 3
         
     | 
| 
      
 472 
     | 
    
         
            +
                    body1 = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 473 
     | 
    
         
            +
                    expect(body1.element_children[0].selector_and_children)
         
     | 
| 
      
 474 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 475 
     | 
    
         
            +
                             ['div.pgroup',
         
     | 
| 
      
 476 
     | 
    
         
            +
                              ['p', 'this is start.']
         
     | 
| 
      
 477 
     | 
    
         
            +
                             ]
         
     | 
| 
      
 478 
     | 
    
         
            +
                             )
         
     | 
| 
      
 479 
     | 
    
         
            +
             
     | 
| 
      
 480 
     | 
    
         
            +
                    head2 = Nokogiri::XML::Document.parse(converted[1]).root.at_xpath('xmlns:head')
         
     | 
| 
      
 481 
     | 
    
         
            +
                    expect(head2.element_children[0].a).to eq ['title', 'page changed']
         
     | 
| 
      
 482 
     | 
    
         
            +
                    body2 = Nokogiri::XML::Document.parse(converted[1]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 483 
     | 
    
         
            +
                    expect(body2.element_children[0].selector_and_children)
         
     | 
| 
      
 484 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 485 
     | 
    
         
            +
                             ['div.pgroup',
         
     | 
| 
      
 486 
     | 
    
         
            +
                              ['p', 'this is second page.']
         
     | 
| 
      
 487 
     | 
    
         
            +
                             ]
         
     | 
| 
      
 488 
     | 
    
         
            +
                             )
         
     | 
| 
      
 489 
     | 
    
         
            +
             
     | 
| 
      
 490 
     | 
    
         
            +
                    head3 = Nokogiri::XML::Document.parse(converted[2]).root.at_xpath('xmlns:head')
         
     | 
| 
      
 491 
     | 
    
         
            +
                    expect(head3.element_children[0].a).to eq ['title', 'page changed']
         
     | 
| 
      
 492 
     | 
    
         
            +
                    body3 = Nokogiri::XML::Document.parse(converted[2]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 493 
     | 
    
         
            +
                    expect(body3.element_children[0].selector_and_children)
         
     | 
| 
      
 494 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 495 
     | 
    
         
            +
                             ['div.pgroup',
         
     | 
| 
      
 496 
     | 
    
         
            +
                              ['p', 'and the third.']
         
     | 
| 
      
 497 
     | 
    
         
            +
                             ]
         
     | 
| 
      
 498 
     | 
    
         
            +
                             )
         
     | 
| 
      
 499 
     | 
    
         
            +
                  end
         
     | 
| 
       455 
500 
     | 
    
         | 
| 
       456 
     | 
    
         
            -
             
     | 
| 
       457 
     | 
    
         
            -
             
     | 
| 
       458 
     | 
    
         
            -
             
     | 
| 
       459 
     | 
    
         
            -
             
     | 
| 
       460 
     | 
    
         
            -
             
     | 
| 
       461 
     | 
    
         
            -
             
     | 
| 
       462 
     | 
    
         
            -
             
     | 
| 
       463 
     | 
    
         
            -
             
     | 
| 
       464 
     | 
    
         
            -
             
     | 
| 
      
 501 
     | 
    
         
            +
                  it 'handle stylesheets' do
         
     | 
| 
      
 502 
     | 
    
         
            +
                    text = "d.styled {\n this is styled document.\n}"
         
     | 
| 
      
 503 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the document title', stylesheets: ['reset.css', 'mystyle.css'])
         
     | 
| 
      
 504 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 505 
     | 
    
         
            +
                    head = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:head')
         
     | 
| 
      
 506 
     | 
    
         
            +
                    expect(head.element_children[0].a).to eq ['title', 'the document title']
         
     | 
| 
      
 507 
     | 
    
         
            +
                    expect(head.element_children[1].a).to eq ["link[rel='stylesheet'][type='text/css'][href='reset.css']", '']
         
     | 
| 
      
 508 
     | 
    
         
            +
                    expect(head.element_children[2].a).to eq ["link[rel='stylesheet'][type='text/css'][href='mystyle.css']", '']
         
     | 
| 
      
 509 
     | 
    
         
            +
                  end
         
     | 
| 
       465 
510 
     | 
    
         | 
| 
       466 
     | 
    
         
            -
             
     | 
| 
       467 
     | 
    
         
            -
             
     | 
| 
       468 
     | 
    
         
            -
             
     | 
| 
       469 
     | 
    
         
            -
             
     | 
| 
       470 
     | 
    
         
            -
             
     | 
| 
       471 
     | 
    
         
            -
             
     | 
| 
       472 
     | 
    
         
            -
             
     | 
| 
       473 
     | 
    
         
            -
             
     | 
| 
       474 
     | 
    
         
            -
             
     | 
| 
       475 
     | 
    
         
            -
             
     | 
| 
       476 
     | 
    
         
            -
             
     | 
| 
       477 
     | 
    
         
            -
             
     | 
| 
       478 
     | 
    
         
            -
             
     | 
| 
       479 
     | 
    
         
            -
                  ]
         
     | 
| 
       480 
     | 
    
         
            -
                 )       
         
     | 
| 
       481 
     | 
    
         
            -
                end
         
     | 
| 
      
 511 
     | 
    
         
            +
                  it 'handle custom paragraph' do
         
     | 
| 
      
 512 
     | 
    
         
            +
                    text = "this is normal line.\np.custom: this text is in custom class."
         
     | 
| 
      
 513 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 514 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 515 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 516 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 517 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 518 
     | 
    
         
            +
                             ['div.pgroup',
         
     | 
| 
      
 519 
     | 
    
         
            +
                              ['p', 'this is normal line.'],
         
     | 
| 
      
 520 
     | 
    
         
            +
                              ['p.custom', 'this text is in custom class.']
         
     | 
| 
      
 521 
     | 
    
         
            +
                             ]
         
     | 
| 
      
 522 
     | 
    
         
            +
                             )        
         
     | 
| 
      
 523 
     | 
    
         
            +
                  end
         
     | 
| 
       482 
524 
     | 
    
         | 
| 
       483 
     | 
    
         
            -
             
     | 
| 
       484 
     | 
    
         
            -
             
     | 
| 
       485 
     | 
    
         
            -
             
     | 
| 
       486 
     | 
    
         
            -
             
     | 
| 
       487 
     | 
    
         
            -
             
     | 
| 
       488 
     | 
    
         
            -
             
     | 
| 
       489 
     | 
    
         
            -
             
     | 
| 
       490 
     | 
    
         
            -
             
     | 
| 
       491 
     | 
    
         
            -
             
     | 
| 
       492 
     | 
    
         
            -
             
     | 
| 
       493 
     | 
    
         
            -
             
     | 
| 
       494 
     | 
    
         
            -
             
     | 
| 
       495 
     | 
    
         
            -
             
     | 
| 
       496 
     | 
    
         
            -
             
     | 
| 
       497 
     | 
    
         
            -
             
     | 
| 
       498 
     | 
    
         
            -
             
     | 
| 
      
 525 
     | 
    
         
            +
                  it 'handle any block' do
         
     | 
| 
      
 526 
     | 
    
         
            +
                    text = "this is normal line.\ncite {\n this block should be in cite. \n}"
         
     | 
| 
      
 527 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 528 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 529 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 530 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 531 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 532 
     | 
    
         
            +
                             ['div.pgroup',
         
     | 
| 
      
 533 
     | 
    
         
            +
                              ['p', 'this is normal line.']
         
     | 
| 
      
 534 
     | 
    
         
            +
                             ]
         
     | 
| 
      
 535 
     | 
    
         
            +
                             )
         
     | 
| 
      
 536 
     | 
    
         
            +
                    expect(body.element_children[1].selector_and_children)
         
     | 
| 
      
 537 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 538 
     | 
    
         
            +
                             ['cite',
         
     | 
| 
      
 539 
     | 
    
         
            +
                              ['div.pgroup',
         
     | 
| 
      
 540 
     | 
    
         
            +
                               ['p', 'this block should be in cite.']
         
     | 
| 
      
 541 
     | 
    
         
            +
                              ]
         
     | 
| 
      
 542 
     | 
    
         
            +
                             ]
         
     | 
| 
      
 543 
     | 
    
         
            +
                             )
         
     | 
| 
      
 544 
     | 
    
         
            +
                  end
         
     | 
| 
      
 545 
     | 
    
         
            +
                  it 'convert h1 in article after title' do
         
     | 
| 
      
 546 
     | 
    
         
            +
                    text = "---\nstylesheets: css/default.css\ntitle: foo\n---\narticle.atogaki {\n\nh1: あとがき。\n\natogaki\n}"
         
     | 
| 
      
 547 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 548 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 549 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 550 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 551 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 552 
     | 
    
         
            +
                             ["article.atogaki",
         
     | 
| 
      
 553 
     | 
    
         
            +
                              ["h1", "あとがき。"],
         
     | 
| 
      
 554 
     | 
    
         
            +
                              ["div.pgroup",
         
     | 
| 
      
 555 
     | 
    
         
            +
                               ["p", "atogaki"]]]
         
     | 
| 
      
 556 
     | 
    
         
            +
                             ) 
         
     | 
| 
      
 557 
     | 
    
         
            +
                  end
         
     | 
| 
       499 
558 
     | 
    
         | 
| 
       500 
     | 
    
         
            -
                it 'should handle custom paragraph' do
         
     | 
| 
       501 
     | 
    
         
            -
                  text = "this is normal line.\np.custom: this text is in custom class."
         
     | 
| 
       502 
     | 
    
         
            -
                  noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
       503 
     | 
    
         
            -
                  converted = noramark.html
         
     | 
| 
       504 
     | 
    
         
            -
                  body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
       505 
     | 
    
         
            -
                  expect(body.element_children[0].selector_and_children).to eq(
         
     | 
| 
       506 
     | 
    
         
            -
                  ['div.pgroup',
         
     | 
| 
       507 
     | 
    
         
            -
                   ['p', 'this is normal line.'],
         
     | 
| 
       508 
     | 
    
         
            -
                   ['p.custom', 'this text is in custom class.']
         
     | 
| 
       509 
     | 
    
         
            -
                  ]
         
     | 
| 
       510 
     | 
    
         
            -
                 )        
         
     | 
| 
       511 
559 
     | 
    
         
             
                end
         
     | 
| 
      
 560 
     | 
    
         
            +
                describe 'inline' do
         
     | 
| 
      
 561 
     | 
    
         
            +
                  it 'handle link' do
         
     | 
| 
      
 562 
     | 
    
         
            +
                    text = " link to [link(http://github.com/skoji/noramark){noramark repository}]. \ncan you see this?"
         
     | 
| 
      
 563 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 564 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 565 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 566 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 567 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 568 
     | 
    
         
            +
                             ['div.pgroup',
         
     | 
| 
      
 569 
     | 
    
         
            +
                              ['p',
         
     | 
| 
      
 570 
     | 
    
         
            +
                               'link to ',
         
     | 
| 
      
 571 
     | 
    
         
            +
                               ["a[href='http://github.com/skoji/noramark']", 'noramark repository'],
         
     | 
| 
      
 572 
     | 
    
         
            +
                               '.'
         
     | 
| 
      
 573 
     | 
    
         
            +
                              ],
         
     | 
| 
      
 574 
     | 
    
         
            +
                              ['p', 'can you see this?']
         
     | 
| 
      
 575 
     | 
    
         
            +
                             ]
         
     | 
| 
      
 576 
     | 
    
         
            +
                             )       
         
     | 
| 
      
 577 
     | 
    
         
            +
                  end
         
     | 
| 
       512 
578 
     | 
    
         | 
| 
       513 
     | 
    
         
            -
             
     | 
| 
       514 
     | 
    
         
            -
             
     | 
| 
       515 
     | 
    
         
            -
             
     | 
| 
       516 
     | 
    
         
            -
             
     | 
| 
       517 
     | 
    
         
            -
             
     | 
| 
       518 
     | 
    
         
            -
             
     | 
| 
       519 
     | 
    
         
            -
             
     | 
| 
       520 
     | 
    
         
            -
             
     | 
| 
       521 
     | 
    
         
            -
             
     | 
| 
       522 
     | 
    
         
            -
             
     | 
| 
       523 
     | 
    
         
            -
             
     | 
| 
      
 579 
     | 
    
         
            +
                  it 'handle link with l' do
         
     | 
| 
      
 580 
     | 
    
         
            +
                    text = "link to [l(http://github.com/skoji/noramark){noramark repository}]. \ncan you see this?"
         
     | 
| 
      
 581 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 582 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 583 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 584 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 585 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 586 
     | 
    
         
            +
                             ['div.pgroup',
         
     | 
| 
      
 587 
     | 
    
         
            +
                              ['p',
         
     | 
| 
      
 588 
     | 
    
         
            +
                               'link to ',
         
     | 
| 
      
 589 
     | 
    
         
            +
                               ["a[href='http://github.com/skoji/noramark']", 'noramark repository'],
         
     | 
| 
      
 590 
     | 
    
         
            +
                               '.'
         
     | 
| 
      
 591 
     | 
    
         
            +
                              ],
         
     | 
| 
      
 592 
     | 
    
         
            +
                              ['p', 'can you see this?']
         
     | 
| 
      
 593 
     | 
    
         
            +
                             ]
         
     | 
| 
      
 594 
     | 
    
         
            +
                             )       
         
     | 
| 
      
 595 
     | 
    
         
            +
                  end
         
     | 
| 
       524 
596 
     | 
    
         | 
| 
       525 
     | 
    
         
            -
             
     | 
| 
       526 
     | 
    
         
            -
             
     | 
| 
       527 
     | 
    
         
            -
             
     | 
| 
       528 
     | 
    
         
            -
             
     | 
| 
       529 
     | 
    
         
            -
             
     | 
| 
       530 
     | 
    
         
            -
             
     | 
| 
       531 
     | 
    
         
            -
             
     | 
| 
       532 
     | 
    
         
            -
             
     | 
| 
       533 
     | 
    
         
            -
             
     | 
| 
       534 
     | 
    
         
            -
             
     | 
| 
       535 
     | 
    
         
            -
             
     | 
| 
       536 
     | 
    
         
            -
             
     | 
| 
       537 
     | 
    
         
            -
                     ['div.pgroup',
         
     | 
| 
       538 
     | 
    
         
            -
                        ['p', 'this block should be in cite.']
         
     | 
| 
       539 
     | 
    
         
            -
                      ]
         
     | 
| 
       540 
     | 
    
         
            -
                    ]
         
     | 
| 
       541 
     | 
    
         
            -
                  )
         
     | 
| 
       542 
     | 
    
         
            -
                end
         
     | 
| 
      
 597 
     | 
    
         
            +
                  it 'handle span' do
         
     | 
| 
      
 598 
     | 
    
         
            +
                    text = "p.custom: this text is in [sp.keyword{custom}] class."
         
     | 
| 
      
 599 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 600 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 601 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 602 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 603 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 604 
     | 
    
         
            +
                             ['div.pgroup',
         
     | 
| 
      
 605 
     | 
    
         
            +
                              ['p.custom', 'this text is in ', ['span.keyword', 'custom'], ' class.'
         
     | 
| 
      
 606 
     | 
    
         
            +
                              ]]
         
     | 
| 
      
 607 
     | 
    
         
            +
                             )
         
     | 
| 
      
 608 
     | 
    
         
            +
                  end
         
     | 
| 
       543 
609 
     | 
    
         | 
| 
       544 
     | 
    
         
            -
             
     | 
| 
       545 
     | 
    
         
            -
             
     | 
| 
       546 
     | 
    
         
            -
             
     | 
| 
       547 
     | 
    
         
            -
             
     | 
| 
       548 
     | 
    
         
            -
             
     | 
| 
       549 
     | 
    
         
            -
             
     | 
| 
       550 
     | 
    
         
            -
             
     | 
| 
       551 
     | 
    
         
            -
             
     | 
| 
       552 
     | 
    
         
            -
             
     | 
| 
       553 
     | 
    
         
            -
             
     | 
| 
       554 
     | 
    
         
            -
             
     | 
| 
      
 610 
     | 
    
         
            +
                  it 'handle inline image' do
         
     | 
| 
      
 611 
     | 
    
         
            +
                    text = "simple image [img(./image1.jpg, alt)]."
         
     | 
| 
      
 612 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 613 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 614 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 615 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 616 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 617 
     | 
    
         
            +
                             ['div.pgroup',
         
     | 
| 
      
 618 
     | 
    
         
            +
                              ['p',
         
     | 
| 
      
 619 
     | 
    
         
            +
                               'simple image ', ["img[src='./image1.jpg'][alt='alt']", ''], '.']]
         
     | 
| 
      
 620 
     | 
    
         
            +
                             )
         
     | 
| 
      
 621 
     | 
    
         
            +
                  end
         
     | 
| 
       555 
622 
     | 
    
         | 
| 
       556 
     | 
    
         
            -
             
     | 
| 
       557 
     | 
    
         
            -
             
     | 
| 
       558 
     | 
    
         
            -
             
     | 
| 
       559 
     | 
    
         
            -
             
     | 
| 
       560 
     | 
    
         
            -
             
     | 
| 
       561 
     | 
    
         
            -
             
     | 
| 
       562 
     | 
    
         
            -
             
     | 
| 
       563 
     | 
    
         
            -
             
     | 
| 
       564 
     | 
    
         
            -
             
     | 
| 
       565 
     | 
    
         
            -
             
     | 
| 
      
 623 
     | 
    
         
            +
                  it 'handle any inline' do
         
     | 
| 
      
 624 
     | 
    
         
            +
                    text = "should be [strong{marked as strong}]."
         
     | 
| 
      
 625 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 626 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 627 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 628 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 629 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 630 
     | 
    
         
            +
                             ['div.pgroup',
         
     | 
| 
      
 631 
     | 
    
         
            +
                              ['p', 'should be ', ['strong', 'marked as strong'],'.']]
         
     | 
| 
      
 632 
     | 
    
         
            +
                             )
         
     | 
| 
      
 633 
     | 
    
         
            +
                  end
         
     | 
| 
       566 
634 
     | 
    
         | 
| 
       567 
     | 
    
         
            -
             
     | 
| 
       568 
     | 
    
         
            -
             
     | 
| 
       569 
     | 
    
         
            -
             
     | 
| 
       570 
     | 
    
         
            -
             
     | 
| 
       571 
     | 
    
         
            -
             
     | 
| 
       572 
     | 
    
         
            -
             
     | 
| 
       573 
     | 
    
         
            -
             
     | 
| 
      
 635 
     | 
    
         
            +
                  it 'convert inline command within line block' do
         
     | 
| 
      
 636 
     | 
    
         
            +
                    text = "h1: [tcy{20}]縦中横タイトル"
         
     | 
| 
      
 637 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 638 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 639 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 640 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children).to eq ['h1', ['span.tcy', '20'], '縦中横タイトル']
         
     | 
| 
      
 641 
     | 
    
         
            +
                  end
         
     | 
| 
       574 
642 
     | 
    
         | 
| 
       575 
     | 
    
         
            -
             
     | 
| 
       576 
     | 
    
         
            -
             
     | 
| 
       577 
     | 
    
         
            -
             
     | 
| 
       578 
     | 
    
         
            -
             
     | 
| 
       579 
     | 
    
         
            -
             
     | 
| 
       580 
     | 
    
         
            -
             
     | 
| 
       581 
     | 
    
         
            -
             
     | 
| 
       582 
     | 
    
         
            -
             
     | 
| 
       583 
     | 
    
         
            -
             
     | 
| 
       584 
     | 
    
         
            -
             
     | 
| 
       585 
     | 
    
         
            -
             
     | 
| 
      
 643 
     | 
    
         
            +
                  it 'handle ruby' do
         
     | 
| 
      
 644 
     | 
    
         
            +
                    text = "[ruby(とんぼ){蜻蛉}]の[ruby(めがね){眼鏡}]はみずいろめがね"
         
     | 
| 
      
 645 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 646 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 647 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 648 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children).to eq ['div.pgroup', ['p', 
         
     | 
| 
      
 649 
     | 
    
         
            +
                                                                                                 ['ruby', '蜻蛉', ['rp','('],['rt','とんぼ'],['rp', ')']],
         
     | 
| 
      
 650 
     | 
    
         
            +
                                                                                                 'の',                                                                                   
         
     | 
| 
      
 651 
     | 
    
         
            +
                                                                                                 ['ruby', '眼鏡', ['rp','('],['rt','めがね'],['rp', ')']],
         
     | 
| 
      
 652 
     | 
    
         
            +
                                                                                                 'はみずいろめがね']]
         
     | 
| 
      
 653 
     | 
    
         
            +
                  end
         
     | 
| 
       586 
654 
     | 
    
         | 
| 
       587 
     | 
    
         
            -
             
     | 
| 
       588 
     | 
    
         
            -
             
     | 
| 
       589 
     | 
    
         
            -
             
     | 
| 
       590 
     | 
    
         
            -
             
     | 
| 
       591 
     | 
    
         
            -
             
     | 
| 
       592 
     | 
    
         
            -
             
     | 
| 
       593 
     | 
    
         
            -
             
     | 
| 
       594 
     | 
    
         
            -
             
     | 
| 
       595 
     | 
    
         
            -
             
     | 
| 
       596 
     | 
    
         
            -
             
     | 
| 
      
 655 
     | 
    
         
            +
                  it 'handle tatechuyoko' do
         
     | 
| 
      
 656 
     | 
    
         
            +
                    text = "[tcy{10}]年前のことだった"
         
     | 
| 
      
 657 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 658 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 659 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 660 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 661 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 662 
     | 
    
         
            +
                             ['div.pgroup', 
         
     | 
| 
      
 663 
     | 
    
         
            +
                              ['p', ['span.tcy', '10'], '年前のことだった']
         
     | 
| 
      
 664 
     | 
    
         
            +
                             ])
         
     | 
| 
      
 665 
     | 
    
         
            +
                  end
         
     | 
| 
       597 
666 
     | 
    
         | 
| 
       598 
     | 
    
         
            -
             
     | 
| 
       599 
     | 
    
         
            -
             
     | 
| 
       600 
     | 
    
         
            -
             
     | 
| 
       601 
     | 
    
         
            -
             
     | 
| 
       602 
     | 
    
         
            -
             
     | 
| 
       603 
     | 
    
         
            -
             
     | 
| 
       604 
     | 
    
         
            -
             
     | 
| 
       605 
     | 
    
         
            -
             
     | 
| 
       606 
     | 
    
         
            -
             
     | 
| 
       607 
     | 
    
         
            -
             
     | 
| 
       608 
     | 
    
         
            -
                   
     | 
| 
       609 
     | 
    
         
            -
             
     | 
| 
       610 
     | 
    
         
            -
             
     | 
| 
       611 
     | 
    
         
            -
             
     | 
| 
       612 
     | 
    
         
            -
             
     | 
| 
       613 
     | 
    
         
            -
                    ])
         
     | 
| 
       614 
     | 
    
         
            -
             
     | 
| 
       615 
     | 
    
         
            -
             
     | 
| 
       616 
     | 
    
         
            -
             
     | 
| 
       617 
     | 
    
         
            -
             
     | 
| 
      
 667 
     | 
    
         
            +
                  it 'handle code inline' do
         
     | 
| 
      
 668 
     | 
    
         
            +
                    text = "`this is inside code and [s{will not parsed}]`. you see?"
         
     | 
| 
      
 669 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 670 
     | 
    
         
            +
                    converted = noramark.html        
         
     | 
| 
      
 671 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 672 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 673 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 674 
     | 
    
         
            +
                             ['div.pgroup', 
         
     | 
| 
      
 675 
     | 
    
         
            +
                              ['p', ['code', 'this is inside code and [s{will not parsed}]'], '. you see?']
         
     | 
| 
      
 676 
     | 
    
         
            +
                             ])
         
     | 
| 
      
 677 
     | 
    
         
            +
                  end
         
     | 
| 
      
 678 
     | 
    
         
            +
                  it 'handle code escaped inline' do
         
     | 
| 
      
 679 
     | 
    
         
            +
                    text = "\\`this is not inside code and [strong{will be parsed}]\\`. you see?"
         
     | 
| 
      
 680 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 681 
     | 
    
         
            +
                    converted = noramark.html        
         
     | 
| 
      
 682 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 683 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 684 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 685 
     | 
    
         
            +
                             ['div.pgroup', 
         
     | 
| 
      
 686 
     | 
    
         
            +
                              ['p', '`this is not inside code and ', ['strong', 'will be parsed'], '`. you see?']
         
     | 
| 
      
 687 
     | 
    
         
            +
                             ])
         
     | 
| 
      
 688 
     | 
    
         
            +
                  end
         
     | 
| 
      
 689 
     | 
    
         
            +
                  it 'handle code inline (long format)' do
         
     | 
| 
      
 690 
     | 
    
         
            +
                    text = "[code.the-class{this is inside code and `backquote will not be parsed`}]. you see?"
         
     | 
| 
      
 691 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 692 
     | 
    
         
            +
                    converted = noramark.html        
         
     | 
| 
      
 693 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 694 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 695 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 696 
     | 
    
         
            +
                             ['div.pgroup', 
         
     | 
| 
      
 697 
     | 
    
         
            +
                              ['p', ['code.the-class', 'this is inside code and `backquote will not be parsed`'], '. you see?']
         
     | 
| 
      
 698 
     | 
    
         
            +
                             ])
         
     | 
| 
      
 699 
     | 
    
         
            +
                  end
         
     | 
| 
       618 
700 
     | 
    
         
             
                end
         
     | 
| 
      
 701 
     | 
    
         
            +
                describe 'list' do
         
     | 
| 
      
 702 
     | 
    
         
            +
                  it 'handle ordered list ' do
         
     | 
| 
      
 703 
     | 
    
         
            +
                    text = "this is normal line.\n1. for the 1st.\n2. secondly, blah.\n3. and last...\nthe ordered list ends."
         
     | 
| 
      
 704 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 705 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 706 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 707 
     | 
    
         
            +
                    expect(body.element_children.size).to eq 3
         
     | 
| 
      
 708 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 709 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 710 
     | 
    
         
            +
                             ['div.pgroup', 
         
     | 
| 
      
 711 
     | 
    
         
            +
                              ['p', 'this is normal line.']
         
     | 
| 
      
 712 
     | 
    
         
            +
                             ])
         
     | 
| 
      
 713 
     | 
    
         
            +
                    expect(body.element_children[1].selector_and_children)
         
     | 
| 
      
 714 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 715 
     | 
    
         
            +
                             ['ol', 
         
     | 
| 
      
 716 
     | 
    
         
            +
                              ['li', 'for the 1st.'],
         
     | 
| 
      
 717 
     | 
    
         
            +
                              ['li', 'secondly, blah.'],
         
     | 
| 
      
 718 
     | 
    
         
            +
                              ['li', 'and last...']
         
     | 
| 
      
 719 
     | 
    
         
            +
                             ])
         
     | 
| 
      
 720 
     | 
    
         
            +
                    expect(body.element_children[2].selector_and_children)
         
     | 
| 
      
 721 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 722 
     | 
    
         
            +
                             ['div.pgroup', 
         
     | 
| 
      
 723 
     | 
    
         
            +
                              ['p', 'the ordered list ends.']
         
     | 
| 
      
 724 
     | 
    
         
            +
                             ])
         
     | 
| 
      
 725 
     | 
    
         
            +
                  end
         
     | 
| 
       619 
726 
     | 
    
         | 
| 
       620 
     | 
    
         
            -
             
     | 
| 
       621 
     | 
    
         
            -
             
     | 
| 
       622 
     | 
    
         
            -
             
     | 
| 
       623 
     | 
    
         
            -
             
     | 
| 
       624 
     | 
    
         
            -
             
     | 
| 
       625 
     | 
    
         
            -
             
     | 
| 
       626 
     | 
    
         
            -
             
     | 
| 
       627 
     | 
    
         
            -
             
     | 
| 
       628 
     | 
    
         
            -
             
     | 
| 
       629 
     | 
    
         
            -
             
     | 
| 
       630 
     | 
    
         
            -
             
     | 
| 
       631 
     | 
    
         
            -
                    [ 
     | 
| 
       632 
     | 
    
         
            -
             
     | 
| 
       633 
     | 
    
         
            -
             
     | 
| 
       634 
     | 
    
         
            -
             
     | 
| 
       635 
     | 
    
         
            -
             
     | 
| 
       636 
     | 
    
         
            -
             
     | 
| 
       637 
     | 
    
         
            -
             
     | 
| 
       638 
     | 
    
         
            -
             
     | 
| 
       639 
     | 
    
         
            -
             
     | 
| 
       640 
     | 
    
         
            -
             
     | 
| 
      
 727 
     | 
    
         
            +
                  it 'handle unordered list ' do
         
     | 
| 
      
 728 
     | 
    
         
            +
                    text = "this is normal line.\n* for the 1st.\n* secondly, blah.\n* and last...\nthe ordered list ends."
         
     | 
| 
      
 729 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 730 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 731 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 732 
     | 
    
         
            +
                    expect(body.element_children.size).to eq 3
         
     | 
| 
      
 733 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 734 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 735 
     | 
    
         
            +
                             ['div.pgroup', 
         
     | 
| 
      
 736 
     | 
    
         
            +
                              ['p', 'this is normal line.']
         
     | 
| 
      
 737 
     | 
    
         
            +
                             ])
         
     | 
| 
      
 738 
     | 
    
         
            +
                    expect(body.element_children[1].selector_and_children)
         
     | 
| 
      
 739 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 740 
     | 
    
         
            +
                             ['ul', 
         
     | 
| 
      
 741 
     | 
    
         
            +
                              ['li', 'for the 1st.'],
         
     | 
| 
      
 742 
     | 
    
         
            +
                              ['li', 'secondly, blah.'],
         
     | 
| 
      
 743 
     | 
    
         
            +
                              ['li', 'and last...']
         
     | 
| 
      
 744 
     | 
    
         
            +
                             ])
         
     | 
| 
      
 745 
     | 
    
         
            +
                    expect(body.element_children[2].selector_and_children)
         
     | 
| 
      
 746 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 747 
     | 
    
         
            +
                             ['div.pgroup', 
         
     | 
| 
      
 748 
     | 
    
         
            +
                              ['p', 'the ordered list ends.']
         
     | 
| 
      
 749 
     | 
    
         
            +
                             ])
         
     | 
| 
      
 750 
     | 
    
         
            +
                  end
         
     | 
| 
       641 
751 
     | 
    
         | 
| 
       642 
     | 
    
         
            -
             
     | 
| 
       643 
     | 
    
         
            -
             
     | 
| 
       644 
     | 
    
         
            -
             
     | 
| 
       645 
     | 
    
         
            -
             
     | 
| 
       646 
     | 
    
         
            -
             
     | 
| 
       647 
     | 
    
         
            -
             
     | 
| 
       648 
     | 
    
         
            -
             
     | 
| 
       649 
     | 
    
         
            -
             
     | 
| 
       650 
     | 
    
         
            -
             
     | 
| 
       651 
     | 
    
         
            -
             
     | 
| 
       652 
     | 
    
         
            -
             
     | 
| 
       653 
     | 
    
         
            -
                    [ 
     | 
| 
       654 
     | 
    
         
            -
             
     | 
| 
       655 
     | 
    
         
            -
             
     | 
| 
       656 
     | 
    
         
            -
             
     | 
| 
       657 
     | 
    
         
            -
             
     | 
| 
       658 
     | 
    
         
            -
             
     | 
| 
       659 
     | 
    
         
            -
             
     | 
| 
       660 
     | 
    
         
            -
             
     | 
| 
       661 
     | 
    
         
            -
                    ])
         
     | 
| 
       662 
     | 
    
         
            -
             
     | 
| 
      
 752 
     | 
    
         
            +
                  it 'handle nested unordered list ' do
         
     | 
| 
      
 753 
     | 
    
         
            +
                    text = "this is normal line.\n* for the 1st.\n** nested.\n* and last...\nthe ordered list ends."
         
     | 
| 
      
 754 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 755 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 756 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 757 
     | 
    
         
            +
                    expect(body.element_children.size).to eq 3
         
     | 
| 
      
 758 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 759 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 760 
     | 
    
         
            +
                             ['div.pgroup', 
         
     | 
| 
      
 761 
     | 
    
         
            +
                              ['p', 'this is normal line.']
         
     | 
| 
      
 762 
     | 
    
         
            +
                             ])
         
     | 
| 
      
 763 
     | 
    
         
            +
                    expect(body.element_children[1].selector_and_children)
         
     | 
| 
      
 764 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 765 
     | 
    
         
            +
                             ['ul', 
         
     | 
| 
      
 766 
     | 
    
         
            +
                              ['li', 'for the 1st.',
         
     | 
| 
      
 767 
     | 
    
         
            +
                               ['ul', 
         
     | 
| 
      
 768 
     | 
    
         
            +
                                ['li', 'nested.']]],
         
     | 
| 
      
 769 
     | 
    
         
            +
                              ['li', 'and last...']
         
     | 
| 
      
 770 
     | 
    
         
            +
                             ])
         
     | 
| 
      
 771 
     | 
    
         
            +
                    expect(body.element_children[2].selector_and_children)
         
     | 
| 
      
 772 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 773 
     | 
    
         
            +
                             ['div.pgroup', 
         
     | 
| 
      
 774 
     | 
    
         
            +
                              ['p', 'the ordered list ends.']
         
     | 
| 
      
 775 
     | 
    
         
            +
                             ])
         
     | 
| 
      
 776 
     | 
    
         
            +
                  end
         
     | 
| 
       663 
777 
     | 
    
         | 
| 
       664 
     | 
    
         
            -
             
     | 
| 
       665 
     | 
    
         
            -
             
     | 
| 
       666 
     | 
    
         
            -
             
     | 
| 
       667 
     | 
    
         
            -
             
     | 
| 
       668 
     | 
    
         
            -
             
     | 
| 
       669 
     | 
    
         
            -
             
     | 
| 
       670 
     | 
    
         
            -
             
     | 
| 
       671 
     | 
    
         
            -
             
     | 
| 
       672 
     | 
    
         
            -
             
     | 
| 
       673 
     | 
    
         
            -
             
     | 
| 
       674 
     | 
    
         
            -
             
     | 
| 
       675 
     | 
    
         
            -
                    [ 
     | 
| 
       676 
     | 
    
         
            -
             
     | 
| 
       677 
     | 
    
         
            -
             
     | 
| 
       678 
     | 
    
         
            -
             
     | 
| 
       679 
     | 
    
         
            -
             
     | 
| 
       680 
     | 
    
         
            -
             
     | 
| 
       681 
     | 
    
         
            -
             
     | 
| 
       682 
     | 
    
         
            -
             
     | 
| 
       683 
     | 
    
         
            -
             
     | 
| 
       684 
     | 
    
         
            -
             
     | 
| 
      
 778 
     | 
    
         
            +
                  it 'handle definition list ' do
         
     | 
| 
      
 779 
     | 
    
         
            +
                    text = "this is normal line.\n;: 1st : this is the first definition\n;: 2nd : blah :blah.\n;: 3rd: this term is the last.\nthe list ends."
         
     | 
| 
      
 780 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 781 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 782 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 783 
     | 
    
         
            +
                    expect(body.element_children.size).to eq 3
         
     | 
| 
      
 784 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 785 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 786 
     | 
    
         
            +
                             ['div.pgroup', 
         
     | 
| 
      
 787 
     | 
    
         
            +
                              ['p', 'this is normal line.']
         
     | 
| 
      
 788 
     | 
    
         
            +
                             ])
         
     | 
| 
      
 789 
     | 
    
         
            +
                    expect(body.element_children[1].selector_and_children)
         
     | 
| 
      
 790 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 791 
     | 
    
         
            +
                             ['dl', 
         
     | 
| 
      
 792 
     | 
    
         
            +
                              ['dt', '1st'],['dd', 'this is the first definition'],
         
     | 
| 
      
 793 
     | 
    
         
            +
                              ['dt', '2nd'],['dd', 'blah :blah.'],
         
     | 
| 
      
 794 
     | 
    
         
            +
                              ['dt', '3rd'],['dd', 'this term is the last.'],
         
     | 
| 
      
 795 
     | 
    
         
            +
                             ])
         
     | 
| 
      
 796 
     | 
    
         
            +
                    expect(body.element_children[2].selector_and_children)
         
     | 
| 
      
 797 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 798 
     | 
    
         
            +
                             ['div.pgroup', 
         
     | 
| 
      
 799 
     | 
    
         
            +
                              ['p', 'the list ends.']
         
     | 
| 
      
 800 
     | 
    
         
            +
                             ])
         
     | 
| 
      
 801 
     | 
    
         
            +
                  end
         
     | 
| 
       685 
802 
     | 
    
         | 
| 
       686 
     | 
    
         
            -
             
     | 
| 
       687 
     | 
    
         
            -
             
     | 
| 
       688 
     | 
    
         
            -
             
     | 
| 
       689 
     | 
    
         
            -
             
     | 
| 
       690 
     | 
    
         
            -
             
     | 
| 
       691 
     | 
    
         
            -
             
     | 
| 
       692 
     | 
    
         
            -
                    [ 
     | 
| 
       693 
     | 
    
         
            -
             
     | 
| 
       694 
     | 
    
         
            -
             
     | 
| 
      
 803 
     | 
    
         
            +
                  it 'handle long definition list ' do
         
     | 
| 
      
 804 
     | 
    
         
            +
                    text = "this is normal line.\n;: 1st {\n this is the first definition\n}\n;: 2nd { \nblah :blah.\n}\n;: 3rd{\n this term is the last.\n}\nthe list ends."
         
     | 
| 
      
 805 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 806 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 807 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 808 
     | 
    
         
            +
                    expect(body.element_children.size).to eq 3
         
     | 
| 
      
 809 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 810 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 811 
     | 
    
         
            +
                             ['div.pgroup', 
         
     | 
| 
      
 812 
     | 
    
         
            +
                              ['p', 'this is normal line.']
         
     | 
| 
      
 813 
     | 
    
         
            +
                             ])
         
     | 
| 
      
 814 
     | 
    
         
            +
                    expect(body.element_children[1].selector_and_children)
         
     | 
| 
      
 815 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 816 
     | 
    
         
            +
                             ['dl', 
         
     | 
| 
      
 817 
     | 
    
         
            +
                              ['dt', '1st'],['dd', ['div.pgroup', ['p', 'this is the first definition']]],
         
     | 
| 
      
 818 
     | 
    
         
            +
                              ['dt', '2nd'],['dd', ['div.pgroup', ['p', 'blah :blah.']]],
         
     | 
| 
      
 819 
     | 
    
         
            +
                              ['dt', '3rd'],['dd', ['div.pgroup', ['p', 'this term is the last.']]]
         
     | 
| 
      
 820 
     | 
    
         
            +
                             ])
         
     | 
| 
      
 821 
     | 
    
         
            +
                    expect(body.element_children[2].selector_and_children)
         
     | 
| 
      
 822 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 823 
     | 
    
         
            +
                             ['div.pgroup', 
         
     | 
| 
      
 824 
     | 
    
         
            +
                              ['p', 'the list ends.']
         
     | 
| 
      
 825 
     | 
    
         
            +
                             ])
         
     | 
| 
      
 826 
     | 
    
         
            +
                  end
         
     | 
| 
      
 827 
     | 
    
         
            +
                  it 'escape html in definition list' do
         
     | 
| 
      
 828 
     | 
    
         
            +
                    text = ";:definition<div>:</div>"
         
     | 
| 
      
 829 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 830 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 831 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 832 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 833 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 834 
     | 
    
         
            +
                             ['dl', 
         
     | 
| 
      
 835 
     | 
    
         
            +
                              ['dt', 'definition<div>'],['dd', '</div>']
         
     | 
| 
      
 836 
     | 
    
         
            +
                             ])
         
     | 
| 
      
 837 
     | 
    
         
            +
                  end
         
     | 
| 
       695 
838 
     | 
    
         
             
                end
         
     | 
| 
       696 
     | 
    
         
            -
             
     | 
| 
       697 
     | 
    
         
            -
                 
     | 
| 
       698 
     | 
    
         
            -
                   
     | 
| 
      
 839 
     | 
    
         
            +
                
         
     | 
| 
      
 840 
     | 
    
         
            +
                describe 'metadata' do
         
     | 
| 
      
 841 
     | 
    
         
            +
                  it 'specify stylesheets' do
         
     | 
| 
      
 842 
     | 
    
         
            +
                    text = <<EOF
         
     | 
| 
       699 
843 
     | 
    
         
             
            ---
         
     | 
| 
       700 
844 
     | 
    
         
             
            stylesheets: [ css/default.css, css/specific.css, [ css/iphone.css, 'only screen and (min-device-width : 320px) and (max-device-width : 480px)']]
         
     | 
| 
       701 
845 
     | 
    
         
             
            ---
         
     | 
| 
       702 
846 
     | 
    
         
             
            text.
         
     | 
| 
       703 
847 
     | 
    
         | 
| 
       704 
848 
     | 
    
         
             
            EOF
         
     | 
| 
       705 
     | 
    
         
            -
             
     | 
| 
       706 
     | 
    
         
            -
             
     | 
| 
       707 
     | 
    
         
            -
             
     | 
| 
       708 
     | 
    
         
            -
             
     | 
| 
       709 
     | 
    
         
            -
             
     | 
| 
       710 
     | 
    
         
            -
             
     | 
| 
       711 
     | 
    
         
            -
             
     | 
| 
      
 849 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the document title')
         
     | 
| 
      
 850 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 851 
     | 
    
         
            +
                    head = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:head')
         
     | 
| 
      
 852 
     | 
    
         
            +
                    expect(head.element_children[0].a).to eq ['title', 'the document title']
         
     | 
| 
      
 853 
     | 
    
         
            +
                    expect(head.element_children[1].a).to eq ["link[rel='stylesheet'][type='text/css'][href='css/default.css']", '']
         
     | 
| 
      
 854 
     | 
    
         
            +
                    expect(head.element_children[2].a).to eq ["link[rel='stylesheet'][type='text/css'][href='css/specific.css']", '']
         
     | 
| 
      
 855 
     | 
    
         
            +
                    expect(head.element_children[3].a).to eq ["link[rel='stylesheet'][type='text/css'][media='only screen and (min-device-width : 320px) and (max-device-width : 480px)'][href='css/iphone.css']", '']
         
     | 
| 
       712 
856 
     | 
    
         | 
| 
       713 
     | 
    
         
            -
             
     | 
| 
       714 
     | 
    
         
            -
             
     | 
| 
       715 
     | 
    
         
            -
             
     | 
| 
       716 
     | 
    
         
            -
             
     | 
| 
       717 
     | 
    
         
            -
             
     | 
| 
       718 
     | 
    
         
            -
             
     | 
| 
      
 857 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 858 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 859 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 860 
     | 
    
         
            +
                             ['div.pgroup',
         
     | 
| 
      
 861 
     | 
    
         
            +
                              ['p',
         
     | 
| 
      
 862 
     | 
    
         
            +
                               'text.']])
         
     | 
| 
      
 863 
     | 
    
         
            +
                  end
         
     | 
| 
       719 
864 
     | 
    
         | 
| 
       720 
     | 
    
         
            -
             
     | 
| 
       721 
     | 
    
         
            -
             
     | 
| 
       722 
     | 
    
         
            -
             
     | 
| 
       723 
     | 
    
         
            -
             
     | 
| 
       724 
     | 
    
         
            -
             
     | 
| 
       725 
     | 
    
         
            -
             
     | 
| 
       726 
     | 
    
         
            -
             
     | 
| 
       727 
     | 
    
         
            -
             
     | 
| 
       728 
     | 
    
         
            -
             
     | 
| 
       729 
     | 
    
         
            -
             
     | 
| 
       730 
     | 
    
         
            -
             
     | 
| 
      
 865 
     | 
    
         
            +
                  it 'specify title' do
         
     | 
| 
      
 866 
     | 
    
         
            +
                    text = "---\ntitle: the title of the book in the text.\n---\n\ntext."
         
     | 
| 
      
 867 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 868 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 869 
     | 
    
         
            +
                    head = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:head')
         
     | 
| 
      
 870 
     | 
    
         
            +
                    expect(head.element_children[0].a).to eq ['title', 'the title of the book in the text.']
         
     | 
| 
      
 871 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 872 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 873 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 874 
     | 
    
         
            +
                             ['div.pgroup',
         
     | 
| 
      
 875 
     | 
    
         
            +
                              ['p',
         
     | 
| 
      
 876 
     | 
    
         
            +
                               'text.']])
         
     | 
| 
       731 
877 
     | 
    
         | 
| 
       732 
     | 
    
         
            -
             
     | 
| 
      
 878 
     | 
    
         
            +
                  end
         
     | 
| 
       733 
879 
     | 
    
         | 
| 
       734 
     | 
    
         
            -
             
     | 
| 
       735 
     | 
    
         
            -
             
     | 
| 
       736 
     | 
    
         
            -
             
     | 
| 
       737 
     | 
    
         
            -
             
     | 
| 
       738 
     | 
    
         
            -
                  # 1st page
         
     | 
| 
       739 
     | 
    
         
            -
                  head = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:head')
         
     | 
| 
       740 
     | 
    
         
            -
                  expect(head.element_children[0].a).to eq ['title', 'page1']
         
     | 
| 
       741 
     | 
    
         
            -
                  body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
       742 
     | 
    
         
            -
                  expect(body.element_children[0].selector_and_children).to eq(
         
     | 
| 
       743 
     | 
    
         
            -
                    ['div.pgroup',
         
     | 
| 
       744 
     | 
    
         
            -
                      ['p',
         
     | 
| 
       745 
     | 
    
         
            -
                        '1st page.']])
         
     | 
| 
       746 
     | 
    
         
            -
                  # 2nd page
         
     | 
| 
       747 
     | 
    
         
            -
                  head = Nokogiri::XML::Document.parse(converted[1]).root.at_xpath('xmlns:head')
         
     | 
| 
       748 
     | 
    
         
            -
                  expect(head.element_children[0].a).to eq ['title', 'page2']
         
     | 
| 
       749 
     | 
    
         
            -
                  body = Nokogiri::XML::Document.parse(converted[1]).root.at_xpath('xmlns:body')
         
     | 
| 
       750 
     | 
    
         
            -
                  expect(body.element_children[0].selector_and_children).to eq(
         
     | 
| 
       751 
     | 
    
         
            -
                    ['h1',"2nd page"])
         
     | 
| 
       752 
     | 
    
         
            -
                end
         
     | 
| 
      
 880 
     | 
    
         
            +
                  it 'specify title on each page' do
         
     | 
| 
      
 881 
     | 
    
         
            +
                    text = "---\ntitle: page1\n---\n\n1st page.\nnewpage:\n---\ntitle: page2\n---\nh1:2nd page"
         
     | 
| 
      
 882 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title', paragraph_style: :use_paragraph_group)
         
     | 
| 
      
 883 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
       753 
884 
     | 
    
         | 
| 
      
 885 
     | 
    
         
            +
                    # 1st page
         
     | 
| 
      
 886 
     | 
    
         
            +
                    head = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:head')
         
     | 
| 
      
 887 
     | 
    
         
            +
                    expect(head.element_children[0].a).to eq ['title', 'page1']
         
     | 
| 
      
 888 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 889 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 890 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 891 
     | 
    
         
            +
                             ['div.pgroup',
         
     | 
| 
      
 892 
     | 
    
         
            +
                              ['p',
         
     | 
| 
      
 893 
     | 
    
         
            +
                               '1st page.']])
         
     | 
| 
      
 894 
     | 
    
         
            +
                    # 2nd page
         
     | 
| 
      
 895 
     | 
    
         
            +
                    head = Nokogiri::XML::Document.parse(converted[1]).root.at_xpath('xmlns:head')
         
     | 
| 
      
 896 
     | 
    
         
            +
                    expect(head.element_children[0].a).to eq ['title', 'page2']
         
     | 
| 
      
 897 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[1]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 898 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 899 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 900 
     | 
    
         
            +
                             ['h1',"2nd page"])
         
     | 
| 
      
 901 
     | 
    
         
            +
                  end
         
     | 
| 
       754 
902 
     | 
    
         | 
| 
       755 
     | 
    
         
            -
             
     | 
| 
       756 
     | 
    
         
            -
             
     | 
| 
       757 
     | 
    
         
            -
             
     | 
| 
       758 
     | 
    
         
            -
             
     | 
| 
       759 
     | 
    
         
            -
             
     | 
| 
       760 
     | 
    
         
            -
             
     | 
| 
       761 
     | 
    
         
            -
             
     | 
| 
       762 
     | 
    
         
            -
                  expect(body.element_children[0].selector_and_children).to eq(
         
     | 
| 
       763 
     | 
    
         
            -
                    ['div.pgroup', 
         
     | 
| 
       764 
     | 
    
         
            -
                     ['p', 'ここから、パラグラフがはじまります。'],
         
     | 
| 
       765 
     | 
    
         
            -
                     ['p.noindent', '「二行目です。」'],
         
     | 
| 
       766 
     | 
    
         
            -
                     ['p', '三行目です。']
         
     | 
| 
       767 
     | 
    
         
            -
                    ]
         
     | 
| 
       768 
     | 
    
         
            -
                  )
         
     | 
| 
       769 
     | 
    
         
            -
             
     | 
| 
       770 
     | 
    
         
            -
                  expect(body.element_children[1].selector_and_children).to eq(
         
     | 
| 
       771 
     | 
    
         
            -
                    ['div.pgroup',
         
     | 
| 
       772 
     | 
    
         
            -
                      ['p', 'ここから、次のパラグラフです。']]
         
     | 
| 
       773 
     | 
    
         
            -
                  )
         
     | 
| 
       774 
     | 
    
         
            -
                end
         
     | 
| 
      
 903 
     | 
    
         
            +
                  it 'ignore comments' do
         
     | 
| 
      
 904 
     | 
    
         
            +
                    text = "// この行はコメントです\nここから、パラグラフがはじまります。\n // これもコメント\n「二行目です。」\n三行目です。\n\n// これもコメント\n\n ここから、次のパラグラフです。\n// 最後のコメントです"
         
     | 
| 
      
 905 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 906 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 907 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 908 
     | 
    
         
            +
                    expect(body.element_children.size).to eq 2
         
     | 
| 
       775 
909 
     | 
    
         | 
| 
       776 
     | 
    
         
            -
             
     | 
| 
       777 
     | 
    
         
            -
             
     | 
| 
       778 
     | 
    
         
            -
             
     | 
| 
       779 
     | 
    
         
            -
             
     | 
| 
       780 
     | 
    
         
            -
             
     | 
| 
       781 
     | 
    
         
            -
             
     | 
| 
       782 
     | 
    
         
            -
             
     | 
| 
       783 
     | 
    
         
            -
             
     | 
| 
      
 910 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 911 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 912 
     | 
    
         
            +
                             ['div.pgroup', 
         
     | 
| 
      
 913 
     | 
    
         
            +
                              ['p', 'ここから、パラグラフがはじまります。'],
         
     | 
| 
      
 914 
     | 
    
         
            +
                              ['p.noindent', '「二行目です。」'],
         
     | 
| 
      
 915 
     | 
    
         
            +
                              ['p', '三行目です。']
         
     | 
| 
      
 916 
     | 
    
         
            +
                             ]
         
     | 
| 
      
 917 
     | 
    
         
            +
                             )
         
     | 
| 
      
 918 
     | 
    
         
            +
             
     | 
| 
      
 919 
     | 
    
         
            +
                    expect(body.element_children[1].selector_and_children)
         
     | 
| 
      
 920 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 921 
     | 
    
         
            +
                             ['div.pgroup',
         
     | 
| 
      
 922 
     | 
    
         
            +
                              ['p', 'ここから、次のパラグラフです。']]
         
     | 
| 
      
 923 
     | 
    
         
            +
                             )
         
     | 
| 
       784 
924 
     | 
    
         
             
                  end
         
     | 
| 
       785 
     | 
    
         
            -
                  converted = noramark.html
         
     | 
| 
       786 
     | 
    
         
            -
                  body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
       787 
     | 
    
         
            -
                  expect(body.element_children[0].selector_and_children).to eq(
         
     | 
| 
       788 
     | 
    
         
            -
                    ['div.pgroup', 
         
     | 
| 
       789 
     | 
    
         
            -
                     ['p', 'post-process text'],
         
     | 
| 
       790 
     | 
    
         
            -
                    ]
         
     | 
| 
       791 
     | 
    
         
            -
                  )
         
     | 
| 
       792 
     | 
    
         
            -
                end
         
     | 
| 
       793 
925 
     | 
    
         | 
| 
       794 
     | 
    
         
            -
             
     | 
| 
       795 
     | 
    
         
            -
             
     | 
| 
       796 
     | 
    
         
            -
             
     | 
| 
       797 
     | 
    
         
            -
             
     | 
| 
       798 
     | 
    
         
            -
             
     | 
| 
       799 
     | 
    
         
            -
             
     | 
| 
       800 
     | 
    
         
            -
             
     | 
| 
       801 
     | 
    
         
            -
             
     | 
| 
       802 
     | 
    
         
            -
             
     | 
| 
       803 
     | 
    
         
            -
             
     | 
| 
       804 
     | 
    
         
            -
             
     | 
| 
      
 926 
     | 
    
         
            +
                  it 'handle preprocessor' do
         
     | 
| 
      
 927 
     | 
    
         
            +
                    text = "pre-preprocess text"
         
     | 
| 
      
 928 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title') do
         
     | 
| 
      
 929 
     | 
    
         
            +
                      |nora|
         
     | 
| 
      
 930 
     | 
    
         
            +
                      nora.preprocessor do
         
     | 
| 
      
 931 
     | 
    
         
            +
                        |t|
         
     | 
| 
      
 932 
     | 
    
         
            +
                        t.gsub('pre-preprocess', 'post-process')
         
     | 
| 
      
 933 
     | 
    
         
            +
                      end
         
     | 
| 
      
 934 
     | 
    
         
            +
                    end
         
     | 
| 
      
 935 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 936 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 937 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 938 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 939 
     | 
    
         
            +
                             ['div.pgroup', 
         
     | 
| 
      
 940 
     | 
    
         
            +
                              ['p', 'post-process text'],
         
     | 
| 
      
 941 
     | 
    
         
            +
                             ]
         
     | 
| 
      
 942 
     | 
    
         
            +
                             )
         
     | 
| 
      
 943 
     | 
    
         
            +
                  end
         
     | 
| 
       805 
944 
     | 
    
         
             
                end
         
     | 
| 
       806 
945 
     | 
    
         | 
| 
       807 
     | 
    
         
            -
                 
     | 
| 
       808 
     | 
    
         
            -
                  text  
     | 
| 
      
 946 
     | 
    
         
            +
                describe 'preformatted' do
         
     | 
| 
      
 947 
     | 
    
         
            +
                  it 'convert preformatted text' do
         
     | 
| 
      
 948 
     | 
    
         
            +
                    text = <<EOF
         
     | 
| 
       809 
949 
     | 
    
         
             
            normal line.
         
     | 
| 
       810 
950 
     | 
    
         
             
              pre {//
         
     | 
| 
       811 
951 
     | 
    
         
             
            d {
         
     | 
| 
       812 
952 
     | 
    
         
             
               this will not converted to div or p or pgroup.
         
     | 
| 
      
 953 
     | 
    
         
            +
             
     | 
| 
       813 
954 
     | 
    
         
             
            line_command: this will be not converted too.
         
     | 
| 
       814 
955 
     | 
    
         
             
            }
         
     | 
| 
       815 
956 
     | 
    
         
             
              //}
         
     | 
| 
      
 957 
     | 
    
         
            +
            normal line again.
         
     | 
| 
       816 
958 
     | 
    
         
             
            EOF
         
     | 
| 
       817 
     | 
    
         
            -
             
     | 
| 
       818 
     | 
    
         
            -
             
     | 
| 
       819 
     | 
    
         
            -
             
     | 
| 
       820 
     | 
    
         
            -
             
     | 
| 
       821 
     | 
    
         
            -
             
     | 
| 
       822 
     | 
    
         
            -
             
     | 
| 
      
 959 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 960 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 961 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 962 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 963 
     | 
    
         
            +
                      .to eq(["div.pgroup", ["p", "normal line."]])
         
     | 
| 
      
 964 
     | 
    
         
            +
                    expect(body.element_children[1].selector_and_children)
         
     | 
| 
      
 965 
     | 
    
         
            +
                      .to eq(["pre", "d {\n   this will not converted to div or p or pgroup.\n\nline_command: this will be not converted too.\n}"])
         
     | 
| 
      
 966 
     | 
    
         
            +
                    expect(body.element_children[2].selector_and_children)
         
     | 
| 
      
 967 
     | 
    
         
            +
                      .to eq(["div.pgroup", ["p", "normal line again."]])
         
     | 
| 
      
 968 
     | 
    
         
            +
                  end
         
     | 
| 
       823 
969 
     | 
    
         | 
| 
       824 
     | 
    
         
            -
             
     | 
| 
       825 
     | 
    
         
            -
             
     | 
| 
      
 970 
     | 
    
         
            +
                  it 'should convert preformatted code' do
         
     | 
| 
      
 971 
     | 
    
         
            +
                    text = <<EOF
         
     | 
| 
       826 
972 
     | 
    
         
             
            normal line.
         
     | 
| 
       827 
973 
     | 
    
         
             
            code {//
         
     | 
| 
       828 
974 
     | 
    
         
             
            d {
         
     | 
| 
         @@ -832,16 +978,19 @@ line_command: this will be not converted too. 
     | 
|
| 
       832 
978 
     | 
    
         
             
            //}
         
     | 
| 
       833 
979 
     | 
    
         
             
            normal line again.
         
     | 
| 
       834 
980 
     | 
    
         
             
            EOF
         
     | 
| 
       835 
     | 
    
         
            -
             
     | 
| 
       836 
     | 
    
         
            -
             
     | 
| 
       837 
     | 
    
         
            -
             
     | 
| 
       838 
     | 
    
         
            -
             
     | 
| 
       839 
     | 
    
         
            -
             
     | 
| 
       840 
     | 
    
         
            -
             
     | 
| 
       841 
     | 
    
         
            -
             
     | 
| 
      
 981 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 982 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 983 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 984 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 985 
     | 
    
         
            +
                      .to eq(["div.pgroup", ["p", "normal line."]])
         
     | 
| 
      
 986 
     | 
    
         
            +
                    expect(body.element_children[1].selector_and_children)
         
     | 
| 
      
 987 
     | 
    
         
            +
                      .to eq(["pre", ["code", "d {\n   this will not converted to div or p or pgroup.\nline_command: this will be not converted too.\n}"]])
         
     | 
| 
      
 988 
     | 
    
         
            +
                    expect(body.element_children[2].selector_and_children)
         
     | 
| 
      
 989 
     | 
    
         
            +
                      .to eq(["div.pgroup", ["p", "normal line again."]])
         
     | 
| 
      
 990 
     | 
    
         
            +
                  end
         
     | 
| 
       842 
991 
     | 
    
         | 
| 
       843 
     | 
    
         
            -
             
     | 
| 
       844 
     | 
    
         
            -
             
     | 
| 
      
 992 
     | 
    
         
            +
                  it 'convert preformatted code with language' do
         
     | 
| 
      
 993 
     | 
    
         
            +
                    text = <<EOF
         
     | 
| 
       845 
994 
     | 
    
         
             
            normal line.
         
     | 
| 
       846 
995 
     | 
    
         
             
            code {//ruby
         
     | 
| 
       847 
996 
     | 
    
         
             
            # ruby code example.
         
     | 
| 
         @@ -849,16 +998,39 @@ code {//ruby 
     | 
|
| 
       849 
998 
     | 
    
         
             
            //}
         
     | 
| 
       850 
999 
     | 
    
         
             
            normal line again.
         
     | 
| 
       851 
1000 
     | 
    
         
             
            EOF
         
     | 
| 
       852 
     | 
    
         
            -
             
     | 
| 
       853 
     | 
    
         
            -
             
     | 
| 
       854 
     | 
    
         
            -
             
     | 
| 
       855 
     | 
    
         
            -
             
     | 
| 
       856 
     | 
    
         
            -
             
     | 
| 
       857 
     | 
    
         
            -
             
     | 
| 
       858 
     | 
    
         
            -
             
     | 
| 
      
 1001 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 1002 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 1003 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 1004 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 1005 
     | 
    
         
            +
                      .to eq(["div.pgroup", ["p", "normal line."]])
         
     | 
| 
      
 1006 
     | 
    
         
            +
                    expect(body.element_children[1].selector_and_children)
         
     | 
| 
      
 1007 
     | 
    
         
            +
                      .to eq(["pre.code-ruby[data-code-language='ruby']", ["code", "# ruby code example.\n\"Hello, World\".split(',').map(&:strip).map(&:to_sym) # => [:Hello, :World]"]])
         
     | 
| 
      
 1008 
     | 
    
         
            +
                    expect(body.element_children[2].selector_and_children)
         
     | 
| 
      
 1009 
     | 
    
         
            +
                      .to eq(["div.pgroup", ["p", "normal line again."]])
         
     | 
| 
      
 1010 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1011 
     | 
    
         
            +
             
     | 
| 
      
 1012 
     | 
    
         
            +
                  it 'convert preformatted code with language fence format' do 
         
     | 
| 
      
 1013 
     | 
    
         
            +
                    text = <<EOF
         
     | 
| 
      
 1014 
     | 
    
         
            +
            normal line.
         
     | 
| 
      
 1015 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 1016 
     | 
    
         
            +
            # ruby code example.
         
     | 
| 
      
 1017 
     | 
    
         
            +
            "Hello, World".split(',').map(&:strip).map(&:to_sym) # => [:Hello, :World]
         
     | 
| 
      
 1018 
     | 
    
         
            +
            ```
         
     | 
| 
      
 1019 
     | 
    
         
            +
            normal line again.
         
     | 
| 
      
 1020 
     | 
    
         
            +
            EOF
         
     | 
| 
      
 1021 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 1022 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 1023 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 1024 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 1025 
     | 
    
         
            +
                      .to eq(["div.pgroup", ["p", "normal line."]])
         
     | 
| 
      
 1026 
     | 
    
         
            +
                    expect(body.element_children[1].selector_and_children)
         
     | 
| 
      
 1027 
     | 
    
         
            +
                      .to eq(["pre.code-ruby[data-code-language='ruby']", ["code", "# ruby code example.\n\"Hello, World\".split(',').map(&:strip).map(&:to_sym) # => [:Hello, :World]"]])
         
     | 
| 
      
 1028 
     | 
    
         
            +
                    expect(body.element_children[2].selector_and_children)
         
     | 
| 
      
 1029 
     | 
    
         
            +
                      .to eq(["div.pgroup", ["p", "normal line again."]])
         
     | 
| 
      
 1030 
     | 
    
         
            +
                  end
         
     | 
| 
       859 
1031 
     | 
    
         | 
| 
       860 
     | 
    
         
            -
             
     | 
| 
       861 
     | 
    
         
            -
             
     | 
| 
      
 1032 
     | 
    
         
            +
                  it 'convert preformatted text (simple notation)' do
         
     | 
| 
      
 1033 
     | 
    
         
            +
                    text = <<EOF
         
     | 
| 
       862 
1034 
     | 
    
         
             
            normal line.
         
     | 
| 
       863 
1035 
     | 
    
         
             
            pre {
         
     | 
| 
       864 
1036 
     | 
    
         
             
            this [l(link){link}] will not be converted.
         
     | 
| 
         @@ -866,123 +1038,228 @@ line_command: this will be not converted too. 
     | 
|
| 
       866 
1038 
     | 
    
         
             
            }
         
     | 
| 
       867 
1039 
     | 
    
         
             
            normal line again.
         
     | 
| 
       868 
1040 
     | 
    
         
             
            EOF
         
     | 
| 
       869 
     | 
    
         
            -
             
     | 
| 
       870 
     | 
    
         
            -
             
     | 
| 
       871 
     | 
    
         
            -
             
     | 
| 
       872 
     | 
    
         
            -
             
     | 
| 
       873 
     | 
    
         
            -
             
     | 
| 
       874 
     | 
    
         
            -
             
     | 
| 
       875 
     | 
    
         
            -
             
     | 
| 
       876 
     | 
    
         
            -
             
     | 
| 
       877 
     | 
    
         
            -
             
     | 
| 
      
 1041 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 1042 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 1043 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 1044 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 1045 
     | 
    
         
            +
                      .to eq(["div.pgroup", ["p", "normal line."]])
         
     | 
| 
      
 1046 
     | 
    
         
            +
                    expect(body.element_children[1].selector_and_children)
         
     | 
| 
      
 1047 
     | 
    
         
            +
                      .to eq(["pre", "this [l(link){link}] will not be converted.\nline_command: this will be not converted too."])
         
     | 
| 
      
 1048 
     | 
    
         
            +
                    expect(body.element_children[2].selector_and_children)
         
     | 
| 
      
 1049 
     | 
    
         
            +
                      .to eq(["div.pgroup", ["p", "normal line again."]])
         
     | 
| 
      
 1050 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1051 
     | 
    
         
            +
                  it 'should convert preformatted code (simple notation)' do
         
     | 
| 
      
 1052 
     | 
    
         
            +
                    text = <<EOF
         
     | 
| 
       878 
1053 
     | 
    
         
             
            normal line.
         
     | 
| 
       879 
1054 
     | 
    
         
             
            code {
         
     | 
| 
       880 
1055 
     | 
    
         
             
            line_command: this will be not converted too.
         
     | 
| 
       881 
1056 
     | 
    
         
             
            }
         
     | 
| 
       882 
1057 
     | 
    
         
             
            normal line again.
         
     | 
| 
       883 
1058 
     | 
    
         
             
            EOF
         
     | 
| 
       884 
     | 
    
         
            -
             
     | 
| 
       885 
     | 
    
         
            -
             
     | 
| 
       886 
     | 
    
         
            -
             
     | 
| 
       887 
     | 
    
         
            -
             
     | 
| 
       888 
     | 
    
         
            -
             
     | 
| 
       889 
     | 
    
         
            -
             
     | 
| 
       890 
     | 
    
         
            -
             
     | 
| 
      
 1059 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 1060 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 1061 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 1062 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 1063 
     | 
    
         
            +
                      .to eq(["div.pgroup", ["p", "normal line."]])
         
     | 
| 
      
 1064 
     | 
    
         
            +
                    expect(body.element_children[1].selector_and_children)
         
     | 
| 
      
 1065 
     | 
    
         
            +
                      .to eq(["pre", ["code", "line_command: this will be not converted too."]])
         
     | 
| 
      
 1066 
     | 
    
         
            +
                    expect(body.element_children[2].selector_and_children)
         
     | 
| 
      
 1067 
     | 
    
         
            +
                      .to eq(["div.pgroup", ["p", "normal line again."]])
         
     | 
| 
      
 1068 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1069 
     | 
    
         
            +
             
     | 
| 
      
 1070 
     | 
    
         
            +
                  it 'convert preformatted text with caption' do
         
     | 
| 
      
 1071 
     | 
    
         
            +
                    text = <<EOF
         
     | 
| 
      
 1072 
     | 
    
         
            +
            normal line.
         
     | 
| 
      
 1073 
     | 
    
         
            +
              pre(caption [sp.the-text{text}]) {//
         
     | 
| 
      
 1074 
     | 
    
         
            +
            d {
         
     | 
| 
      
 1075 
     | 
    
         
            +
               this will not converted to div or p or pgroup.
         
     | 
| 
      
 1076 
     | 
    
         
            +
            line_command: this will be not converted too.
         
     | 
| 
      
 1077 
     | 
    
         
            +
            }
         
     | 
| 
      
 1078 
     | 
    
         
            +
              //}
         
     | 
| 
      
 1079 
     | 
    
         
            +
            EOF
         
     | 
| 
      
 1080 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 1081 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 1082 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 1083 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 1084 
     | 
    
         
            +
                      .to eq(["div.pgroup", ["p", "normal line."]])
         
     | 
| 
      
 1085 
     | 
    
         
            +
                    expect(body.element_children[1].selector_and_children)
         
     | 
| 
      
 1086 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 1087 
     | 
    
         
            +
                             ["div.pre",
         
     | 
| 
      
 1088 
     | 
    
         
            +
                              ["p.caption", "caption ", ["span.the-text", "text"]],
         
     | 
| 
      
 1089 
     | 
    
         
            +
                              ["pre", "d {\n   this will not converted to div or p or pgroup.\nline_command: this will be not converted too.\n}"]
         
     | 
| 
      
 1090 
     | 
    
         
            +
                              ])
         
     | 
| 
      
 1091 
     | 
    
         
            +
             
     | 
| 
      
 1092 
     | 
    
         
            +
                              
         
     | 
| 
      
 1093 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1094 
     | 
    
         
            +
             
     | 
| 
      
 1095 
     | 
    
         
            +
                  it 'convert preformatted code with language fence format with caption' do 
         
     | 
| 
      
 1096 
     | 
    
         
            +
                    text = <<EOF
         
     | 
| 
      
 1097 
     | 
    
         
            +
            normal line.
         
     | 
| 
      
 1098 
     | 
    
         
            +
            ```ruby(the caption text)
         
     | 
| 
      
 1099 
     | 
    
         
            +
            # ruby code example.
         
     | 
| 
      
 1100 
     | 
    
         
            +
            "Hello, World".split(',').map(&:strip).map(&:to_sym) # => [:Hello, :World]
         
     | 
| 
      
 1101 
     | 
    
         
            +
            ```
         
     | 
| 
      
 1102 
     | 
    
         
            +
            normal line again.
         
     | 
| 
      
 1103 
     | 
    
         
            +
            EOF
         
     | 
| 
      
 1104 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 1105 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 1106 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 1107 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 1108 
     | 
    
         
            +
                      .to eq(["div.pgroup", ["p", "normal line."]])
         
     | 
| 
      
 1109 
     | 
    
         
            +
                    expect(body.element_children[1].selector_and_children)
         
     | 
| 
      
 1110 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 1111 
     | 
    
         
            +
                             ["div.pre", 
         
     | 
| 
      
 1112 
     | 
    
         
            +
                              ["p.caption", "the caption text"],
         
     | 
| 
      
 1113 
     | 
    
         
            +
                             ["pre.code-ruby[data-code-language='ruby']",
         
     | 
| 
      
 1114 
     | 
    
         
            +
                              ["code", "# ruby code example.\n\"Hello, World\".split(',').map(&:strip).map(&:to_sym) # => [:Hello, :World]"]]])
         
     | 
| 
      
 1115 
     | 
    
         
            +
                    expect(body.element_children[2].selector_and_children)
         
     | 
| 
      
 1116 
     | 
    
         
            +
                      .to eq(["div.pgroup", ["p", "normal line again."]])
         
     | 
| 
      
 1117 
     | 
    
         
            +
                  end
         
     | 
| 
       891 
1118 
     | 
    
         | 
| 
       892 
     | 
    
         
            -
                it 'should raise error' do
         
     | 
| 
       893 
     | 
    
         
            -
                  text = "d {\n block is\nd {\n nested but\nd {\n not terminated }"
         
     | 
| 
       894 
     | 
    
         
            -
                  expect { NoraMark::Document.parse(text, lang: 'ja', title: 'foo') }.to raise_error KPeg::CompiledParser::ParseError
         
     | 
| 
       895 
1119 
     | 
    
         
             
                end
         
     | 
| 
       896 
1120 
     | 
    
         | 
| 
       897 
1121 
     | 
    
         
             
                describe 'markdown style' do
         
     | 
| 
       898 
1122 
     | 
    
         
             
                  it 'should convert markdown style heading' do
         
     | 
| 
       899 
     | 
    
         
            -
                    text = " 
     | 
| 
      
 1123 
     | 
    
         
            +
                    text = "# タイトル です。\r\n\r\nこれは、セクションの中です。"
         
     | 
| 
       900 
1124 
     | 
    
         
             
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
       901 
1125 
     | 
    
         
             
                    converted = noramark.html
         
     | 
| 
       902 
1126 
     | 
    
         
             
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
       903 
1127 
     | 
    
         
             
                    expect(body.element_children.size).to eq 1
         
     | 
| 
       904 
     | 
    
         
            -
                    expect(body.element_children[0].selector_and_children) 
     | 
| 
       905 
     | 
    
         
            -
             
     | 
| 
       906 
     | 
    
         
            -
             
     | 
| 
       907 
     | 
    
         
            -
             
     | 
| 
       908 
     | 
    
         
            -
             
     | 
| 
       909 
     | 
    
         
            -
             
     | 
| 
      
 1128 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 1129 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 1130 
     | 
    
         
            +
                             ['section',
         
     | 
| 
      
 1131 
     | 
    
         
            +
                              ['h1', 'タイトル です。'],
         
     | 
| 
      
 1132 
     | 
    
         
            +
                              ['div.pgroup', 
         
     | 
| 
      
 1133 
     | 
    
         
            +
                               ['p', 'これは、セクションの中です。']]]
         
     | 
| 
      
 1134 
     | 
    
         
            +
                             )
         
     | 
| 
       910 
1135 
     | 
    
         
             
                  end
         
     | 
| 
       911 
1136 
     | 
    
         
             
                  it 'should convert markdown style heading with empty body' do
         
     | 
| 
       912 
     | 
    
         
            -
                    text = " 
     | 
| 
      
 1137 
     | 
    
         
            +
                    text = "# タイトルです。\n* 中身です。\n\n## 次のタイトルです。これから書きます。\n\n## ここもこれから。"
         
     | 
| 
       913 
1138 
     | 
    
         
             
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
       914 
1139 
     | 
    
         
             
                    converted = noramark.html
         
     | 
| 
       915 
1140 
     | 
    
         
             
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
       916 
     | 
    
         
            -
                    expect(body.element_children[0].selector_and_children) 
     | 
| 
       917 
     | 
    
         
            -
             
     | 
| 
       918 
     | 
    
         
            -
             
     | 
| 
       919 
     | 
    
         
            -
             
     | 
| 
       920 
     | 
    
         
            -
             
     | 
| 
       921 
     | 
    
         
            -
             
     | 
| 
       922 
     | 
    
         
            -
             
     | 
| 
       923 
     | 
    
         
            -
             
     | 
| 
      
 1141 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 1142 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 1143 
     | 
    
         
            +
                             ['section',
         
     | 
| 
      
 1144 
     | 
    
         
            +
                              ['h1', 'タイトルです。'],
         
     | 
| 
      
 1145 
     | 
    
         
            +
                              ['ul', ['li', '中身です。']],
         
     | 
| 
      
 1146 
     | 
    
         
            +
                              ['section',
         
     | 
| 
      
 1147 
     | 
    
         
            +
                               ['h2', '次のタイトルです。これから書きます。']],
         
     | 
| 
      
 1148 
     | 
    
         
            +
                              ['section',
         
     | 
| 
      
 1149 
     | 
    
         
            +
                               ['h2', 'ここもこれから。']]])
         
     | 
| 
       924 
1150 
     | 
    
         
             
                  end
         
     | 
| 
       925 
1151 
     | 
    
         
             
                  it 'should markdown style heading interrupted by other headed section' do
         
     | 
| 
       926 
     | 
    
         
            -
                    text = " 
     | 
| 
      
 1152 
     | 
    
         
            +
                    text = "# タイトルです。\r\nこれは、セクションの中です。\n # また次のセクションです。\n次のセクションの中です。"
         
     | 
| 
       927 
1153 
     | 
    
         
             
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
       928 
1154 
     | 
    
         
             
                    converted = noramark.html
         
     | 
| 
       929 
1155 
     | 
    
         
             
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
       930 
1156 
     | 
    
         
             
                    expect(body.element_children.size).to eq 2
         
     | 
| 
       931 
     | 
    
         
            -
                    expect(body.element_children[0].selector_and_children) 
     | 
| 
       932 
     | 
    
         
            -
             
     | 
| 
       933 
     | 
    
         
            -
             
     | 
| 
       934 
     | 
    
         
            -
             
     | 
| 
       935 
     | 
    
         
            -
             
     | 
| 
       936 
     | 
    
         
            -
             
     | 
| 
       937 
     | 
    
         
            -
                    [ 
     | 
| 
       938 
     | 
    
         
            -
                       
     | 
| 
       939 
     | 
    
         
            -
             
     | 
| 
       940 
     | 
    
         
            -
             
     | 
| 
       941 
     | 
    
         
            -
             
     | 
| 
      
 1157 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 1158 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 1159 
     | 
    
         
            +
                             ['section',
         
     | 
| 
      
 1160 
     | 
    
         
            +
                              ['h1', 'タイトルです。'],
         
     | 
| 
      
 1161 
     | 
    
         
            +
                              ['div.pgroup', 
         
     | 
| 
      
 1162 
     | 
    
         
            +
                               ['p', 'これは、セクションの中です。']]])
         
     | 
| 
      
 1163 
     | 
    
         
            +
                    expect(body.element_children[1].selector_and_children)
         
     | 
| 
      
 1164 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 1165 
     | 
    
         
            +
                             ['section',
         
     | 
| 
      
 1166 
     | 
    
         
            +
                              ['h1', 'また次のセクションです。'],
         
     | 
| 
      
 1167 
     | 
    
         
            +
                              ['div.pgroup', 
         
     | 
| 
      
 1168 
     | 
    
         
            +
                               ['p', '次のセクションの中です。']]]
         
     | 
| 
      
 1169 
     | 
    
         
            +
                             )
         
     | 
| 
       942 
1170 
     | 
    
         
             
                  end
         
     | 
| 
       943 
1171 
     | 
    
         
             
                  it 'should markdown style heading not interrupted by other explicit section' do
         
     | 
| 
       944 
     | 
    
         
            -
                    text = " 
     | 
| 
      
 1172 
     | 
    
         
            +
                    text = "# タイトルです。\r\nこれは、セクションの中です。\n section {\n h2: また次のセクションです。\n入れ子になります。\n}\nこのように。"
         
     | 
| 
       945 
1173 
     | 
    
         
             
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
       946 
1174 
     | 
    
         
             
                    converted = noramark.html
         
     | 
| 
       947 
1175 
     | 
    
         
             
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
       948 
1176 
     | 
    
         
             
                    expect(body.element_children.size).to eq 1
         
     | 
| 
       949 
     | 
    
         
            -
                    expect(body.element_children[0].selector_and_children) 
     | 
| 
       950 
     | 
    
         
            -
             
     | 
| 
       951 
     | 
    
         
            -
             
     | 
| 
       952 
     | 
    
         
            -
             
     | 
| 
       953 
     | 
    
         
            -
             
     | 
| 
       954 
     | 
    
         
            -
             
     | 
| 
       955 
     | 
    
         
            -
             
     | 
| 
       956 
     | 
    
         
            -
             
     | 
| 
       957 
     | 
    
         
            -
             
     | 
| 
       958 
     | 
    
         
            -
             
     | 
| 
       959 
     | 
    
         
            -
             
     | 
| 
       960 
     | 
    
         
            -
             
     | 
| 
      
 1177 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 1178 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 1179 
     | 
    
         
            +
                             ['section',
         
     | 
| 
      
 1180 
     | 
    
         
            +
                              ['h1', 'タイトルです。'],
         
     | 
| 
      
 1181 
     | 
    
         
            +
                              ['div.pgroup', 
         
     | 
| 
      
 1182 
     | 
    
         
            +
                               ['p', 'これは、セクションの中です。']],
         
     | 
| 
      
 1183 
     | 
    
         
            +
                              ['section',
         
     | 
| 
      
 1184 
     | 
    
         
            +
                               ['h2', 'また次のセクションです。'],
         
     | 
| 
      
 1185 
     | 
    
         
            +
                               ['div.pgroup', 
         
     | 
| 
      
 1186 
     | 
    
         
            +
                                ['p', '入れ子になります。']]],
         
     | 
| 
      
 1187 
     | 
    
         
            +
                              ['div.pgroup', 
         
     | 
| 
      
 1188 
     | 
    
         
            +
                               ['p', 'このように。']]]
         
     | 
| 
      
 1189 
     | 
    
         
            +
                             )
         
     | 
| 
       961 
1190 
     | 
    
         
             
                  end
         
     | 
| 
      
 1191 
     | 
    
         
            +
                  it 'should markdown style heading not interrupted by other explicit section' do
         
     | 
| 
      
 1192 
     | 
    
         
            +
                    text = "# タイトルです。\r\nこれは、セクションの中です。\n ## また次のセクションです。{\n 入れ子になります。\n# 中にもかけます。\nさらにネストされます。\n}\nこのように。"
         
     | 
| 
      
 1193 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 1194 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 1195 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 1196 
     | 
    
         
            +
                    expect(body.element_children.size).to eq 1
         
     | 
| 
      
 1197 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 1198 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 1199 
     | 
    
         
            +
                             ['section',
         
     | 
| 
      
 1200 
     | 
    
         
            +
                              ['h1', 'タイトルです。'],
         
     | 
| 
      
 1201 
     | 
    
         
            +
                              ['div.pgroup', 
         
     | 
| 
      
 1202 
     | 
    
         
            +
                               ['p', 'これは、セクションの中です。']],
         
     | 
| 
      
 1203 
     | 
    
         
            +
                              ['section',
         
     | 
| 
      
 1204 
     | 
    
         
            +
                               ['h2', 'また次のセクションです。'],
         
     | 
| 
      
 1205 
     | 
    
         
            +
                               ['div.pgroup', 
         
     | 
| 
      
 1206 
     | 
    
         
            +
                                ['p', '入れ子になります。']],
         
     | 
| 
      
 1207 
     | 
    
         
            +
                               ['section',
         
     | 
| 
      
 1208 
     | 
    
         
            +
                                ['h1', '中にもかけます。'],
         
     | 
| 
      
 1209 
     | 
    
         
            +
                                ['div.pgroup', 
         
     | 
| 
      
 1210 
     | 
    
         
            +
                                 ['p', 'さらにネストされます。']]]],
         
     | 
| 
      
 1211 
     | 
    
         
            +
                              ['div.pgroup', 
         
     | 
| 
      
 1212 
     | 
    
         
            +
                               ['p', 'このように。']]]
         
     | 
| 
      
 1213 
     | 
    
         
            +
                             )
         
     | 
| 
      
 1214 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1215 
     | 
    
         
            +
             
     | 
| 
      
 1216 
     | 
    
         
            +
                  it 'should markdown style explicit heading correctly nested' do
         
     | 
| 
      
 1217 
     | 
    
         
            +
                    text = "# head one \n in the top level section.\n ## second level section. { \n\n in the second level.\n}\n top level again."
         
     | 
| 
      
 1218 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
      
 1219 
     | 
    
         
            +
                    converted = noramark.html
         
     | 
| 
      
 1220 
     | 
    
         
            +
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 1221 
     | 
    
         
            +
                    expect(body.element_children.size).to eq 1
         
     | 
| 
      
 1222 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 1223 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 1224 
     | 
    
         
            +
                             ['section',
         
     | 
| 
      
 1225 
     | 
    
         
            +
                              ['h1', 'head one'],
         
     | 
| 
      
 1226 
     | 
    
         
            +
                              ['div.pgroup', 
         
     | 
| 
      
 1227 
     | 
    
         
            +
                               ['p', 'in the top level section.']],
         
     | 
| 
      
 1228 
     | 
    
         
            +
                              ['section',
         
     | 
| 
      
 1229 
     | 
    
         
            +
                               ['h2', 'second level section.'],
         
     | 
| 
      
 1230 
     | 
    
         
            +
                               ['div.pgroup', 
         
     | 
| 
      
 1231 
     | 
    
         
            +
                                ['p', 'in the second level.']]],
         
     | 
| 
      
 1232 
     | 
    
         
            +
                              ['div.pgroup', 
         
     | 
| 
      
 1233 
     | 
    
         
            +
                               ['p', 'top level again.']]]
         
     | 
| 
      
 1234 
     | 
    
         
            +
                             )
         
     | 
| 
      
 1235 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1236 
     | 
    
         
            +
             
     | 
| 
       962 
1237 
     | 
    
         
             
                  it 'should markdown style heading not interrupted by smaller section' do
         
     | 
| 
       963 
     | 
    
         
            -
                    text = " 
     | 
| 
      
 1238 
     | 
    
         
            +
                    text = "# タイトルです。\r\nこれは、セクションの中です。\n ## また次のセクションです。\n 入れ子になります。\n### さらに中のセクション \nさらに入れ子になっているはず。\n# ここで次のセクションです。\n脱出しているはずです。"
         
     | 
| 
       964 
1239 
     | 
    
         
             
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
       965 
1240 
     | 
    
         
             
                    converted = noramark.html
         
     | 
| 
       966 
1241 
     | 
    
         
             
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
       967 
1242 
     | 
    
         
             
                    expect(body.element_children.size).to eq 2
         
     | 
| 
       968 
     | 
    
         
            -
                    expect(body.element_children[0].selector_and_children) 
     | 
| 
       969 
     | 
    
         
            -
             
     | 
| 
       970 
     | 
    
         
            -
             
     | 
| 
       971 
     | 
    
         
            -
             
     | 
| 
       972 
     | 
    
         
            -
             
     | 
| 
       973 
     | 
    
         
            -
             
     | 
| 
       974 
     | 
    
         
            -
             
     | 
| 
       975 
     | 
    
         
            -
             
     | 
| 
       976 
     | 
    
         
            -
             
     | 
| 
       977 
     | 
    
         
            -
             
     | 
| 
       978 
     | 
    
         
            -
             
     | 
| 
       979 
     | 
    
         
            -
             
     | 
| 
       980 
     | 
    
         
            -
             
     | 
| 
       981 
     | 
    
         
            -
             
     | 
| 
       982 
     | 
    
         
            -
                    [ 
     | 
| 
       983 
     | 
    
         
            -
                       
     | 
| 
       984 
     | 
    
         
            -
             
     | 
| 
       985 
     | 
    
         
            -
             
     | 
| 
      
 1243 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 1244 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 1245 
     | 
    
         
            +
                             ['section',
         
     | 
| 
      
 1246 
     | 
    
         
            +
                              ['h1', 'タイトルです。'],
         
     | 
| 
      
 1247 
     | 
    
         
            +
                              ['div.pgroup', 
         
     | 
| 
      
 1248 
     | 
    
         
            +
                               ['p', 'これは、セクションの中です。']],
         
     | 
| 
      
 1249 
     | 
    
         
            +
                              ['section',
         
     | 
| 
      
 1250 
     | 
    
         
            +
                               ['h2', 'また次のセクションです。'],
         
     | 
| 
      
 1251 
     | 
    
         
            +
                               ['div.pgroup', 
         
     | 
| 
      
 1252 
     | 
    
         
            +
                                ['p', '入れ子になります。']],
         
     | 
| 
      
 1253 
     | 
    
         
            +
                               ['section',
         
     | 
| 
      
 1254 
     | 
    
         
            +
                                ['h3', 'さらに中のセクション'],
         
     | 
| 
      
 1255 
     | 
    
         
            +
                                ['div.pgroup', 
         
     | 
| 
      
 1256 
     | 
    
         
            +
                                 ['p', 'さらに入れ子になっているはず。']]]]] )
         
     | 
| 
      
 1257 
     | 
    
         
            +
                    expect(body.element_children[1].selector_and_children)
         
     | 
| 
      
 1258 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 1259 
     | 
    
         
            +
                             ['section',
         
     | 
| 
      
 1260 
     | 
    
         
            +
                              ['h1', 'ここで次のセクションです。'],
         
     | 
| 
      
 1261 
     | 
    
         
            +
                              ['div.pgroup', 
         
     | 
| 
      
 1262 
     | 
    
         
            +
                               ['p', '脱出しているはずです。']]])
         
     | 
| 
       986 
1263 
     | 
    
         | 
| 
       987 
1264 
     | 
    
         
             
                  end
         
     | 
| 
       988 
1265 
     | 
    
         
             
                end
         
     | 
| 
         @@ -993,14 +1270,17 @@ EOF 
     | 
|
| 
       993 
1270 
     | 
    
         
             
                    converted = noramark.render_parameter(nonpaged: true).html
         
     | 
| 
       994 
1271 
     | 
    
         
             
                    expect(converted.size).to eq 1
         
     | 
| 
       995 
1272 
     | 
    
         
             
                    body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
       996 
     | 
    
         
            -
                    expect(body.element_children[0].selector_and_children) 
     | 
| 
       997 
     | 
    
         
            -
             
     | 
| 
       998 
     | 
    
         
            -
             
     | 
| 
       999 
     | 
    
         
            -
             
     | 
| 
       1000 
     | 
    
         
            -
                    [ 
     | 
| 
       1001 
     | 
    
         
            -
             
     | 
| 
       1002 
     | 
    
         
            -
             
     | 
| 
       1003 
     | 
    
         
            -
             
     | 
| 
      
 1273 
     | 
    
         
            +
                    expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 1274 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 1275 
     | 
    
         
            +
                             ['div.pgroup',
         
     | 
| 
      
 1276 
     | 
    
         
            +
                              ['p', 'some text']])
         
     | 
| 
      
 1277 
     | 
    
         
            +
                    expect(body.element_children[1].selector_and_children)
         
     | 
| 
      
 1278 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 1279 
     | 
    
         
            +
                             ['hr.page-break'])
         
     | 
| 
      
 1280 
     | 
    
         
            +
                    expect(body.element_children[2].selector_and_children)
         
     | 
| 
      
 1281 
     | 
    
         
            +
                      .to eq(
         
     | 
| 
      
 1282 
     | 
    
         
            +
                             ['div.pgroup',
         
     | 
| 
      
 1283 
     | 
    
         
            +
                              ['p', 'next page']])
         
     | 
| 
       1004 
1284 
     | 
    
         
             
                  end
         
     | 
| 
       1005 
1285 
     | 
    
         
             
                end
         
     | 
| 
       1006 
1286 
     | 
    
         
             
                describe 'create file' do
         
     | 
| 
         @@ -1010,7 +1290,7 @@ EOF 
     | 
|
| 
       1010 
1290 
     | 
    
         
             
                    text = "some text"
         
     | 
| 
       1011 
1291 
     | 
    
         
             
                    noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
         
     | 
| 
       1012 
1292 
     | 
    
         
             
                    noramark.html.write_as_files(directory: @basedir)
         
     | 
| 
       1013 
     | 
    
         
            -
                    expect(File.basename(Dir.glob(File.join(@basedir, '*.xhtml'))[0])).to match 
     | 
| 
      
 1293 
     | 
    
         
            +
                    expect(File.basename(Dir.glob(File.join(@basedir, '*.xhtml'))[0])).to match(/noramark_[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}_00001.xhtml/)
         
     | 
| 
       1014 
1294 
     | 
    
         
             
                  end
         
     | 
| 
       1015 
1295 
     | 
    
         
             
                  it 'should create named file' do
         
     | 
| 
       1016 
1296 
     | 
    
         
             
                    text = "some text\nnewpage:\nnext page"
         
     | 
| 
         @@ -1029,7 +1309,7 @@ EOF 
     | 
|
| 
       1029 
1309 
     | 
    
         
             
                  }
         
     | 
| 
       1030 
1310 
     | 
    
         
             
                  after { Dir.glob(File.join(@basedir, '*.xhtml')) { |file| File.delete file } }
         
     | 
| 
       1031 
1311 
     | 
    
         
             
                  it 'should create valid html5' do
         
     | 
| 
       1032 
     | 
    
         
            -
                    noramark = NoraMark::Document.parse(File.open(File.join(@exampledir, 'noramark-reference-ja.nora')).read, document_name: 'noramark-reference-ja')
         
     | 
| 
      
 1312 
     | 
    
         
            +
                    noramark = NoraMark::Document.parse(File.open(File.join(@exampledir, 'noramark-reference-ja.nora'), 'rb:UTF-8').read, document_name: 'noramark-reference-ja')
         
     | 
| 
       1033 
1313 
     | 
    
         
             
                    noramark.html.write_as_files(directory: @exampledir)
         
     | 
| 
       1034 
1314 
     | 
    
         
             
                    jar = File.join(@here, 'jing-20091111/bin/jing.jar')
         
     | 
| 
       1035 
1315 
     | 
    
         
             
                    schema = File.join(@here, 'epub30-schemas/epub-xhtml-30.rnc')
         
     | 
| 
         @@ -1051,177 +1331,6 @@ EOF 
     | 
|
| 
       1051 
1331 
     | 
    
         
             
                    expect(@stdout.strip).to eq ""
         
     | 
| 
       1052 
1332 
     | 
    
         
             
                  end
         
     | 
| 
       1053 
1333 
     | 
    
         
             
                end
         
     | 
| 
       1054 
     | 
    
         
            -
                describe 'node manipulation' do
         
     | 
| 
       1055 
     | 
    
         
            -
                  before do
         
     | 
| 
       1056 
     | 
    
         
            -
                    @text = <<EOF
         
     | 
| 
       1057 
     | 
    
         
            -
            1st line.
         
     | 
| 
       1058 
     | 
    
         
            -
            d.the_class {
         
     | 
| 
       1059 
     | 
    
         
            -
            3rd line.
         
     | 
| 
       1060 
     | 
    
         
            -
            }
         
     | 
| 
       1061 
     | 
    
         
            -
            5th line.
         
     | 
| 
       1062 
     | 
    
         
            -
            EOF
         
     | 
| 
       1063 
     | 
    
         
            -
                  end
         
     | 
| 
       1064 
     | 
    
         
            -
                  it 'should access line number' do
         
     | 
| 
       1065 
     | 
    
         
            -
                    noramark = NoraMark::Document.parse(@text)
         
     | 
| 
       1066 
     | 
    
         
            -
                    page = noramark.root.children[0]
         
     | 
| 
       1067 
     | 
    
         
            -
                    expect(page.children.size).to eq 3
         
     | 
| 
       1068 
     | 
    
         
            -
                    expect(page.line_no).to eq 1
         
     | 
| 
       1069 
     | 
    
         
            -
                    expect(page.children[0].line_no).to eq 1
         
     | 
| 
       1070 
     | 
    
         
            -
                    expect(page.children[1].line_no).to eq 2
         
     | 
| 
       1071 
     | 
    
         
            -
                    expect(page.children[2].children[0].line_no).to eq 5
         
     | 
| 
       1072 
     | 
    
         
            -
                  end
         
     | 
| 
       1073 
     | 
    
         
            -
             
     | 
| 
       1074 
     | 
    
         
            -
                  it 'replace existing node' do
         
     | 
| 
       1075 
     | 
    
         
            -
                    noramark = NoraMark::Document.parse(@text)
         
     | 
| 
       1076 
     | 
    
         
            -
                    page = noramark.root.children[0]
         
     | 
| 
       1077 
     | 
    
         
            -
                    first_pgroup = page.children[0]
         
     | 
| 
       1078 
     | 
    
         
            -
                    line_no = first_pgroup.line_no
         
     | 
| 
       1079 
     | 
    
         
            -
                    new_node = NoraMark::ParagraphGroup.new(['the_id'], ['the_class'], [], {}, [ NoraMark::Text.new("replaced.", line_no)],  line_no)
         
     | 
| 
       1080 
     | 
    
         
            -
                    first_pgroup.replace(new_node)
         
     | 
| 
       1081 
     | 
    
         
            -
                    body = Nokogiri::XML::Document.parse(noramark.html[0]).root.at_xpath('xmlns:body')
         
     | 
| 
       1082 
     | 
    
         
            -
                    expect(body.element_children[0].selector_and_children(remove_id: false)).to eq(
         
     | 
| 
       1083 
     | 
    
         
            -
                      ['p#the_id.the_class', 'replaced.'])
         
     | 
| 
       1084 
     | 
    
         
            -
                  end
         
     | 
| 
       1085 
     | 
    
         
            -
             
     | 
| 
       1086 
     | 
    
         
            -
                  it 'modify existing node by DSL' do
         
     | 
| 
       1087 
     | 
    
         
            -
                    text = "1st line.\nfoobar(title)[level: 3] {\n in the section.\n}\n=: section 2."
         
     | 
| 
       1088 
     | 
    
         
            -
                    noramark = NoraMark::Document.parse(text, lang: 'ja')
         
     | 
| 
       1089 
     | 
    
         
            -
             
     | 
| 
       1090 
     | 
    
         
            -
                    noramark.add_transformer(generator: :html) do
         
     | 
| 
       1091 
     | 
    
         
            -
                      for_node 'foobar', :modify do
         
     | 
| 
       1092 
     | 
    
         
            -
                        @node.name = 'section'
         
     | 
| 
       1093 
     | 
    
         
            -
                        @node.prepend_child block("h#{@node.named_parameters[:level]}", @node.parameters[0])
         
     | 
| 
       1094 
     | 
    
         
            -
                      end
         
     | 
| 
       1095 
     | 
    
         
            -
                    end
         
     | 
| 
       1096 
     | 
    
         
            -
                    body = Nokogiri::XML::Document.parse(noramark.html[0]).root.at_xpath('xmlns:body')
         
     | 
| 
       1097 
     | 
    
         
            -
                    expect(body.element_children[0].selector_and_children()).to eq(
         
     | 
| 
       1098 
     | 
    
         
            -
                      ['div.pgroup', [ 'p', '1st line.' ]])
         
     | 
| 
       1099 
     | 
    
         
            -
                    expect(body.element_children[1].selector_and_children()).to eq(
         
     | 
| 
       1100 
     | 
    
         
            -
                      ['section', [ 'h3', 'title' ], ['div.pgroup',  ['p', 'in the section.']]])
         
     | 
| 
       1101 
     | 
    
         
            -
                    expect(body.element_children[2].selector_and_children()).to eq(
         
     | 
| 
       1102 
     | 
    
         
            -
                      ['section', [ 'h1','section 2.' ]])
         
     | 
| 
       1103 
     | 
    
         
            -
                  end
         
     | 
| 
       1104 
     | 
    
         
            -
                  it 'replace existing node by DSL' do
         
     | 
| 
       1105 
     | 
    
         
            -
                    text = "1st line.\nfoobar(title)[level: 3] {\n in the section.\n}\n=: section 2."
         
     | 
| 
       1106 
     | 
    
         
            -
                    noramark = NoraMark::Document.parse(text, lang: 'ja')
         
     | 
| 
       1107 
     | 
    
         
            -
             
     | 
| 
       1108 
     | 
    
         
            -
                    noramark.add_transformer(generator: :html) do
         
     | 
| 
       1109 
     | 
    
         
            -
                      for_node 'foobar', :replace do
         
     | 
| 
       1110 
     | 
    
         
            -
                        block('section',
         
     | 
| 
       1111 
     | 
    
         
            -
                               [
         
     | 
| 
       1112 
     | 
    
         
            -
                                block( "h#{@node.named_parameters[:level]}", @node.parameters[0]),
         
     | 
| 
       1113 
     | 
    
         
            -
                               ] + @node.children)
         
     | 
| 
       1114 
     | 
    
         
            -
                      end
         
     | 
| 
       1115 
     | 
    
         
            -
                    end
         
     | 
| 
       1116 
     | 
    
         
            -
                    body = Nokogiri::XML::Document.parse(noramark.html[0]).root.at_xpath('xmlns:body')
         
     | 
| 
       1117 
     | 
    
         
            -
                    expect(body.element_children[0].selector_and_children()).to eq(
         
     | 
| 
       1118 
     | 
    
         
            -
                      ['div.pgroup', [ 'p', '1st line.' ]])
         
     | 
| 
       1119 
     | 
    
         
            -
                    expect(body.element_children[1].selector_and_children()).to eq(
         
     | 
| 
       1120 
     | 
    
         
            -
                      ['section', [ 'h3', 'title' ], ['div.pgroup',  ['p', 'in the section.']]])
         
     | 
| 
       1121 
     | 
    
         
            -
                    expect(body.element_children[2].selector_and_children()).to eq(
         
     | 
| 
       1122 
     | 
    
         
            -
                      ['section', [ 'h1','section 2.' ]])
         
     | 
| 
       1123 
     | 
    
         
            -
                  end
         
     | 
| 
       1124 
     | 
    
         
            -
                  it 'generate complex-style headed section' do
         
     | 
| 
       1125 
     | 
    
         
            -
                    text = <<EOF
         
     | 
| 
       1126 
     | 
    
         
            -
            ---
         
     | 
| 
       1127 
     | 
    
         
            -
            lang: ja
         
     | 
| 
       1128 
     | 
    
         
            -
            ---
         
     | 
| 
       1129 
     | 
    
         
            -
             
     | 
| 
       1130 
     | 
    
         
            -
            =: 見出し
         
     | 
| 
       1131 
     | 
    
         
            -
            sub: 副見出し
         
     | 
| 
       1132 
     | 
    
         
            -
             
     | 
| 
       1133 
     | 
    
         
            -
            パラグラフ。
         
     | 
| 
       1134 
     | 
    
         
            -
            パラグラフ。
         
     | 
| 
       1135 
     | 
    
         
            -
             
     | 
| 
       1136 
     | 
    
         
            -
            EOF
         
     | 
| 
       1137 
     | 
    
         
            -
                    noramark = NoraMark::Document.parse(text)
         
     | 
| 
       1138 
     | 
    
         
            -
                    noramark.add_transformer(generator: :html) do
         
     | 
| 
       1139 
     | 
    
         
            -
                      for_node({:type => :HeadedSection}, :replace) do
         
     | 
| 
       1140 
     | 
    
         
            -
                        header = block('header',
         
     | 
| 
       1141 
     | 
    
         
            -
                                       block('div',
         
     | 
| 
       1142 
     | 
    
         
            -
                                             block("h#{@node.level}", @node.heading),
         
     | 
| 
       1143 
     | 
    
         
            -
                                             classes: ['hgroup'])) 
         
     | 
| 
       1144 
     | 
    
         
            -
                        if (fc = @node.first_child).name == 'sub'
         
     | 
| 
       1145 
     | 
    
         
            -
                          fc.name = 'p'
         
     | 
| 
       1146 
     | 
    
         
            -
                          fc.classes = ['subh']
         
     | 
| 
       1147 
     | 
    
         
            -
                          header.first_child.append_child fc 
         
     | 
| 
       1148 
     | 
    
         
            -
                        end
         
     | 
| 
       1149 
     | 
    
         
            -
                        body = block('div', @node.children, classes:['section-body'])
         
     | 
| 
       1150 
     | 
    
         
            -
                        block('section', [ header, body ], template: @node)
         
     | 
| 
       1151 
     | 
    
         
            -
                      end
         
     | 
| 
       1152 
     | 
    
         
            -
                    end
         
     | 
| 
       1153 
     | 
    
         
            -
                    body = Nokogiri::XML::Document.parse(noramark.html[0]).root.at_xpath('xmlns:body')
         
     | 
| 
       1154 
     | 
    
         
            -
                    expect(body.element_children[0].selector_and_children()).to eq(
         
     | 
| 
       1155 
     | 
    
         
            -
                           ['section', [ 'header', ['div.hgroup', ['h1', '見出し'], ['p.subh', '副見出し']]],
         
     | 
| 
       1156 
     | 
    
         
            -
                            ['div.section-body',
         
     | 
| 
       1157 
     | 
    
         
            -
                             ['div.pgroup', ['p', 'パラグラフ。'], ['p', 'パラグラフ。']]]])
         
     | 
| 
       1158 
     | 
    
         
            -
                  end
         
     | 
| 
       1159 
     | 
    
         
            -
                  it 'converts my markup' do
         
     | 
| 
       1160 
     | 
    
         
            -
                    text = "speak(Alice): Alice is speaking.\nspeak(Bob): and this is Bob."
         
     | 
| 
       1161 
     | 
    
         
            -
                    noramark = NoraMark::Document.parse(text)
         
     | 
| 
       1162 
     | 
    
         
            -
                    noramark.add_transformer(generator: :html) do
         
     | 
| 
       1163 
     | 
    
         
            -
                      for_node("speak", :modify) do
         
     | 
| 
       1164 
     | 
    
         
            -
                        @node.name = 'p'
         
     | 
| 
       1165 
     | 
    
         
            -
                        @node.prepend_child inline('span', @node.parameters[0], classes: ['speaker'])
         
     | 
| 
       1166 
     | 
    
         
            -
                      end
         
     | 
| 
       1167 
     | 
    
         
            -
                    end
         
     | 
| 
       1168 
     | 
    
         
            -
                    body = Nokogiri::XML::Document.parse(noramark.html[0]).root.at_xpath('xmlns:body')
         
     | 
| 
       1169 
     | 
    
         
            -
                    expect(body.element_children[0].selector_and_children()).to eq(
         
     | 
| 
       1170 
     | 
    
         
            -
                             ['p', ['span.speaker', 'Alice'], 'Alice is speaking.'])
         
     | 
| 
       1171 
     | 
    
         
            -
                    expect(body.element_children[1].selector_and_children()).to eq(
         
     | 
| 
       1172 
     | 
    
         
            -
                             ['p', ['span.speaker', 'Bob'], 'and this is Bob.'])
         
     | 
| 
       1173 
     | 
    
         
            -
             
     | 
| 
       1174 
     | 
    
         
            -
                  end
         
     | 
| 
       1175 
     | 
    
         
            -
                  
         
     | 
| 
       1176 
     | 
    
         
            -
             
     | 
| 
       1177 
     | 
    
         
            -
                  it 'should reparent tree' do
         
     | 
| 
       1178 
     | 
    
         
            -
                    text = <<EOF
         
     | 
| 
       1179 
     | 
    
         
            -
            1st line.
         
     | 
| 
       1180 
     | 
    
         
            -
            d {
         
     | 
| 
       1181 
     | 
    
         
            -
            in the div
         
     | 
| 
       1182 
     | 
    
         
            -
            }
         
     | 
| 
       1183 
     | 
    
         
            -
            *: ul item
         
     | 
| 
       1184 
     | 
    
         
            -
            text [s{with inline}] within
         
     | 
| 
       1185 
     | 
    
         
            -
            EOF
         
     | 
| 
       1186 
     | 
    
         
            -
                    root = NoraMark::Document.parse(text).root
         
     | 
| 
       1187 
     | 
    
         
            -
             
     | 
| 
       1188 
     | 
    
         
            -
                    expect(root.parent).to be nil
         
     | 
| 
       1189 
     | 
    
         
            -
                    expect(root.prev).to be nil
         
     | 
| 
       1190 
     | 
    
         
            -
                    expect(root.next).to be nil
         
     | 
| 
       1191 
     | 
    
         
            -
                    expect(root.content).to be nil
         
     | 
| 
       1192 
     | 
    
         
            -
             
     | 
| 
       1193 
     | 
    
         
            -
                    expect(root.children.size).to eq 1
         
     | 
| 
       1194 
     | 
    
         
            -
                    page = root.first_child
         
     | 
| 
       1195 
     | 
    
         
            -
                    expect(root.children[0]).to eq page
         
     | 
| 
       1196 
     | 
    
         
            -
                    expect(root.last_child).to eq page
         
     | 
| 
       1197 
     | 
    
         
            -
                    expect(page.parent).to eq root
         
     | 
| 
       1198 
     | 
    
         
            -
                    expect(page.prev).to be nil
         
     | 
| 
       1199 
     | 
    
         
            -
                    expect(page.next).to be nil
         
     | 
| 
       1200 
     | 
    
         
            -
             
     | 
| 
       1201 
     | 
    
         
            -
                    first_pgroup = page.first_child
         
     | 
| 
       1202 
     | 
    
         
            -
                    expect(first_pgroup.class).to be NoraMark::ParagraphGroup
         
     | 
| 
       1203 
     | 
    
         
            -
                    expect(first_pgroup.parent).to eq page
         
     | 
| 
       1204 
     | 
    
         
            -
                    expect(first_pgroup.children.size).to eq 1
         
     | 
| 
       1205 
     | 
    
         
            -
                    expect(first_pgroup.prev).to be nil
         
     | 
| 
       1206 
     | 
    
         
            -
             
     | 
| 
       1207 
     | 
    
         
            -
                    paragraph = first_pgroup.first_child
         
     | 
| 
       1208 
     | 
    
         
            -
                    expect(paragraph.class).to be NoraMark::Paragraph
         
     | 
| 
       1209 
     | 
    
         
            -
                    expect(paragraph.parent).to be first_pgroup
         
     | 
| 
       1210 
     | 
    
         
            -
                    expect(paragraph.prev).to be nil
         
     | 
| 
       1211 
     | 
    
         
            -
                    expect(paragraph.next).to be nil
         
     | 
| 
       1212 
     | 
    
         
            -
                    expect(paragraph.children.size).to eq 1
         
     | 
| 
       1213 
     | 
    
         
            -
                    text = paragraph.first_child
         
     | 
| 
       1214 
     | 
    
         
            -
                    expect(text.class).to be NoraMark::Text
         
     | 
| 
       1215 
     | 
    
         
            -
                    expect(text.content).to eq '1st line.'
         
     | 
| 
       1216 
     | 
    
         
            -
                    expect(text.children.size).to eq 0
         
     | 
| 
       1217 
     | 
    
         
            -
                    expect(text.prev).to be nil
         
     | 
| 
       1218 
     | 
    
         
            -
                    expect(text.next).to be nil
         
     | 
| 
       1219 
     | 
    
         
            -
                    expect(text.parent).to eq paragraph
         
     | 
| 
       1220 
     | 
    
         
            -
             
     | 
| 
       1221 
     | 
    
         
            -
                    second_div = first_pgroup.next
         
     | 
| 
       1222 
     | 
    
         
            -
                    expect(second_div.class).to be NoraMark::Block
         
     | 
| 
       1223 
     | 
    
         
            -
                  end
         
     | 
| 
       1224 
     | 
    
         
            -
                end
         
     | 
| 
       1225 
1334 
     | 
    
         
             
                describe 'table of contents' do
         
     | 
| 
       1226 
1335 
     | 
    
         
             
                  before do
         
     | 
| 
       1227 
1336 
     | 
    
         
             
                    @text = <<EOF
         
     | 
| 
         @@ -1229,9 +1338,9 @@ EOF 
     | 
|
| 
       1229 
1338 
     | 
    
         
             
            lang: ja
         
     | 
| 
       1230 
1339 
     | 
    
         
             
            title: title
         
     | 
| 
       1231 
1340 
     | 
    
         
             
            ---
         
     | 
| 
       1232 
     | 
    
         
            -
             
     | 
| 
      
 1341 
     | 
    
         
            +
            # [strong{chapter 1}]
         
     | 
| 
       1233 
1342 
     | 
    
         
             
            text
         
     | 
| 
       1234 
     | 
    
         
            -
             
     | 
| 
      
 1343 
     | 
    
         
            +
            ## section 1-1
         
     | 
| 
       1235 
1344 
     | 
    
         
             
            text
         
     | 
| 
       1236 
1345 
     | 
    
         
             
            newpage:
         
     | 
| 
       1237 
1346 
     | 
    
         
             
            section {
         
     | 
| 
         @@ -1254,11 +1363,66 @@ EOF 
     | 
|
| 
       1254 
1363 
     | 
    
         
             
                  it 'should generate tocs' do
         
     | 
| 
       1255 
1364 
     | 
    
         
             
                    toc = @noramark.html.toc
         
     | 
| 
       1256 
1365 
     | 
    
         
             
                    expect(toc.size).to eq 3
         
     | 
| 
       1257 
     | 
    
         
            -
                    expect(toc[0]) 
     | 
| 
       1258 
     | 
    
         
            -
             
     | 
| 
       1259 
     | 
    
         
            -
                    expect(toc[ 
     | 
| 
      
 1366 
     | 
    
         
            +
                    expect(toc[0])
         
     | 
| 
      
 1367 
     | 
    
         
            +
                      .to eq({link: "nora_00001.xhtml#heading_index_1", level: 1, text: "chapter 1"})
         
     | 
| 
      
 1368 
     | 
    
         
            +
                    expect(toc[1])
         
     | 
| 
      
 1369 
     | 
    
         
            +
                      .to eq({link: "nora_00001.xhtml#heading_index_2", level: 2, text: "section 1-1"})
         
     | 
| 
      
 1370 
     | 
    
         
            +
                    expect(toc[2])
         
     | 
| 
      
 1371 
     | 
    
         
            +
                      .to eq({link: "nora_00002.xhtml#heading_index_3", level: 6, text: "some column"})
         
     | 
| 
       1260 
1372 
     | 
    
         
             
                  end
         
     | 
| 
       1261 
1373 
     | 
    
         
             
                end
         
     | 
| 
      
 1374 
     | 
    
         
            +
                it 'should raise error' do
         
     | 
| 
      
 1375 
     | 
    
         
            +
                  text = "d {\n block is\nd {\n nested but\nd {\n not terminated }"
         
     | 
| 
      
 1376 
     | 
    
         
            +
                  expect { NoraMark::Document.parse(text, lang: 'ja', title: 'foo') }.to raise_error KPeg::CompiledParser::ParseError
         
     | 
| 
      
 1377 
     | 
    
         
            +
                end
         
     | 
| 
      
 1378 
     | 
    
         
            +
              end
         
     | 
| 
      
 1379 
     | 
    
         
            +
              describe 'video' do
         
     | 
| 
      
 1380 
     | 
    
         
            +
                it 'should render video' do
         
     | 
| 
      
 1381 
     | 
    
         
            +
                  text = "this text includes [video(video.mp4)[poster: poster.jpg]{alternate message}]"
         
     | 
| 
      
 1382 
     | 
    
         
            +
                  nora = NoraMark::Document.parse(text)
         
     | 
| 
      
 1383 
     | 
    
         
            +
                  converted = nora.html
         
     | 
| 
      
 1384 
     | 
    
         
            +
                  body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 1385 
     | 
    
         
            +
                  expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 1386 
     | 
    
         
            +
                    .to eq(
         
     | 
| 
      
 1387 
     | 
    
         
            +
                           ['p', 'this text includes ',
         
     | 
| 
      
 1388 
     | 
    
         
            +
                            ["video[src='video.mp4'][poster='poster.jpg']", 'alternate message']]
         
     | 
| 
      
 1389 
     | 
    
         
            +
                           )
         
     | 
| 
      
 1390 
     | 
    
         
            +
                end
         
     | 
| 
      
 1391 
     | 
    
         
            +
                it 'should render video with autoplay and controls' do
         
     | 
| 
      
 1392 
     | 
    
         
            +
                  text = "this text includes [video(video.mp4, autoplay, controls)[poster: poster.jpg]]"
         
     | 
| 
      
 1393 
     | 
    
         
            +
                  nora = NoraMark::Document.parse(text)
         
     | 
| 
      
 1394 
     | 
    
         
            +
                  converted = nora.html
         
     | 
| 
      
 1395 
     | 
    
         
            +
                  body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 1396 
     | 
    
         
            +
                  expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 1397 
     | 
    
         
            +
                    .to eq(
         
     | 
| 
      
 1398 
     | 
    
         
            +
                           ['p', 'this text includes ',
         
     | 
| 
      
 1399 
     | 
    
         
            +
                            ["video[src='video.mp4'][poster='poster.jpg'][autoplay='autoplay'][controls='controls']", '']]
         
     | 
| 
      
 1400 
     | 
    
         
            +
                           )
         
     | 
| 
      
 1401 
     | 
    
         
            +
                end
         
     | 
| 
      
 1402 
     | 
    
         
            +
              end
         
     | 
| 
      
 1403 
     | 
    
         
            +
              describe 'audio' do
         
     | 
| 
      
 1404 
     | 
    
         
            +
                it 'should render audio' do
         
     | 
| 
      
 1405 
     | 
    
         
            +
                  text = "this text includes [audio(audio.mp3)[volume: 0.2]{alternate message}]"
         
     | 
| 
      
 1406 
     | 
    
         
            +
                  nora = NoraMark::Document.parse(text)
         
     | 
| 
      
 1407 
     | 
    
         
            +
                  converted = nora.html
         
     | 
| 
      
 1408 
     | 
    
         
            +
                  body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 1409 
     | 
    
         
            +
                  expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 1410 
     | 
    
         
            +
                    .to eq(
         
     | 
| 
      
 1411 
     | 
    
         
            +
                           ['p', 'this text includes ',
         
     | 
| 
      
 1412 
     | 
    
         
            +
                            ["audio[src='audio.mp3'][volume='0.2']", 'alternate message']]
         
     | 
| 
      
 1413 
     | 
    
         
            +
                           )
         
     | 
| 
      
 1414 
     | 
    
         
            +
                end
         
     | 
| 
      
 1415 
     | 
    
         
            +
                it 'should render audio with autoplay and controls' do
         
     | 
| 
      
 1416 
     | 
    
         
            +
                  text = "this text includes [audio(audio.mp3, autoplay, controls)]"
         
     | 
| 
      
 1417 
     | 
    
         
            +
                  nora = NoraMark::Document.parse(text)
         
     | 
| 
      
 1418 
     | 
    
         
            +
                  converted = nora.html
         
     | 
| 
      
 1419 
     | 
    
         
            +
                  body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
         
     | 
| 
      
 1420 
     | 
    
         
            +
                  expect(body.element_children[0].selector_and_children)
         
     | 
| 
      
 1421 
     | 
    
         
            +
                    .to eq(
         
     | 
| 
      
 1422 
     | 
    
         
            +
                           ['p', 'this text includes ',
         
     | 
| 
      
 1423 
     | 
    
         
            +
                            ["audio[src='audio.mp3'][autoplay='autoplay'][controls='controls']", '']]
         
     | 
| 
      
 1424 
     | 
    
         
            +
                           )
         
     | 
| 
      
 1425 
     | 
    
         
            +
                end
         
     | 
| 
       1262 
1426 
     | 
    
         
             
              end
         
     | 
| 
       1263 
1427 
     | 
    
         
             
            end
         
     | 
| 
       1264 
1428 
     | 
    
         |