diff --git a/lib/coradoc.rb b/lib/coradoc.rb index b6caa6f..0e495bd 100644 --- a/lib/coradoc.rb +++ b/lib/coradoc.rb @@ -7,6 +7,7 @@ require "coradoc/parser" require "coradoc/transformer" +require "coradoc/generator" module Coradoc class Error < StandardError; end diff --git a/lib/coradoc/document.rb b/lib/coradoc/document.rb index 514b6ed..4a0a733 100644 --- a/lib/coradoc/document.rb +++ b/lib/coradoc/document.rb @@ -12,6 +12,11 @@ require "coradoc/document/table" require "coradoc/document/list" +require "coradoc/document/inline" +require "coradoc/document/audio" +require "coradoc/document/video" +require "coradoc/document/break" + module Coradoc module Document class << self diff --git a/lib/coradoc/document/audio.rb b/lib/coradoc/document/audio.rb new file mode 100644 index 0000000..87f7266 --- /dev/null +++ b/lib/coradoc/document/audio.rb @@ -0,0 +1,26 @@ +module Coradoc + module Document + class Audio + attr_reader :id, :title, :src, :options + + def initialize(title, options = {}) + @title = title + @id = options.fetch(:id, nil) + @src = options.fetch(:src, '') + @options = options.fetch(:options, []) + end + + def to_adoc + anchor = @id ? "[[#{@id}]]\n" : "" + title = ".#{@title}\n" unless @title.empty? + + opts = "" + if @options.any? + opts = %{options="#{@options.join(',')}"} + end + + [anchor, title, "audio::", @src, "[", opts, "]"].join("") + end + end + end +end diff --git a/lib/coradoc/document/block.rb b/lib/coradoc/document/block.rb index 232077f..8a9ff57 100644 --- a/lib/coradoc/document/block.rb +++ b/lib/coradoc/document/block.rb @@ -1,7 +1,7 @@ module Coradoc module Document class Block - attr_reader :title, :lines, :attributes + attr_reader :title, :lines, :attributes, :lang, :id def initialize(title, options = {}) @title = title @@ -9,12 +9,33 @@ def initialize(title, options = {}) @type_str = options.fetch(:type, nil) @delimiter = options.fetch(:delimiter, "") @attributes = options.fetch(:attributes, {}) + @lang = options.fetch(:lang, nil) + @id = options.fetch(:id, nil) end def type @type ||= defined_type || type_from_delimiter end + def to_adoc + lines = Coradoc::Generator.gen_adoc(@lines) + if type == :quote + "\n\n#{@attributes}____\n" << lines << "\n____\n\n" + elsif type == :source && @lang + anchor = @id ? "[[#{@id}]]\n" : "" + "\n\n#{anchor}[source,#{@lang}]\n----\n" << lines << "\n----\n\n" + elsif type == :literal + anchor = @id ? "[[#{@id}]]\n" : "" + "\n\n#{anchor}....\n" << lines << "\n....\n\n" + elsif type == :side + "\n\n****\n" << lines << "\n****\n\n" + elsif type == :example + anchor = @id ? "[[#{@id}]]\n" : "" + title = ".#{@title}\n" unless @title.empty? + "\n\n#{anchor}#{title}====\n" << lines << "\n====\n\n" + end + end + private def defined_type @@ -31,6 +52,7 @@ def type_hash "****" => :side, "----" => :source, "====" => :example, + "...." => :literal } end end diff --git a/lib/coradoc/document/break.rb b/lib/coradoc/document/break.rb new file mode 100644 index 0000000..5759c24 --- /dev/null +++ b/lib/coradoc/document/break.rb @@ -0,0 +1,11 @@ +module Coradoc + module Document + module Break + class ThematicBreak + def to_adoc + "\n* * *\n" + end + end + end + end +end diff --git a/lib/coradoc/document/header.rb b/lib/coradoc/document/header.rb index f54149b..5baa79f 100644 --- a/lib/coradoc/document/header.rb +++ b/lib/coradoc/document/header.rb @@ -7,5 +7,9 @@ def initialize(title, options = {}) @author = options.fetch(:author, nil) @revision = options.fetch(:revision, nil) end + + def to_adoc + "= #{title}\n:stem:\n\n" + end end end diff --git a/lib/coradoc/document/inline.rb b/lib/coradoc/document/inline.rb new file mode 100644 index 0000000..9878987 --- /dev/null +++ b/lib/coradoc/document/inline.rb @@ -0,0 +1,19 @@ +require "coradoc/document/inline/anchor" +require "coradoc/document/inline/bold" +require "coradoc/document/inline/hard_line_break" +require "coradoc/document/inline/highlight" +require "coradoc/document/inline/image" +require "coradoc/document/inline/italic" +require "coradoc/document/inline/monospace" +require "coradoc/document/inline/quotation" +require "coradoc/document/inline/subscript" +require "coradoc/document/inline/superscript" + +module Coradoc + module Document + module Inline + class << self + end + end + end +end diff --git a/lib/coradoc/document/inline/anchor.rb b/lib/coradoc/document/inline/anchor.rb new file mode 100644 index 0000000..e735e46 --- /dev/null +++ b/lib/coradoc/document/inline/anchor.rb @@ -0,0 +1,39 @@ +module Coradoc + module Document + module Inline + class Anchor + attr_reader :id, :href, :title, :name + + def initialize(options = {}) + @id = options.fetch(:id,nil) + @href = options.fetch(:href,nil) + @title = options.fetch(:title, nil) + @name = options.fetch(:name,nil) + end + + def to_adoc + if /^_Toc\d+$|^_GoBack$/.match @id + "" + elsif !@id.nil? && !@id.empty? + "[[#{@id}]]" + elsif @href.to_s.start_with?('#') + @href = @href.sub(/^#/, "").gsub(/\s/, "").gsub(/__+/, "_") + if @name.to_s.empty? + "<<#{@href}>>" + else + "<<#{@href},#{@name}>>" + end + elsif @href.to_s.empty? + @name + else + @name = @title if @name.to_s.empty? + @href = "link:#{@href}" unless @href.to_s =~ URI::DEFAULT_PARSER.make_regexp + link = "#{@href}[#{@name}]" + link.prepend(' ') + link + end + end + end + end + end +end diff --git a/lib/coradoc/document/inline/bold.rb b/lib/coradoc/document/inline/bold.rb new file mode 100644 index 0000000..73447a0 --- /dev/null +++ b/lib/coradoc/document/inline/bold.rb @@ -0,0 +1,16 @@ +module Coradoc + module Document + module Inline + class Bold + attr_accessor :content + def initialize(content) + @content = content + end + def to_adoc + content = Coradoc::Generator.gen_adoc(@content) + "#{content[/^\s*/]}*#{content.strip}*#{content[/\s*$/]}" + end + end + end + end +end diff --git a/lib/coradoc/document/inline/hard_line_break.rb b/lib/coradoc/document/inline/hard_line_break.rb new file mode 100644 index 0000000..a0b08ec --- /dev/null +++ b/lib/coradoc/document/inline/hard_line_break.rb @@ -0,0 +1,11 @@ +module Coradoc + module Document + module Inline + class HardLineBreak + def to_adoc + " +\n" + end + end + end + end +end diff --git a/lib/coradoc/document/inline/highlight.rb b/lib/coradoc/document/inline/highlight.rb new file mode 100644 index 0000000..f103db0 --- /dev/null +++ b/lib/coradoc/document/inline/highlight.rb @@ -0,0 +1,16 @@ +module Coradoc + module Document + module Inline + class Highlight + attr_accessor :content + def initialize(content) + @content = content + end + def to_adoc + content = Coradoc::Generator.gen_adoc(@content) + "#{content[/^\s*/]}##{content.strip}##{content[/\s*$/]}" + end + end + end + end +end diff --git a/lib/coradoc/document/inline/image.rb b/lib/coradoc/document/inline/image.rb new file mode 100644 index 0000000..e43b5c2 --- /dev/null +++ b/lib/coradoc/document/inline/image.rb @@ -0,0 +1,26 @@ +module Coradoc + module Document + module Inline + class Image + attr_reader :id, :title, :src, :alt, :width, :height + def initialize(options = ()) + @id = options.fetch(:id, nil) + @title = options.fetch(:title, nil) + @src = options.fetch(:src, nil) + @alt = options.fetch(:alt, nil) + @width = options.fetch(:width, nil) + @height = options.fetch(:height, nil) + end + def to_adoc + anchor = @id ? "[[#{@id}]]\n" : "" + title = ".#{@title}\n" unless @title.empty? + attrs = @alt + attrs = "\"\"" if (@width || @height) && @alt.nil? + attrs += ",#{@width}" if @width + attrs += ",#{@height}" if @width && @height + [anchor, title, "image::", src, "[", attrs, "]"].join("") + end + end + end + end +end diff --git a/lib/coradoc/document/inline/italic.rb b/lib/coradoc/document/inline/italic.rb new file mode 100644 index 0000000..1e9dd8e --- /dev/null +++ b/lib/coradoc/document/inline/italic.rb @@ -0,0 +1,16 @@ +module Coradoc + module Document + module Inline + class Italic + attr_accessor :content + def initialize(content) + @content = content + end + def to_adoc + content = Coradoc::Generator.gen_adoc(@content) + "#{content[/^\s*/]}_#{content.strip}_#{content[/\s*$/]}" + end + end + end + end +end diff --git a/lib/coradoc/document/inline/monospace.rb b/lib/coradoc/document/inline/monospace.rb new file mode 100644 index 0000000..2563466 --- /dev/null +++ b/lib/coradoc/document/inline/monospace.rb @@ -0,0 +1,16 @@ +module Coradoc + module Document + module Inline + class Monospace + attr_accessor :content + def initialize(content) + @content = content + end + def to_adoc + content = Coradoc::Generator.gen_adoc(@content) + "`#{content}`" + end + end + end + end +end diff --git a/lib/coradoc/document/inline/quotation.rb b/lib/coradoc/document/inline/quotation.rb new file mode 100644 index 0000000..718e5cc --- /dev/null +++ b/lib/coradoc/document/inline/quotation.rb @@ -0,0 +1,16 @@ +module Coradoc + module Document + module Inline + class Quotation + attr_accessor :content + def initialize(content) + @content = content + end + def to_adoc + content = Coradoc::Generator.gen_adoc(@content) + "#{content[/^\s*/]}\"#{content.strip}\"#{content[/\s*$/]}" + end + end + end + end +end diff --git a/lib/coradoc/document/inline/subscript.rb b/lib/coradoc/document/inline/subscript.rb new file mode 100644 index 0000000..4895007 --- /dev/null +++ b/lib/coradoc/document/inline/subscript.rb @@ -0,0 +1,17 @@ +module Coradoc + module Document + module Inline + class Subscript + attr_accessor :content + def initialize(content) + @content = content + end + + def to_adoc + content = Coradoc::Generator.gen_adoc(@content) + "#{content[/^\s*/]}~#{content.strip}~#{content[/\s*$/]}" + end + end + end + end +end diff --git a/lib/coradoc/document/inline/superscript.rb b/lib/coradoc/document/inline/superscript.rb new file mode 100644 index 0000000..720f370 --- /dev/null +++ b/lib/coradoc/document/inline/superscript.rb @@ -0,0 +1,16 @@ +module Coradoc + module Document + module Inline + class Superscript + attr_accessor :content + def initialize(content) + @content = content + end + def to_adoc + content = Coradoc::Generator.gen_adoc(@content) + "#{content[/^\s*/]}^#{content.strip}^#{content[/\s*$/]}" + end + end + end + end +end diff --git a/lib/coradoc/document/list.rb b/lib/coradoc/document/list.rb index 226d49e..1668fdd 100644 --- a/lib/coradoc/document/list.rb +++ b/lib/coradoc/document/list.rb @@ -1,13 +1,49 @@ module Coradoc module Document class List - attr_reader :items + attr_reader :items, :prefix, :id, :ol_count - def initialize(items) + def initialize(items, options = {}) @items = items + @items = [@items] unless @items.is_a?(Array) + @id = options.fetch(:id, nil) + @ol_count = options.fetch(:ol_count, 0) + @anchor = options.fetch(:anchor, nil) + @attrs = options.fetch(:attrs, nil) end - class Unnumbered < List + def to_adoc + content = "" + @items.each do |item| + c = Coradoc::Generator.gen_adoc(item) + if !c.empty? + content << "#{prefix}" + content << c + end + end + "\n#{@anchor}#{@attrs}" + content + end + + + def prefix + "." * [@ol_count, 0].max + end + + class Unordered < List + def prefix + "*" * [@ol_count, 0].max + end + end + + class Item + def initialize(content, options = {}) + @content = content + @anchor = options.fetch(:anchor, '') + end + def to_adoc + content = Coradoc::Generator.gen_adoc(@content) + " #{@anchor}#{content.chomp}\n" + end end end end diff --git a/lib/coradoc/document/paragraph.rb b/lib/coradoc/document/paragraph.rb index 45a616d..1364abd 100644 --- a/lib/coradoc/document/paragraph.rb +++ b/lib/coradoc/document/paragraph.rb @@ -1,11 +1,13 @@ module Coradoc module Document class Paragraph - attr_reader :content + attr_reader :content, :id, :tdsinglepara def initialize(content, options = {}) @content = content @meta = options.fetch(:meta, nil) + @id = options.fetch(:id, nil) + @tdsinglepara = options.fetch(:tdsinglepara, nil) end def id @@ -15,6 +17,15 @@ def id def texts content.map(&:content) end + + def to_adoc + anchor = @id ? "[[#{@id}]]\n" : "" + if @tdsinglepara + "#{anchor}" << Coradoc::Generator.gen_adoc(@content).strip + else + "\n\n#{anchor}" << Coradoc::Generator.gen_adoc(@content).strip << "\n\n" + end + end end end end diff --git a/lib/coradoc/document/section.rb b/lib/coradoc/document/section.rb index 77a63bf..03b21f3 100644 --- a/lib/coradoc/document/section.rb +++ b/lib/coradoc/document/section.rb @@ -20,6 +20,12 @@ def content end end + def to_adoc + anchor = !@id.empty? ? "[[#{@id}]]\n" : "" + content = Coradoc::Generator.gen_adoc(@contents) + "\n#{anchor}" << content << "\n" + end + private def extract_glossaries diff --git a/lib/coradoc/document/table.rb b/lib/coradoc/document/table.rb index f42b018..c885749 100644 --- a/lib/coradoc/document/table.rb +++ b/lib/coradoc/document/table.rb @@ -1,18 +1,62 @@ module Coradoc module Document class Table - attr_reader :title, :rows + attr_reader :title, :rows, :content, :id - def initialize(title, rows) + def initialize(title, rows, options = {}) @rows = rows @title = title + @id = options.fetch(:id, nil) + @attrs = options.fetch(:attrs, '') + end + + + def to_adoc + anchor = @id ? "[[#{@id}]]\n" : "" + attrs = @attrs + title = @title + content = Coradoc::Generator.gen_adoc(@rows) + "\n\n#{anchor}#{attrs}#{title}|===\n" << content << "\n|===\n" end class Row - attr_reader :columns + attr_reader :columns, :header - def initialize(columns) + def initialize(columns, header = false) @columns = columns + @header = header + end + + def table_header_row? + @header + end + + def to_adoc + content = Coradoc::Generator.gen_adoc(@columns).rstrip + result = "#{content}\n" + table_header_row? ? result + underline_for : result + end + + def underline_for + "\n" + end + + end + class Cell + attr_reader :id + def initialize(options = {}) + @id = options.fetch(:id, nil) + @colrowattr = options.fetch(:colrowattr, '') + @alignattr = options.fetch(:alignattr, '') + @style = options.fetch(:style, '') + @content = options.fetch(:content, '') + @delim = options.fetch(:delim, '') + end + + def to_adoc + anchor = @id ? "[[#{@id}]]" : "" + content = Coradoc::Generator.gen_adoc(@content) + "#{@colrowattr}#{@alignattr}#{@style}| #{anchor}#{content}#{@delim}" end end end diff --git a/lib/coradoc/document/text_element.rb b/lib/coradoc/document/text_element.rb index 26e9a08..58abb05 100644 --- a/lib/coradoc/document/text_element.rb +++ b/lib/coradoc/document/text_element.rb @@ -7,6 +7,10 @@ def initialize(content, options = {}) @id = options.fetch(:id, nil) @line_break = options.fetch(:line_break, "") end + + def to_adoc + @content + end end class Document::LineBreak diff --git a/lib/coradoc/document/title.rb b/lib/coradoc/document/title.rb index 2a63b2e..bfcd18f 100644 --- a/lib/coradoc/document/title.rb +++ b/lib/coradoc/document/title.rb @@ -8,12 +8,19 @@ def initialize(content, level, options = {}) @content = content.to_s @id = options.fetch(:id, nil).to_s @line_break = options.fetch(:line_break, "") + @anchor = options.fetch(:anchor, nil) end def level @level ||= level_from_string end + def to_adoc + content = Coradoc::Generator.gen_adoc(@content) + content = ["\n", @anchor, @level_str, ' ', content, "\n"].join("") + Coradoc::Generator.gen_adoc(content) + end + alias :text :content private diff --git a/lib/coradoc/document/video.rb b/lib/coradoc/document/video.rb new file mode 100644 index 0000000..bd6bfb4 --- /dev/null +++ b/lib/coradoc/document/video.rb @@ -0,0 +1,26 @@ +module Coradoc + module Document + class Video + attr_reader :id, :title, :src, :options + + def initialize(title, options = {}) + @title = title + @id = options.fetch(:id, nil) + @src = options.fetch(:src, '') + @options = options.fetch(:options, []) + end + + def to_adoc + anchor = @id ? "[[#{@id}]]\n" : "" + title = ".#{@title}\n" unless @title.empty? + + opts = "" + if @options.any? + opts = %{options="#{@options.join(',')}"} + end + + [anchor, title, "video::", @src, "[", opts, "]"].join("") + end + end + end +end diff --git a/lib/coradoc/generator.rb b/lib/coradoc/generator.rb new file mode 100644 index 0000000..d33dd44 --- /dev/null +++ b/lib/coradoc/generator.rb @@ -0,0 +1,17 @@ +module Coradoc + class Generator + def self.gen_adoc(content) + if content.is_a?(Array) + content.map do |elem| + Coradoc::Generator.gen_adoc(elem) + end.join('') + elsif content.respond_to? :to_adoc + content.to_adoc + elsif content.is_a?(String) + content + elsif content.nil? + '' + end + end + end +end diff --git a/lib/coradoc/legacy_parser.rb b/lib/coradoc/legacy_parser.rb index 945a39f..dd64828 100644 --- a/lib/coradoc/legacy_parser.rb +++ b/lib/coradoc/legacy_parser.rb @@ -85,15 +85,15 @@ class LegacyParser < Parslet::Parser # List rule(:list) do - unnumbered_list.as(:unnumbered) | - definition_list.as(:definition) | numbered_list.as(:numbered) + unordered_list.as(:unordered) | + definition_list.as(:definition) | ordered_list.as(:ordered) end - rule(:numbered_list) { nlist_item.repeat(1) } - rule(:unnumbered_list) { ulist_item.repeat(1) } + rule(:ordered_list) { olist_item.repeat(1) } + rule(:unordered_list) { ulist_item.repeat(1) } rule(:definition_list) { dlist_item.repeat(1) } - rule(:nlist_item) { match("\.") >> space >> text_line } + rule(:olist_item) { match("\.") >> space >> text_line } rule(:ulist_item) { match("\\*") >> space >> text_line } rule(:dlist_item) do str("term") >> space >> digits >> str("::") >> space >> text_line diff --git a/lib/coradoc/parser/asciidoc/content.rb b/lib/coradoc/parser/asciidoc/content.rb index 78ff93c..9990ff2 100644 --- a/lib/coradoc/parser/asciidoc/content.rb +++ b/lib/coradoc/parser/asciidoc/content.rb @@ -15,8 +15,8 @@ def glossaries # List def list - unnumbered_list.as(:unnumbered) | - definition_list.as(:definition) | numbered_list.as(:numbered) + unordered_list.as(:unordered) | + definition_list.as(:definition) | ordered_list.as(:ordered) end def contents @@ -140,11 +140,11 @@ def glossary text.as(:value) >> line_ending.as(:break) end - def numbered_list - nlist_item.repeat(1) + def ordered_list + olist_item.repeat(1) end - def unnumbered_list + def unordered_list (ulist_item >> newline.maybe).repeat(1) end @@ -152,7 +152,7 @@ def definition_list dlist_item.repeat(1) end - def nlist_item + def olist_item match("\.") >> space >> text_line end diff --git a/lib/coradoc/transformer.rb b/lib/coradoc/transformer.rb index cf8fa90..7a1ef8f 100644 --- a/lib/coradoc/transformer.rb +++ b/lib/coradoc/transformer.rb @@ -155,8 +155,8 @@ class Transformer < Parslet::Transform # List rule(list: simple(:list)) { list } - rule(unnumbered: sequence(:list_items)) do - Document::List::Unnumbered.new(list_items) + rule(unordered: sequence(:list_items)) do + Document::List::Unordered.new(list_items) end # Highlight diff --git a/spec/coradoc/document/list_spec.rb b/spec/coradoc/document/list_spec.rb index c2de08e..248b597 100644 --- a/spec/coradoc/document/list_spec.rb +++ b/spec/coradoc/document/list_spec.rb @@ -5,7 +5,7 @@ it "initializes and exposes list" do items = ["Item 1", "Item 2", "Item 3"] - list = Coradoc::Document::List::Unnumbered.new(items) + list = Coradoc::Document::List::Unordered.new(items) expect(list.items).to eq(items) end diff --git a/spec/coradoc/legacy_parser_spec.rb b/spec/coradoc/legacy_parser_spec.rb index 812313d..e987262 100644 --- a/spec/coradoc/legacy_parser_spec.rb +++ b/spec/coradoc/legacy_parser_spec.rb @@ -13,8 +13,8 @@ expect_document_to_match_section_with_body(document[2]) expect_document_to_match_section_titles(document[3..10]) expect_document_to_match_inline_formatting(document[11]) - expect_document_to_match_numbered_list_section(document[12]) - expect_document_to_match_unnumbered_list_section(document[13]) + expect_document_to_match_ordered_list_section(document[12]) + expect_document_to_match_unordered_list_section(document[13]) expect_document_to_match_definition_list_section(document[14]) expect_document_to_match_basic_block_sections(document[16]) expect_document_to_match_the_top_lavel_block(document[17]) @@ -210,30 +210,30 @@ def expect_document_to_match_definition_list_section(doc) expect(list[5][:text]).to eq("definition list item 15") end - def expect_document_to_match_unnumbered_list_section(doc) + def expect_document_to_match_unordered_list_section(doc) section = doc[:section] - list = section[:list][:unnumbered] + list = section[:list][:unordered] expect(section[:title][:level]).to eq("==") - expect(section[:title][:text]).to eq("Unnumbered list") - expect(section[:list][:unnumbered].count).to eq(5) + expect(section[:title][:text]).to eq("Unordered list") + expect(section[:list][:unordered].count).to eq(5) - expect(list[0][:text]).to eq("Unnumbered list item 1") - expect(list[2][:text]).to eq("Unnumbered list item 3") - expect(list[4][:text]).to eq("Unnumbered list item 5") + expect(list[0][:text]).to eq("Unordered list item 1") + expect(list[2][:text]).to eq("Unordered list item 3") + expect(list[4][:text]).to eq("Unordered list item 5") end - def expect_document_to_match_numbered_list_section(doc) + def expect_document_to_match_ordered_list_section(doc) section = doc[:section] - numbered_list = section[:list][:numbered] + ordered_list = section[:list][:ordered] expect(section[:title][:level]).to eq("==") - expect(section[:title][:text]).to eq("Numbered list") - expect(section[:list][:numbered].count).to eq(5) + expect(section[:title][:text]).to eq("Ordered list") + expect(section[:list][:ordered].count).to eq(5) - expect(numbered_list[0][:text]).to eq("Numbered list item 1") - expect(numbered_list[2][:text]).to eq("Numbered list item 3") - expect(numbered_list[4][:text]).to eq("Numbered list item 5") + expect(ordered_list[0][:text]).to eq("Ordered list item 1") + expect(ordered_list[2][:text]).to eq("Ordered list item 3") + expect(ordered_list[4][:text]).to eq("Ordered list item 5") end def expect_document_to_match_inline_formatting(doc) diff --git a/spec/coradoc/parser/asciidoc/content_spec.rb b/spec/coradoc/parser/asciidoc/content_spec.rb index eea6775..9eac1d0 100644 --- a/spec/coradoc/parser/asciidoc/content_spec.rb +++ b/spec/coradoc/parser/asciidoc/content_spec.rb @@ -208,18 +208,18 @@ it "parses list embeded in the content" do content = <<~DOC - * Unnumbered list item 1 - * Unnumbered list item 2 - * [[list_item_id]] Unnumbered list item 3 + * Unordered list item 1 + * Unordered list item 2 + * [[list_item_id]] Unordered list item 3 DOC ast = Asciidoc::ContentTester.parse(content) - list_items = ast[0][:list][:unnumbered] + list_items = ast[0][:list][:unordered] expect(list_items.count).to eq(3) - expect(list_items[0][:text]).to eq("Unnumbered list item 1") + expect(list_items[0][:text]).to eq("Unordered list item 1") expect(list_items[2][:id]).to eq("list_item_id") - expect(list_items[2][:text]).to eq("Unnumbered list item 3") + expect(list_items[2][:text]).to eq("Unordered list item 3") end it "parses the table block" do diff --git a/spec/coradoc/parser/asciidoc/section_spec.rb b/spec/coradoc/parser/asciidoc/section_spec.rb index 7296541..e6190c7 100644 --- a/spec/coradoc/parser/asciidoc/section_spec.rb +++ b/spec/coradoc/parser/asciidoc/section_spec.rb @@ -143,7 +143,7 @@ ast = Asciidoc::SectionTester.parse(section) section = ast[0] - list_items = section[:contents].first[:list][:unnumbered] + list_items = section[:contents].first[:list][:unordered] expect(section[:id]).to eq("section_id") expect(section[:title][:text]).to eq("Section title") diff --git a/spec/coradoc/parser_spec.rb b/spec/coradoc/parser_spec.rb index 6fd23a2..a869ffa 100644 --- a/spec/coradoc/parser_spec.rb +++ b/spec/coradoc/parser_spec.rb @@ -42,15 +42,15 @@ expect(guidance[:contents][0][:paragraph][:lines][0][:id]).to eq("guidance_5.1_part_1") expect(guidance[:contents][1][:paragraph][:lines][0][:id]).to eq("guidance_5.1_part_2") - list_one_items = guidance[:contents][2][:list][:unnumbered] + list_one_items = guidance[:contents][2][:list][:unordered] expect(list_one_items.count).to eq(3) expect(list_one_items[0][:text]).not_to be_nil expect(list_one_items[0][:id]).to eq("guidance_5.1_part_2_1") expect(guidance[:contents][3][:paragraph][:lines][0][:id]).not_to be_nil - expect(guidance[:contents][4][:list][:unnumbered].count).to eq(7) - expect(guidance[:contents][8][:list][:unnumbered].count).to eq(12) - expect(guidance[:contents][10][:list][:unnumbered].count).to eq(6) + expect(guidance[:contents][4][:list][:unordered].count).to eq(7) + expect(guidance[:contents][8][:list][:unordered].count).to eq(12) + expect(guidance[:contents][10][:list][:unordered].count).to eq(6) expect(guidance[:contents][14][:paragraph]).not_to be_nil diff_table = guidance[:contents][15][:table] diff --git a/spec/fixtures/sample.adoc b/spec/fixtures/sample.adoc index 7bec87b..b70395d 100644 --- a/spec/fixtures/sample.adoc +++ b/spec/fixtures/sample.adoc @@ -57,21 +57,21 @@ This is in [smallcaps]#smallcaps#. -== Numbered list +== Ordered list -. Numbered list item 1 -. Numbered list item 2 -. Numbered list item 3 -. Numbered list item 4 -. Numbered list item 5 +. Ordered list item 1 +. Ordered list item 2 +. Ordered list item 3 +. Ordered list item 4 +. Ordered list item 5 -== Unnumbered list +== Unordered list -* Unnumbered list item 1 -* Unnumbered list item 2 -* Unnumbered list item 3 -* Unnumbered list item 4 -* Unnumbered list item 5 +* Unordered list item 1 +* Unordered list item 2 +* Unordered list item 3 +* Unordered list item 4 +* Unordered list item 5 == Definition list