coradoc 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +7 -0
  2. data/.docker/Dockerfile +19 -0
  3. data/.docker/Makefile +35 -0
  4. data/.docker/docker-compose.yml +14 -0
  5. data/.docker/readme.md +61 -0
  6. data/.hound.yml +5 -0
  7. data/.rubocop.yml +10 -0
  8. data/CHANGELOG.md +5 -0
  9. data/CODE_OF_CONDUCT.md +84 -0
  10. data/Gemfile +5 -0
  11. data/LICENSE.txt +21 -0
  12. data/Makefile +1 -0
  13. data/README.md +69 -0
  14. data/Rakefile +7 -0
  15. data/coradoc.gemspec +38 -0
  16. data/docker-compose.yml +1 -0
  17. data/lib/coradoc/document/admonition.rb +11 -0
  18. data/lib/coradoc/document/attribute.rb +27 -0
  19. data/lib/coradoc/document/author.rb +11 -0
  20. data/lib/coradoc/document/base.rb +17 -0
  21. data/lib/coradoc/document/bibdata.rb +24 -0
  22. data/lib/coradoc/document/block.rb +34 -0
  23. data/lib/coradoc/document/header.rb +11 -0
  24. data/lib/coradoc/document/list.rb +14 -0
  25. data/lib/coradoc/document/paragraph.rb +19 -0
  26. data/lib/coradoc/document/revision.rb +11 -0
  27. data/lib/coradoc/document/section.rb +28 -0
  28. data/lib/coradoc/document/table.rb +20 -0
  29. data/lib/coradoc/document/text_element.rb +22 -0
  30. data/lib/coradoc/document/title.rb +33 -0
  31. data/lib/coradoc/document.rb +46 -0
  32. data/lib/coradoc/legacy_parser.rb +200 -0
  33. data/lib/coradoc/oscal.rb +85 -0
  34. data/lib/coradoc/parser/asciidoc/base.rb +84 -0
  35. data/lib/coradoc/parser/asciidoc/bibdata.rb +19 -0
  36. data/lib/coradoc/parser/asciidoc/content.rb +143 -0
  37. data/lib/coradoc/parser/asciidoc/header.rb +30 -0
  38. data/lib/coradoc/parser/asciidoc/section.rb +60 -0
  39. data/lib/coradoc/parser/base.rb +32 -0
  40. data/lib/coradoc/parser.rb +11 -0
  41. data/lib/coradoc/transformer.rb +178 -0
  42. data/lib/coradoc/version.rb +5 -0
  43. data/lib/coradoc.rb +19 -0
  44. data/todo.md +10 -0
  45. metadata +174 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1808574d50d22e93126d258859b0a7156015dae5e1830332b70a705643c3ab50
4
+ data.tar.gz: e1593143645bd24b419ad84f5961335de1351599fc9e9363d40c49ddb5a1d1b9
5
+ SHA512:
6
+ metadata.gz: a40e182cf07edd62e2af114fdbc752e759aef7b44a693cab17a6fba93869f999a5b2532f25e80146f30ed19b997414061b333836e4165045826e5c3853474403
7
+ data.tar.gz: 51c085c1a3437ea76897568b318a10ed7cc42f3998448903c0337500455fc4712ca869cc50ce1355bcb707461fef16c825f8c5a206fd86050f8b0295e82d198c
@@ -0,0 +1,19 @@
1
+ ARG RUBY_IMAGE=ruby:3.1.2-slim
2
+
3
+ FROM ${RUBY_IMAGE}
4
+
5
+ RUN apt-get update \
6
+ && apt-get install -y build-essential git \
7
+ && apt-get clean && rm -rf /var/lib/apt/lists/*
8
+
9
+ # install latest bundler
10
+ RUN gem install bundler
11
+
12
+ # Create app directory
13
+ WORKDIR /workspace
14
+
15
+ # Set bundle path
16
+ ENV BUNDLE_PATH /bundle
17
+
18
+ # Default to console
19
+ CMD ["bin/console"]
data/.docker/Makefile ADDED
@@ -0,0 +1,35 @@
1
+ export SPEC ?= spec
2
+ SPEC_FILE = $(subst ../,, $(SPEC))
3
+ export RUBY_IMAGE ?= ruby:3.1.2-slim
4
+
5
+ .PHONY: up
6
+ up:
7
+ docker-compose up
8
+
9
+ .PHONY: down
10
+ down:
11
+ docker-compose down
12
+
13
+ .PHONY: test
14
+ test: rspec
15
+
16
+ .PHONY: ssh
17
+ ssh:
18
+ docker-compose run lib bash
19
+
20
+ .PHONY: install
21
+ install:
22
+ docker-compose run lib bin/setup
23
+
24
+ .PHONY: console
25
+ console:
26
+ docker-compose run lib bin/console
27
+
28
+ .PHONY: rspec
29
+ rspec:
30
+ docker-compose run lib bin/rspec ${SPEC_FILE}
31
+
32
+ .PHONY: setup
33
+ setup:
34
+ docker-compose build --build-arg RUBY_IMAGE=${RUBY_IMAGE}
35
+ docker-compose run lib bin/setup
@@ -0,0 +1,14 @@
1
+ version: "3"
2
+
3
+ services:
4
+ lib:
5
+ build:
6
+ context: .
7
+ dockerfile: ./.docker/Dockerfile
8
+
9
+ volumes:
10
+ - .:/workspace
11
+ - bundle:/bundle
12
+
13
+ volumes:
14
+ bundle:
data/.docker/readme.md ADDED
@@ -0,0 +1,61 @@
1
+ ## Docker
2
+
3
+ This directory is only meant to be used for development, and contains some
4
+ necessary setup to spin up docker containers with multiple ruby environment.
5
+
6
+ ### Setup
7
+
8
+ Before doing anything, you might want to create a symlink to the docker file and
9
+ Makefile. This would allow you to avoid some of the unnecessary work related to
10
+ the file paths To do that run the following from the root of the project.
11
+
12
+ ```
13
+ ln -sf .docker/Makefile .
14
+ ln -sf .docker/docker-compose.yml .
15
+ ```
16
+
17
+ By default it usages the most recent ruby version for docker environment, but if
18
+ you want to run it in any specific version then you can set it up by exporting
19
+ `RUBY_IMAGE` environment variable in your shell:
20
+
21
+ ```sh
22
+ export RUBY_IMAGE=ruby:3.0-buster
23
+ ```
24
+
25
+ Once everything is set then you would need to build the development images for
26
+ the first time and you can do that using:
27
+
28
+ ```sh
29
+ make setup
30
+ ```
31
+
32
+ The setup process will install all dependencies and it will also setup a volume
33
+ to speed up the repeated gem installation.
34
+
35
+ ### Playground
36
+
37
+ The `Makefile` contains two target for tests, and you can run the tests using
38
+ any of the following commands:
39
+
40
+ ```sh
41
+ make test
42
+
43
+ # or
44
+ make rspec
45
+ ```
46
+
47
+ If you need more control, and you want to do some development on the go then you
48
+ can get into the container using:
49
+
50
+ ```sh
51
+ make ssh
52
+ ```
53
+
54
+ ### Cleanup
55
+
56
+ Once you are done with your experiment then you can cleanup the docker
57
+ environment using the following command.
58
+
59
+ ```sh
60
+ make down
61
+ ```
data/.hound.yml ADDED
@@ -0,0 +1,5 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ ruby:
4
+ enabled: true
5
+ config_file: .rubocop.yml
data/.rubocop.yml ADDED
@@ -0,0 +1,10 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ inherit_from:
4
+ - https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
5
+
6
+ # local repo-specific modifications
7
+ # ...
8
+
9
+ AllCops:
10
+ TargetRubyVersion: 2.5
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2023-01-08
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at abunashir@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 Abu Nashir
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/Makefile ADDED
@@ -0,0 +1 @@
1
+ .docker/Makefile
data/README.md ADDED
@@ -0,0 +1,69 @@
1
+ # Coradoc
2
+
3
+ Coradoc is a modern Parser for Asciidoc document. It defines a grammar for
4
+ AsciiDoc, and then build the Parser for that grammar.
5
+
6
+ Once the document is parsed, it provides a pure ruby object `Coradoc::Document`,
7
+ which can used to customize the document in easiest way.
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem "coradoc"
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ ```sh
20
+ bundle install
21
+ ```
22
+
23
+ Or install it yourself as:
24
+
25
+ ```sh
26
+ gem install coradoc
27
+ ```
28
+
29
+ ## Development
30
+
31
+ We are following Sandi Metz's Rules for this gem, you can read the
32
+ [description of the rules here][sandi-metz] All new code should follow these
33
+ rules. If you make changes in a pre-existing file that violates these rules you
34
+ should fix the violations as part of your contribution.
35
+
36
+ ### Setup
37
+
38
+ Clone the repository.
39
+
40
+ ```sh
41
+ git clone https://github.com/metanorma/coradoc.git
42
+ ```
43
+
44
+ Setup your environment in docker
45
+
46
+ ```sh
47
+ make setup
48
+ ```
49
+
50
+ Run the test suite
51
+
52
+ ```sh
53
+ make test
54
+ ```
55
+
56
+
57
+ ## Usages
58
+
59
+ ### Parsing a document
60
+
61
+ To parse any AsciiDoc, we can use the following:
62
+
63
+ ```ruby
64
+ Coradoc::Parser.parse(sample_asciidoc)
65
+ ```
66
+
67
+ This interface will return the abstract syntax tree.
68
+
69
+ [sandi-metz]: http://robots.thoughtbot.com/post/50655960596/sandi-metz-rules-for-developers
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+ task default: :spec
data/coradoc.gemspec ADDED
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/coradoc/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "coradoc"
7
+ spec.version = Coradoc::VERSION
8
+ spec.authors = ["Ribose Inc.", "Abu Nashir"]
9
+ spec.email = ["open.source@ribose.com", "abunashir@gmail.com"]
10
+
11
+ spec.license = "MIT"
12
+ spec.homepage = "https://www.metanorma.org"
13
+ spec.summary = "AsciiDoc parser for metanorma"
14
+ spec.description = "Experimental AsciiDoc parser for metanorma"
15
+
16
+ spec.metadata["homepage_uri"] = spec.homepage
17
+ spec.metadata["source_code_uri"] = "https://github.com/metanorma/coradoc"
18
+
19
+ spec.files = Dir.chdir(__dir__) do
20
+ `git ls-files -z`.split("\x0").reject do |f|
21
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
22
+ end
23
+ end
24
+
25
+ spec.bindir = "exe"
26
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
27
+
28
+ spec.require_paths = ["lib"]
29
+ spec.required_ruby_version = ">= 2.7.0"
30
+
31
+ spec.add_dependency "parslet"
32
+ spec.add_dependency "oscal", "~> 0.1.1"
33
+
34
+ spec.add_development_dependency "pry"
35
+ spec.add_development_dependency "rake"
36
+ spec.add_development_dependency "rspec"
37
+ spec.add_development_dependency "rubocop"
38
+ end
@@ -0,0 +1 @@
1
+ .docker/docker-compose.yml
@@ -0,0 +1,11 @@
1
+ module Coradoc
2
+ class Document::Admonition
3
+ attr_reader :type, :content, :line_break
4
+
5
+ def initialize(content, type, options = {})
6
+ @content = content
7
+ @type = type.downcase.to_sym
8
+ @line_break = options.fetch(:line_break, "")
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,27 @@
1
+ module Coradoc
2
+ module Document
3
+ class Attribute
4
+ attr_reader :key, :value
5
+
6
+ def initialize(key, value, _options = {})
7
+ @key = key.to_s
8
+ @value = build_values(value.to_s)
9
+ end
10
+
11
+ private
12
+
13
+ def build_values(value)
14
+ values = value.split(",").map(&:strip)
15
+ values.length > 1 ? values : values.first
16
+ end
17
+ end
18
+
19
+ class Glossaries
20
+ attr_reader :items
21
+
22
+ def initialize(items)
23
+ @items = items
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,11 @@
1
+ module Coradoc
2
+ class Document::Author
3
+ attr_reader :email, :last_name, :first_name
4
+
5
+ def initialize(first_name, last_name, email)
6
+ @email = email
7
+ @last_name = last_name
8
+ @first_name = first_name
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,17 @@
1
+ module Coradoc
2
+ module Document
3
+ class Base
4
+ attr_reader :bibdata
5
+
6
+ def initialize(asciidoc)
7
+ @bibdata = extract_bibdata(asciidoc)
8
+ end
9
+
10
+ private
11
+
12
+ def extract_bibdata(asciidoc)
13
+ @bibdata ||= BibData.new(asciidoc.attributes)
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,24 @@
1
+ module Coradoc
2
+ module Document
3
+ class Bibdata
4
+ attr_reader :data
5
+
6
+ def initialize(bibdata, options = {})
7
+ @bibdata = bibdata
8
+ @options = options
9
+ end
10
+
11
+ def data
12
+ @data ||= @bibdata
13
+ end
14
+
15
+ def to_hash
16
+ Hash.new.tap do |hash|
17
+ data.each do |attribute|
18
+ hash[attribute.key.to_s] = attribute.value.to_s.gsub("'", "")
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,34 @@
1
+ module Coradoc
2
+ class Document::Block
3
+ attr_reader :title, :lines, :attributes
4
+
5
+ def initialize(title, options = {})
6
+ @title = title
7
+ @lines = options.fetch(:lines, [])
8
+ @type_str = options.fetch(:type, nil)
9
+ @delimiter = options.fetch(:delimiter, "")
10
+ @attributes = options.fetch(:attributes, {})
11
+ end
12
+
13
+ def type
14
+ @type ||= defined_type || type_from_delimiter
15
+ end
16
+
17
+ private
18
+
19
+ def defined_type
20
+ if @type_str
21
+ @type_str.to_s.to_sym
22
+ end
23
+ end
24
+
25
+ def type_from_delimiter
26
+ case @delimiter
27
+ when "____" then :quote
28
+ when "****" then :side
29
+ when "----" then :source
30
+ when "====" then :example
31
+ else nil end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,11 @@
1
+ module Coradoc
2
+ class Document::Header
3
+ attr_reader :title, :author, :revision
4
+
5
+ def initialize(title, options = {})
6
+ @title = title
7
+ @author = options.fetch(:author, nil)
8
+ @revision = options.fetch(:revision, nil)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,14 @@
1
+ module Coradoc
2
+ module Document
3
+ class List
4
+ attr_reader :items
5
+
6
+ def initialize(items)
7
+ @items = items
8
+ end
9
+
10
+ class Unnumbered < List
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,19 @@
1
+ module Coradoc
2
+ module Document
3
+ class Paragraph
4
+ attr_reader :content
5
+
6
+ def initialize(content, _options = {})
7
+ @content = content
8
+ end
9
+
10
+ def id
11
+ content&.first&.id&.to_s
12
+ end
13
+
14
+ def texts
15
+ content.map(&:content)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,11 @@
1
+ module Coradoc
2
+ class Document::Revision
3
+ attr_reader :number, :date, :remark
4
+
5
+ def initialize(number, options = {})
6
+ @number = number
7
+ @date = options.fetch(:date, nil)
8
+ @remark = options.fetch(:remark, nil)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,28 @@
1
+ module Coradoc
2
+ class Document::Section
3
+ attr_reader :id, :title, :contents, :sections
4
+
5
+ def initialize(title, options = {})
6
+ @title = title
7
+ @id = options.fetch(:id, nil).to_s
8
+ @contents = options.fetch(:contents, [])
9
+ @sections = options.fetch(:sections, [])
10
+ end
11
+
12
+ def glossaries
13
+ @glossaries ||= extract_glossaries
14
+ end
15
+
16
+ def content
17
+ if contents.count == 1 && contents.first.is_a?(Coradoc::Document::Paragraph)
18
+ contents.first
19
+ end
20
+ end
21
+
22
+ private
23
+
24
+ def extract_glossaries
25
+ contents.select {|c| c if c.is_a?(Coradoc::Document::Glossaries) }.first
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,20 @@
1
+ module Coradoc
2
+ module Document
3
+ class Table
4
+ attr_reader :title, :rows
5
+
6
+ def initialize(title, rows)
7
+ @rows = rows
8
+ @title = title
9
+ end
10
+
11
+ class Row
12
+ attr_reader :columns
13
+
14
+ def initialize(columns)
15
+ @columns = columns
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,22 @@
1
+ module Coradoc
2
+ class Document::TextElement
3
+ attr_reader :id, :content, :line_break
4
+
5
+ def initialize(content, options = {})
6
+ @content = content.to_s
7
+ @id = options.fetch(:id, nil)
8
+ @line_break = options.fetch(:line_break, "")
9
+ end
10
+ end
11
+
12
+ class Document::LineBreak
13
+ attr_reader :line_break
14
+
15
+ def initialize(line_break)
16
+ @line_break = line_break
17
+ end
18
+ end
19
+
20
+ class Document::Highlight < Document::TextElement
21
+ end
22
+ end