correspondence-markup 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -28,11 +28,13 @@ grammar CorrespondenceMarkupLanguage
28
28
  end
29
29
 
30
30
  rule structure
31
- structure_class s itemGroups:("[" item_group "]" s)*
31
+ structure_annotation s itemGroups:("[" item_group "]" s)*
32
32
  {
33
33
  def value
34
34
  itemGroupObjects = itemGroups.elements.map {|e| e.item_group.value}
35
- CorrespondenceMarkup::Structure.new(structure_class.text_value, itemGroupObjects)
35
+ class_name, description = structure_annotation.value
36
+ CorrespondenceMarkup::Structure.new(class_name, description,
37
+ itemGroupObjects)
36
38
  end
37
39
  }
38
40
  end
@@ -41,6 +43,20 @@ grammar CorrespondenceMarkupLanguage
41
43
  ([a-zA-Z] [a-zA-Z0-9_-]*)?
42
44
  end
43
45
 
46
+ rule structure_annotation
47
+ structure_class description_section:(":" s description:[^\n]* "\n")?
48
+ {
49
+ def value
50
+ class_name = structure_class.text_value
51
+ description = nil
52
+ if description_section.elements
53
+ description = description_section.description.text_value
54
+ end
55
+ [class_name, description]
56
+ end
57
+ }
58
+ end
59
+
44
60
  rule item_group
45
61
  optional_id:(id:[A-Z]* ":")? components:(item / non_item)*
46
62
  {
@@ -99,15 +99,18 @@ module CorrespondenceMarkup
99
99
 
100
100
  # A structure, containing a sequence of items and non-items
101
101
  class Structure
102
- attr_reader :type, :item_groups
102
+ attr_reader :type, :description, :item_groups
103
103
 
104
- def initialize(type, item_groups)
104
+ def initialize(type, description, item_groups)
105
105
  @type = type
106
+ @description = description
106
107
  @item_groups = item_groups
107
108
  end
108
109
 
109
110
  def ==(otherStructure)
110
- otherStructure.class == Structure && otherStructure.type == @type && otherStructure.item_groups == @item_groups
111
+ otherStructure.class == Structure && otherStructure.type == @type &&
112
+ otherStructure.description == description &&
113
+ otherStructure.item_groups == @item_groups
111
114
  end
112
115
 
113
116
  def css_class_names
@@ -121,6 +124,7 @@ module CorrespondenceMarkup
121
124
  def to_html(options={})
122
125
  itemGroupHtmls = @item_groups.map{|x| x.to_html(options)}
123
126
  "<div class=\"#{css_class_names}\">\n " +
127
+ (@description ? "<div class=\"language\">#{@description}</div>\n " : "") +
124
128
  itemGroupHtmls.join("").chomp("\n").gsub("\n", "\n ") +
125
129
  "\n</div>\n"
126
130
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: correspondence-markup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -38,7 +38,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
38
38
  version: '0'
39
39
  segments:
40
40
  - 0
41
- hash: -1007145873
41
+ hash: -1049094467
42
42
  required_rubygems_version: !ruby/object:Gem::Requirement
43
43
  none: false
44
44
  requirements: