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

add ird sty #11

Merged
merged 4 commits into from
Feb 16, 2021
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
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
review-retrovert (0.9.6)
review-retrovert (0.9.7)
review (>= 3.0.0)
thor

Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ inherit: ["config-base.yml", "config-starter.yml", "config-retrovert.yml"]
#chapterlink: true
```

## Experimental

### IRD sty

--ird オプションを付けると IRD 組版に近いレイアウトにするために ird.sty と reveiw-ext.rb をプロジェクトに追加します。
こちらは実験的機能です。

## Development

After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
Expand Down
25 changes: 24 additions & 1 deletion lib/review/retrovert/converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,13 @@ def update_config(outdir)
@configs.rewrite_yml('hook_beforetexcompile', 'null')
@configs.rewrite_yml('texstyle', '["reviewmacro"]')
pagesize = @config['starter']['pagesize'].downcase
@configs.rewrite_yml_array('texdocumentclass', "[\"review-jsbook\", \"media=print,paper=#{pagesize}\"]")
jsbook_config = "media=print,paper=#{pagesize}"
if @ird
# # リュウミン Pr6N R-KL 12.5Q 22H (9pt = 12.7Q 15.5pt = 21.8Q(H))
# texdocumentclass: ["review-jsbook", "media=ebook,openany,paper=b5,fontsize=9pt,baselineskip=15.5pt,head_space=15mm,gutter=22mm,footskip=16mm,line_length=45zw,number_of_lines=38"]
jsbook_config = "media=ebook,openany,paper=b5,fontsize=9pt,baselineskip=15.5pt,head_space=15mm,gutter=22mm,footskip=16mm,line_length=45zw,number_of_lines=38"
end
@configs.rewrite_yml_array('texdocumentclass', "[\"review-jsbook\", \"#{jsbook_config}\"]")
@config['retrovert'].each{ |k,v|
unless v..is_a?(Hash)
@configs.commentout_root_yml(k)
Expand Down Expand Up @@ -542,6 +548,21 @@ def preproc_contents(outdir, options)
end
end

def update_sty(outdir, options)
# FileUtils.cp(File.join(@basedir, 'sty/review-custom.sty'), File.join(outdir, 'sty/review-custom.sty'))
if @ird
FileUtils.cp(File.join(__dir__, 'sty/ird.sty'), File.join(outdir, 'sty/ird.sty'))
file = File.open(File.join(outdir, 'sty/review-custom.sty'), 'a')
file.puts('\RequirePackage{ird}')
end
end

def update_ext(outdir, options)
if @ird
FileUtils.cp(File.join(__dir__, 'ext/review-ext.rb'), File.join(outdir, 'review-ext.rb'))
end
end

def clean_initial_project(outdir)
FileUtils.rm(File.join(outdir, 'config.yml'))
FileUtils.rm(File.join(outdir, 'catalog.yml'))
Expand Down Expand Up @@ -586,6 +607,8 @@ def execute(yamlfile, outdir, options)
copy_images(outdir, store_image_dir)
update_config(outdir)
update_contents(outdir, options)
update_sty(outdir, options)
update_ext(outdir, options)

pwd = Dir.pwd
Dir.chdir(outdir)
Expand Down
71 changes: 71 additions & 0 deletions lib/review/retrovert/ext/review-ext.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# -*- coding: utf-8 -*-

##
## ReVIEW::LATEXBuilderクラスを拡張する
##

require 'review/latexbuilder'


module ReVIEW

defined?(LATEXBuilder) or raise "internal error: LATEXBuilder not found."


module LATEXBuilderForIRD
# def headline(level, label, caption)
# if level >= 4
# puts '\needspace{3zh}'
# end
# super(level,label,caption)
# puts '\nopagebreak[4]'
# end

def ul_begin
blank
puts '\begin{reviewitemize}'
end
def ul_end
puts '\end{reviewitemize}'
blank
end
end

class LATEXBuilder
prepend LATEXBuilderForIRD

# def headline(level, label, caption)
# _, anchor = headline_prefix(level)
# headline_name = HEADLINE[level]
# if @chapter.is_a?(ReVIEW::Book::Part)
# if @book.config.check_version('2', exception: false)
# headline_name = 'part'
# elsif level == 1
# headline_name = 'part'
# puts '\begin{reviewpart}'
# end
# end
# prefix = ''
# if level > @book.config['secnolevel'] || (@chapter.number.to_s.empty? && level > 1)
# prefix = '*'
# end
# blank unless @output.pos == 0
# @doc_status[:caption] = true
# puts macro(headline_name + prefix, compile_inline(caption))
# puts '\nopagebreak[4]'
# @doc_status[:caption] = nil
# if prefix == '*' && level <= @book.config['toclevel'].to_i
# puts "\\addcontentsline{toc}{#{headline_name}}{#{compile_inline(caption)}}"
# end
# if level == 1
# puts macro('label', chapter_label)
# else
# puts macro('label', sec_label(anchor))
# puts macro('label', label) if label
# end
# puts '\nopagebreak[4]'
# rescue
# error "unknown level: #{level}"
# end
end
end
Loading