lib/ebnf/writer.rb in ebnf-2.1.1 vs lib/ebnf/writer.rb in ebnf-2.1.2
- old
+ new
@@ -131,11 +131,14 @@
formatted_rules = rules.map do |rule|
if rule.kind == :terminals || rule.kind == :pass
OpenStruct.new(id: ("@#{rule.kind}"),
sym: nil,
assign: nil,
- formatted: ("<strong># Productions for terminals</strong>" if rule.kind == :terminals))
+ formatted: (
+ rule.kind == :terminals ?
+ "<strong># Productions for terminals</strong>" :
+ self.send(format_meth, rule.expr)))
else
formatted_expr = self.send(format_meth, rule.expr)
# Measure text without markup
formatted_expr_text = formatted_expr.gsub(%r{</?\w+[^>]*>}, '')
if formatted_expr_text.length > rhs_length && (format != :abnf || rule.alt?)
@@ -683,12 +686,14 @@
<table class="grammar">
<tbody id="grammar-productions" class="<%= @format %>">
<% for rule in @rules %>
<tr<%= %{ id="grammar-production-#{rule.sym}"} unless %w(=/ |).include?(rule.assign)%>>
<% if rule.id %>
- <td><%= rule.id %></td>
+ <td<%= " colspan=2" unless rule.sym %>><%= rule.id %></td>
<% end %>
+ <% if rule.sym %>
<td><code><%== rule.sym %></code></td>
+ <% end %>
<td><%= rule.assign %></td>
<td><%= rule.formatted %></td>
</tr>
<% end %>
</tbody>