Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update actions #108

Merged
merged 4 commits into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,19 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: [ '3.1', '3.0', '2.7' ]
ruby: [ '3.2', '3.1', '3.0', '2.7' ]
os: [ubuntu-latest, macos-latest, windows-latest]
exclude:
- os: windows-latest
ruby: '3.1'
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
- name: Build and test with Rake
shell: bash
run: |
gem install bundler --no-document
bundle install --jobs 4 --retry 3
bundle exec rake
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ AllCops:
TargetRubyVersion: 2.7
NewCops: enable

Gemspec/DevelopmentDependencies:
Enabled: false

Style/BarePercentLiterals:
EnforcedStyle: percent_q

Expand Down
3 changes: 1 addition & 2 deletions aozora2html.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@ Gem::Specification.new do |spec|
spec.required_ruby_version = '>= 2.7.0'
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
spec.bindir = 'bin'
spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.require_paths = ['lib']

spec.add_dependency 'rubyzip'
spec.add_development_dependency 'bundler'
spec.add_development_dependency 'rake', '~> 12.0'
spec.add_development_dependency 'rake'
spec.add_development_dependency 'rubocop'
spec.add_development_dependency 'rubocop-performance'
spec.add_development_dependency 'rubocop-rake'
Expand Down
18 changes: 8 additions & 10 deletions lib/aozora2html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class Aozora2Html
PAT_HENYAKU = '編訳$'.to_sjis
PAT_TRANSLATOR = '訳$'.to_sjis
RUBY_PREFIX = '|'.to_sjis
PAT_RUBY = /#{"《.*?》".to_sjis}/.freeze
PAT_RUBY = /#{'《.*?》'.to_sjis}/.freeze
PAT_DIRECTION = '(右|左|上|下)に(.*)'.to_sjis
PAT_REF = '^「.+」'.to_sjis
CHUUKI_COMMAND = '注記付き'.to_sjis
Expand Down Expand Up @@ -87,23 +87,23 @@ class Aozora2Html
WARICHU_COMMAND = '割り注'.to_sjis
TENTSUKI_COMMAND = '天付き'.to_sjis
PAT_REST_NOTES = '(左|下)に「(.*)」の(ルビ|注記|傍記)'.to_sjis
PAT_KUTEN = /#{"「※」[は|の]".to_sjis}/.freeze
PAT_KUTEN = /#{'「※」[は|の]'.to_sjis}/.freeze
PAT_KUTEN_DUAL = '※.*※'.to_sjis
PAT_GAIJI = '(?:#)(.*)(?:、)(.*)'.to_sjis
PAT_KAERITEN = '^([一二三四五六七八九十レ上中下甲乙丙丁天地人]+)$'.to_sjis
PAT_OKURIGANA = '^((.+))$'.to_sjis
PAT_REMOVE_OKURIGANA = /#{"[()]".to_sjis}/.freeze
PAT_CHITSUKI = /#{"(地付き|字上げ)(終わり)*$".to_sjis}/.freeze
PAT_REMOVE_OKURIGANA = /#{'[()]'.to_sjis}/.freeze
PAT_CHITSUKI = /#{'(地付き|字上げ)(終わり)*$'.to_sjis}/.freeze
PAT_ORIKAESHI_JISAGE = '折り返して(\\d*)字下げ'.to_sjis
PAT_ORIKAESHI_JISAGE2 = '(\\d*)字下げ、折り返して(\\d*)字下げ'.to_sjis
PAT_JI_LEN = '([0-9]+)字'.to_sjis
PAT_INLINE_RUBY = '「(.*)」の注記付き'.to_sjis
PAT_IMAGE = '(.*)((fig.+\\.png)(、横([0-9]+)×縦([0-9]+))*)入る'.to_sjis
PAT_FRONTREF = '「([^「」]*(?:「.+」)*[^「」]*)」[にはの](「.+」の)*(.+)'.to_sjis
PAT_RUBY_DIR = '(左|下)に「([^」]*)」の(ルビ|注記)'.to_sjis
PAT_CHUUKI = /#{"「(.+?)」の注記".to_sjis}/.freeze
PAT_BOUKI = /#{"「(.)」の傍記".to_sjis}/.freeze
PAT_CHARSIZE = /#{"(.*)段階(..)な文字".to_sjis}/.freeze
PAT_CHUUKI = /#{'「(.+?)」の注記'.to_sjis}/.freeze
PAT_BOUKI = /#{'「(.)」の傍記'.to_sjis}/.freeze
PAT_CHARSIZE = /#{'(.*)段階(..)な文字'.to_sjis}/.freeze

REGEX_HIRAGANA = Regexp.new('[ぁ-んゝゞ]'.to_sjis)
REGEX_KATAKANA = Regexp.new('[ァ-ンーヽヾヴ]'.to_sjis)
Expand Down Expand Up @@ -158,7 +158,7 @@ def initialize(input, output, gaiji_dir: nil, css_files: nil)
File.open(output, 'w')
end
@gaiji_dir = gaiji_dir || '../../../gaiji/'
@css_files = css_files || Array['../../aozora.css']
@css_files = css_files || ['../../aozora.css']

@buffer = TextBuffer.new
@ruby_buf = RubyBuffer.new
Expand Down Expand Up @@ -767,14 +767,12 @@ def apply_warichu(command)
check = @ruby_buf.last

# NOTE: Do not remove duplicates!
# rubocop:disable Style/IdenticalConditionalBranches
if check.is_a?(String) && check.end_with?(PAREN_BEGIN_MARK)
push_char('<span class="warichu">')
else
push_char('<span class="warichu">')
push_char(PAREN_BEGIN_MARK)
end
# rubocop:enable Style/IdenticalConditionalBranches
end
nil
end
Expand Down
2 changes: 1 addition & 1 deletion test/test_command_parse.rb
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def test_parse_command_ruby
Aozora2Html::Tag::EmbedGaiji.use_unicode = true
src = "グリーンランドの中央部八千尺の氷河地帯にあるといわれる、[#横組み]“Ser-mik-Suah《セルミク・シュアー》”[#横組み終わり]の冥路《よみじ》の国。\r\n"
parsed = parse_text(src)
expected = %Q(グリーンランドの中央部八千尺の氷河地帯にあるといわれる、<span class=\"yokogumi\">“<ruby><rb>Ser-mik-Suah</rb><rp>(</rp><rt>セルミク・シュアー</rt><rp>)</rp></ruby>”</span>の<ruby><rb>冥路</rb><rp>(</rp><rt>よみじ</rt><rp>)</rp></ruby>の国。<br />\r\n)
expected = %Q(グリーンランドの中央部八千尺の氷河地帯にあるといわれる、<span class="yokogumi">“<ruby><rb>Ser-mik-Suah</rb><rp>(</rp><rt>セルミク・シュアー</rt><rp>)</rp></ruby>”</span>の<ruby><rb>冥路</rb><rp>(</rp><rt>よみじ</rt><rp>)</rp></ruby>の国。<br />\r\n)
assert_equal expected, parsed
end

Expand Down
2 changes: 1 addition & 1 deletion test/test_header.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class HeaderTest < Test::Unit::TestCase
def setup
@header = Aozora2Html::Header.new(css_files: Array['../../aozora.css'])
@header = Aozora2Html::Header.new(css_files: ['../../aozora.css'])
end

using Aozora2Html::StringRefinements
Expand Down
Loading