Skip to content

Commit

Permalink
Finish 3.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
gkellogg committed Feb 21, 2023
2 parents 831a6c9 + 5904d0b commit 8d91d90
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 23 deletions.
10 changes: 2 additions & 8 deletions .github/workflows/ci.yml
Expand Up @@ -19,16 +19,10 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby:
- 2.6
- 2.7
- "3.0"
- 3.1
- ruby-head
- jruby
ruby: [2.6, 2.7, '3.0', 3.1, 3.2, ruby-head, jruby]
steps:
- name: Clone repository
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/generate-docs.yml
Expand Up @@ -10,7 +10,7 @@ jobs:
name: Update gh-pages with docs
steps:
- name: Clone repository
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
2.3.1
2.3.2
6 changes: 3 additions & 3 deletions ebnf.gemspec
Expand Up @@ -34,13 +34,13 @@ Gem::Specification.new do |gem|
gem.add_runtime_dependency 'scanf', '~> 1.0'
gem.add_runtime_dependency 'rdf', '~> 3.2' # Required by sxp
gem.add_runtime_dependency 'htmlentities', '~> 4.3'
gem.add_runtime_dependency 'unicode-types', '~> 1.7'
gem.add_runtime_dependency 'amazing_print', '~> 1.4'
gem.add_runtime_dependency 'unicode-types', '~> 1.8'
gem.add_development_dependency 'amazing_print', '~> 1.4'
gem.add_development_dependency 'rdf-spec', '~> 3.2'
gem.add_development_dependency 'rdf-turtle', '~> 3.2'
gem.add_development_dependency 'nokogiri', '~> 1.13', '>= 1.13.4'
gem.add_development_dependency 'erubis', '~> 2.7'
gem.add_development_dependency 'rspec', '~> 3.10'
gem.add_development_dependency 'rspec', '~> 3.12'
gem.add_development_dependency 'rspec-its', '~> 1.3'
gem.add_development_dependency 'yard', '~> 0.9'
gem.add_development_dependency 'rake', '~> 13.0'
Expand Down
2 changes: 1 addition & 1 deletion examples/abnf/doc/parser.html
Expand Up @@ -466,7 +466,7 @@
<div class="pilwrap">
<a class="pilcrow" href="#section-EBNF_Parser_for_EBNF.">&#182;</a>
</div>
<h1>EBNF Parser for EBNF.</h1>
<h1>EBNF Parser for ABNF.</h1>

<p>Produces an Abstract Synatx Tree in S-Expression form for the input grammar file</p>
</td>
Expand Down
2 changes: 1 addition & 1 deletion examples/abnf/parser.rb
@@ -1,4 +1,4 @@
# # EBNF Parser for EBNF.
# # EBNF Parser for ABNF.
#
# Produces an Abstract Synatx Tree in S-Expression form for the input grammar file
require 'ebnf'
Expand Down
18 changes: 11 additions & 7 deletions lib/ebnf/writer.rb
Expand Up @@ -181,8 +181,9 @@ def initialize(rules, out: $stdout, html: false, format: :ebnf, validate: false,

if validate
begin
require 'nokogiri'
# Validate the output HTML
doc = Nokogiri::HTML5("<!DOCTYPE html>" + html_result, max_errors: 10)
doc = ::Nokogiri::HTML5("<!DOCTYPE html>" + html_result, max_errors: 10)
raise EncodingError, "Errors found in generated HTML:\n " +
doc.errors.map(&:to_s).join("\n ") unless doc.errors.empty?
rescue LoadError, NoMethodError
Expand Down Expand Up @@ -407,14 +408,14 @@ def format_abnf(expr, sep: nil, embedded: false, sensitive: true)
seq.unshift(:seq)
return format_abnf(seq, sep: nil, embedded: false)
else
return (@options[:html] ? %("<code class="grammar-literal">#{'%s' if sensitive}#{@coder.encode expr}</code>") : %(#{'%s' if sensitive}"#{expr}"))
return (@options[:html] ? %("<code class="grammar-literal">#{@coder.encode expr}</code>") : %("#{expr}"))
end
end
parts = {
alt: (@options[:html] ? "<code>/</code> " : "/ "),
star: (@options[:html] ? "<code>*</code> " : "*"),
plus: (@options[:html] ? "<code>+</code> " : "1*"),
opt: (@options[:html] ? "<code>?</code> " : "?")
alt: (@options[:html] ? "<code>/</code>" : "/ "),
star: (@options[:html] ? "<code>*</code>" : "*"),
plus: (@options[:html] ? "<code>+</code>" : "1*"),
opt: (@options[:html] ? "<code>?</code>" : "?")
}
lbrac = (@options[:html] ? "<code>[</code> " : "[")
rbrac = (@options[:html] ? "<code>]</code> " : "]")
Expand Down Expand Up @@ -464,6 +465,8 @@ def format_abnf(expr, sep: nil, embedded: false, sensitive: true)
"#{parts[:star]}#{r}"
elsif min > 0 && max == '*'
"#{min}#{parts[:star]}#{r}"
elsif min == 0
"#{parts[:star]}#{max}#{r}"
else
"#{min}#{parts[:star]}#{max}#{r}"
end
Expand Down Expand Up @@ -503,6 +506,7 @@ def format_abnf_range(string)
# Append any decimal values
alt << "%d" + deces.join(".") unless deces.empty?
deces = []
hex = hex.upcase

if in_range
# Add "." sequences for any previous hexes
Expand Down Expand Up @@ -552,7 +556,7 @@ def escape_abnf_hex(u)
when 0x0100..0xffff then "%04X"
else "%08X"
end
char = "%x" + (fmt % u.ord)
char = "%x" + (fmt % u.ord).upcase
if @options[:html]
if u.ord <= 0x20
char = %(<abbr title="#{ASCII_ESCAPE_NAMES[u.ord]}">#{@coder.encode char}</abbr>)
Expand Down
2 changes: 1 addition & 1 deletion spec/writer_spec.rb
Expand Up @@ -319,7 +319,7 @@
],
"rept 0 1": [
[:rept, 0, 1, :A],
"0*1A"
"*1A"
],
"rept 0 *": [
[:rept, 0, '*', :A],
Expand Down

0 comments on commit 8d91d90

Please sign in to comment.