hiki2latex 0.9.11 → 0.9.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bb8c1fa1c37fd149c824756bd2dc02122c4b60f8
4
- data.tar.gz: 6da596d8344c2e70a979ca4a2ceb00c2615b3fff
3
+ metadata.gz: 12076d5d0ba9927aa5c90cf3ca76272ecc0540c9
4
+ data.tar.gz: e6e148da375fdc48d3a083554b07d809fd026d72
5
5
  SHA512:
6
- metadata.gz: f27211c548971a71452b268cbe379011ba1192acdf2faff1ce19eea5771c08535697e836906eb9b9de10b46ea82caf5cc050a1970904381c251bde46f2183649
7
- data.tar.gz: 0057a9233740483c5edf0291c2462795f197b902f3d3def42d426501b08587eb2449575a1e578fca5b75eca493eb54522e1894385f8c939127dabe8831cdc180
6
+ metadata.gz: 27e6493c92a853626cc67858f3b7e70035272de05c82c3758a2c832725f82fd7a6f863376f8690e6a3b3932852afb173dd261659cfb61f0ab52d9d1349092e0a
7
+ data.tar.gz: ed43a50306c7a9af6fed161e5e53cd973feb8c352ebae7290b6ca40ea0bc5aae13edeb767bfe449043761395cc444b79ea1609fd8ed26d3b9d7ad3cb04d38f11
data/#Rakefile# ADDED
@@ -0,0 +1,42 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+ require "rake/testtask"
4
+ require 'yard'
5
+ require 'systemu'
6
+
7
+ #task :default => :test
8
+ task :default do
9
+ system 'rake -T'
10
+ end
11
+
12
+
13
+ desc "make documents by yard"
14
+ task :yard do
15
+ system "hiki2md docs/readme.hiki > docs/README.en.md"
16
+ system "hiki2md docs/readme.ja.hiki > docs/README.ja.md"
17
+ YARD::Rake::YardocTask.new
18
+ end
19
+
20
+ RSpec::Core::RakeTask.new(:spec)
21
+
22
+ desc "all procedure for release."
23
+ task :update =>[:setenv] do
24
+ system 'emacs ./lib/hiki2latex/version.rb'
25
+ system 'git add -A'
26
+ system 'git commit'
27
+ system 'git push -u origin master'
28
+ system 'bundle exec rake release'
29
+ end
30
+
31
+ desc "setenv for release from Kwansei gakuin."
32
+ task :setenv do
33
+ # status, stdout, stderr = systemu "scselect \| grep \'\*\' |grep KG"
34
+ # puts stdout
35
+ # p stdout != nil
36
+ # if stdout != nil then
37
+ p command='setenv HTTP_PROXY http://proxy.ksc.kwansei.ac.jp:8080'
38
+ system command
39
+ p command='setenv HTTPS_PROXY http://proxy.ksc.kwansei.ac.jp:8080'
40
+ system command
41
+ # end
42
+ end
@@ -0,0 +1,42 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'hiki2latex/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "hiki2latex"
8
+ spec.version = Hiki2latex::VERSION
9
+ spec.authors = ["Shigeto R. Nishitani"]
10
+ spec.email = ["shigeto_nishitani@me.com"]
11
+
12
+ spec.summary = %q{convert hikidoc text to latex format.}
13
+ spec.description = <<-EOF
14
+ hiki2latex is a format converter from hikidoc to latex, using hikidoc.
15
+ EOF
16
+ spec.homepage = 'https://github.com/daddygongon/hiki2latex'
17
+ spec.license = "MIT"
18
+
19
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
20
+ # delete this section to allow pushing this gem to any host.
21
+ # if spec.respond_to?(:metadata)
22
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
23
+ # else
24
+ # raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
25
+ # end
26
+
27
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
28
+ spec.bindir = "exe"
29
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ["lib"]
31
+
32
+ spec.required_ruby_version = '>= 1.8.6'
33
+
34
+ spec.add_development_dependency "bundler", "~> 1.10"
35
+ spec.add_development_dependency "rake", "~> 10.0"
36
+ spec.add_development_dependency "rspec"
37
+ spec.add_development_dependency "yard", "~> 0.8"
38
+ spec.add_development_dependency "test-unit"
39
+ spec.add_development_dependency "systemu"
40
+ spec.add_development_dependency "hiki2md"
41
+ spec.add_runtime_dependency "hikidoc","~>0.1.0"
42
+ end
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.yardopts ADDED
@@ -0,0 +1,4 @@
1
+ -
2
+ docs/README.en.md
3
+ docs/README.ja.md
4
+
@@ -1,26 +1,21 @@
1
1
  # Hiki2latex
2
-
3
2
  convert hikidoc text to latex format.
4
3
 
5
4
  ## Installation
6
-
7
5
  Add this line to your application's Gemfile:
8
-
9
6
  ```ruby
10
7
  gem 'hiki2latex'
11
-
12
8
  ```
13
-
14
9
  And then execute:
15
-
16
- $ bundle
17
-
10
+ ```
11
+ $ bundle
12
+ ```
18
13
  Or install it yourself as:
19
-
20
- $ gem install hiki2latex
14
+ ```
15
+ $ gem install hiki2latex
16
+ ```
21
17
 
22
18
  ## Usage
23
-
24
19
  Use as a gem library:
25
20
  ```ruby
26
21
  require 'hiki2latex'
@@ -30,33 +25,34 @@ Use as a gem library:
30
25
 
31
26
  or as a command line tool:
32
27
 
33
- ```csh
34
- Usage: hiki2latex [options] FILE
35
- -v, --version show program Version.
36
- -l, --level VALUE set Level for output section.
37
- -p, --plain FILE make Plain document.
38
- -b, --bare FILE make Bare document.
39
- --head FILE put headers of maketitle file.
40
- --pre FILE put preamble file.
41
- --post FILE put post file.
42
- --listings use listings.sty for preformat with style.
28
+ <dl>
29
+ <dt>Usage</dt><dd> hiki2latex [options] FILE</dd>
30
+ </dl>
31
+
43
32
 
33
+ | option | operation|
34
+ |:----|:----|
35
+ | -v, --version | show program Version.|
36
+ | -l, --level VALUE | set Level for output section.|
37
+ | -p, --plain FILE | make Plain document.|
38
+ | -b, --bare FILE | make Bare document.|
39
+ | --head FILE | put headers of maketitle file.|
40
+ | --pre FILE | put preamble file.|
41
+ | --post FILE | put post file.|
42
+ | --listings | use listings.sty for preformat with style.|
43
+
44
+ ```
44
45
  > hiki2latex --pre PRICM_preamble.tex --post biblio.tex -p test.hiki > test.tex
45
46
  > hiki2latex --listings --post post.tex -p ./test.hiki > test.tex
46
47
  ```
47
48
 
48
49
  ## Development
49
-
50
50
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. Run `bundle exec hiki2latex` to use the gem in this directory, ignoring other installed copies of this gem.
51
51
 
52
52
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
53
53
 
54
54
  ## Contributing
55
-
56
55
  Bug reports and pull requests are welcome on GitHub at https://github.com/daddygongon/hiki2latex. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
57
56
 
58
-
59
57
  ## License
60
-
61
58
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
62
-
data/README.ja.md ADDED
@@ -0,0 +1,131 @@
1
+ # 【概要】
2
+ hiki formatで書かれた文章を,latex formatに変換する
3
+ # 【documents】
4
+ - ![](http://rubygems.org/gems/hiki2latex)
5
+
6
+ # 【使用法】
7
+ ```bash
8
+ Usage: hiki2latex [options] FILE
9
+ -v, --version show program Version.
10
+ -l, --level VALUE set Level for output section.
11
+ -p, --plain FILE make Plain document.
12
+ -b, --bare FILE make Bare document.
13
+ --head FILE put headers of maketitle file.
14
+ --pre FILE put preamble file.
15
+ --post FILE put post file.
16
+ --listings use listings.sty for preformat with style.
17
+ ```
18
+ - より詳細な使用法は,![](hiki2latex_gemizing)にある.
19
+ - 西谷研の内部で利用するときに特化したマニュアルは[こちら](hiki2latex_manual).
20
+
21
+ ## sample
22
+ 幾つかのサンプルを以下に示す.
23
+ ### caption:hiki2latexにより作成されたpdfファイトとその元ネタ.
24
+
25
+ |ソース(hiki表示)|pdf(latex変換後)|
26
+ |:----|:----|
27
+ |[[Shunkuntype]]|[[Shunkuntype]]のレポート|
28
+ |[[LPSO15研究会の例|LPSO15_fall_meeting_abst]]|{{attach_anchor(LPSO_abst.pdf)}}|
29
+ |[[中間発表hand out例|AbstSample]]|{{attach_anchor(AbstSample.pdf)}}|
30
+ |[[使っているformat集|DocumentFormatter_format_examples]]|
31
+
32
+
33
+ # 【仕様】
34
+ 1. hikdoc.rbにwrap
35
+ 1. header部を独立して提供
36
+ 1. author, titleはheadに手を加えて提供
37
+ 1. 図はattach_viewを変換
38
+ 1. 表はそのまま表示
39
+ 1. tableのmulti対応
40
+ 1. captionはheaderで提供
41
+ 1. citeは対応しない.
42
+ 1. graph, tableは[h]で提供.
43
+
44
+ # 【具体的な使用例rakefile】
45
+ 具体的な使用例として![](Shunkuntype_report)を作成した時のRakefile.rbを示す.何度も書き直す時は,このようにして自動化すべき.
46
+ ```ruby
47
+ task :shunkuntype do
48
+ dir = '~/Sites/nishitani0/Internal/data/text/'
49
+ targets =["Shunkuntype_manual","Shunkuntype_gemizing","TouchTyping_Coding"]
50
+ targets.each{|file|
51
+ p command= "rm -f #{file}.tex"
52
+ system command
53
+ p command= "hiki2latex -l 2 --listings -b #{dir}#{file} > #{file}.tex"
54
+ system command
55
+ }
56
+ file="Shunkuntype_report"
57
+ p command= "rm -f #{file}.tex"
58
+ # p command= "hiki2latex --listings --head head.tex --post post.tex -p #{dir}#{file} > #{file}.tex"
59
+ p command= "hiki2latex --listings --post post.tex -p #{dir}#{file} > #{file}.tex"
60
+ system command
61
+
62
+ p command = "open #{file}.tex"
63
+ system command
64
+ exit
65
+ end
66
+ ```
67
+ 本文(Shunkuntype_report.tex)と付録(targets.texs)がある.付録は'-l 2 -b'によってsubsectionからのtitle levelにしてbare modeで作っている.post.texにpostで付け加えるtex部を指定して,appendixをつけている.
68
+
69
+ # 【code documents】
70
+ [rdoc](http://nishitani0.kwansei.ac.jp/~bob/nishitani0/rdocs/hiki2latex/index.html)に置いといたけど,ruby gemsやgithubに置けば不要となる.
71
+ # 【変更履歴,内容】
72
+ 変更履歴,内容を表に示す.15/8月期で基本開発.16/2月期にgem化.
73
+ ## caption:変更履歴,内容
74
+
75
+ |memo |date|hiki|
76
+ |:----|:----|:----|
77
+ |hikidoc.rbからhiki2latex.rb|15/8/4|[[hiki2latex_init]]|
78
+ |hiki2latex.rbひな形作成|15/8/5|
79
+ |@fをStringIOからStringへ|15/8/5|
80
+ |graph+caption|15/8/6|[[LPSO15_fall_meeting_abst]]|
81
+ |math|15/8/7| [[hiki2latex_math]]|
82
+ |table| 15/8/8| [[hiki2latex_table]]|
83
+ |under_score| 15/8/11 | [[hiki2latex_math]]|
84
+ |gem化| 16/2/13 | [[hiki2latex_gemizing]]|
85
+ |listings| 16/2/16 | [[hiki2latex_listings]]|
86
+
87
+
88
+ # 【開発メモ】
89
+ ## 制限事項
90
+ - title中へuriの埋め込みが未対応.
91
+ - uriのverbがlatexのtitle内で使えないため.
92
+ ## 【 保留項目】
93
+ 1. includegraphicsの自動提供
94
+ 1. hikiに置かれているgraphは劣化版なんでそれをいじるのはあまり筋がよろしくない.
95
+ 1. epsならできるかも.hikeのattach_viewでサイズをどういじっているか...
96
+ 1. underbar(_)がlatexでは全て引っかかる.escapeする?-> 対応済み ![](hiki2latex_math)
97
+ 1. snake表記はrubyではfile名や変数名に頻繁に使われるので対処が必要かも.
98
+
99
+ ## 【math】
100
+ $$での変換がうまくいかない.
101
+ ```
102
+ hikiconf.rb
103
+ ```
104
+ での設定を
105
+ ```
106
+ #@style = 'default'
107
+ @style = 'math'
108
+ ```
109
+ としたらhikiからエラーは出なくなったが.まだまだ....
110
+
111
+ ## 【user def】
112
+ ```
113
+ \def\Vec#1{\mbox{\boldmath $#1$}}
114
+ ```
115
+ はpreambleに置くことが推奨されているが,実際は,使用するまでに定義すればいい.preambleをいじるようになるころには,latexについての十分な経験があると思われるので,hiki2latexではいじらない.ちょこっと必要ならhiki本文中に埋め込むべし.今の仕様では,
116
+ ```ruby
117
+ def initialize(file_name)
118
+ @buf = ""
119
+ @buf << HEADER+"\n"
120
+ @buf << "\\begin{document}\n"
121
+ @buf << HikiDoc.to_latex(file_name)+"\n"
122
+ @buf << REFERENCE+"\n"
123
+ @buf << "\\end{document}\n"
124
+ end
125
+
126
+ def display
127
+ @buf
128
+ end
129
+ ```
130
+ とするのが正しそうなので,無理に入れていない.将来はpreambleを保持するような拡張機能(option)が必要かもしれない.それは,「原典一つ主義」で,hikiを原典とするか,latexを原典とするかの選択が迫られたとき.
131
+ - 追記(2015/02/17) いい考察だ.解はでてないが今はhiki2latexに埋め込んで,それらの仕様をできるだけ吸収しようとしている.
data/Rakefile CHANGED
@@ -10,18 +10,15 @@ task :default do
10
10
  end
11
11
 
12
12
 
13
- YARD::Rake::YardocTask.new
13
+ desc "make documents by yard"
14
+ task :yard do
15
+ system "hiki2md docs/readme.hiki > docs/README.en.md"
16
+ system "hiki2md docs/readme.ja.hiki > docs/README.ja.md"
17
+ YARD::Rake::YardocTask.new
18
+ end
14
19
 
15
20
  RSpec::Core::RakeTask.new(:spec)
16
21
 
17
- desc "test using unit/test"
18
- Rake::TestTask.new(:test) do |test|
19
- test.libs << "test"
20
- test.libs << "lib"
21
- test.test_files = FileList['test/**/*_test.rb']
22
- test.verbose = true
23
- end
24
-
25
22
  desc "all procedure for release."
26
23
  task :update =>[:setenv] do
27
24
  system 'emacs ./lib/hiki2latex/version.rb'
data/docs/README.en.md ADDED
@@ -0,0 +1,58 @@
1
+ # Hiki2latex
2
+ convert hikidoc text to latex format.
3
+
4
+ ## Installation
5
+ Add this line to your application's Gemfile:
6
+ ```ruby
7
+ gem 'hiki2latex'
8
+ ```
9
+ And then execute:
10
+ ```
11
+ $ bundle
12
+ ```
13
+ Or install it yourself as:
14
+ ```
15
+ $ gem install hiki2latex
16
+ ```
17
+
18
+ ## Usage
19
+ Use as a gem library:
20
+ ```ruby
21
+ require 'hiki2latex'
22
+
23
+ puts HikiDoc.to_latex(File.read(ARGV[0]),{:level=>@level,:listings=>@listings})
24
+ ```
25
+
26
+ or as a command line tool:
27
+
28
+ <dl>
29
+ <dt>Usage</dt><dd> hiki2latex [options] FILE</dd>
30
+ </dl>
31
+
32
+
33
+ | option | operation|
34
+ |:----|:----|
35
+ | -v, --version | show program Version.|
36
+ | -l, --level VALUE | set Level for output section.|
37
+ | -p, --plain FILE | make Plain document.|
38
+ | -b, --bare FILE | make Bare document.|
39
+ | --head FILE | put headers of maketitle file.|
40
+ | --pre FILE | put preamble file.|
41
+ | --post FILE | put post file.|
42
+ | --listings | use listings.sty for preformat with style.|
43
+
44
+ ```
45
+ > hiki2latex --pre PRICM_preamble.tex --post biblio.tex -p test.hiki > test.tex
46
+ > hiki2latex --listings --post post.tex -p ./test.hiki > test.tex
47
+ ```
48
+
49
+ ## Development
50
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. Run `bundle exec hiki2latex` to use the gem in this directory, ignoring other installed copies of this gem.
51
+
52
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
53
+
54
+ ## Contributing
55
+ Bug reports and pull requests are welcome on GitHub at https://github.com/daddygongon/hiki2latex. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
56
+
57
+ ## License
58
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/docs/README.ja.md ADDED
@@ -0,0 +1,131 @@
1
+ # 【概要】
2
+ hiki formatで書かれた文章を,latex formatに変換する
3
+ # 【documents】
4
+ - ![](http://rubygems.org/gems/hiki2latex)
5
+
6
+ # 【使用法】
7
+ ```bash
8
+ Usage: hiki2latex [options] FILE
9
+ -v, --version show program Version.
10
+ -l, --level VALUE set Level for output section.
11
+ -p, --plain FILE make Plain document.
12
+ -b, --bare FILE make Bare document.
13
+ --head FILE put headers of maketitle file.
14
+ --pre FILE put preamble file.
15
+ --post FILE put post file.
16
+ --listings use listings.sty for preformat with style.
17
+ ```
18
+ - より詳細な使用法は,![](hiki2latex_gemizing)にある.
19
+ - 西谷研の内部で利用するときに特化したマニュアルは[こちら](hiki2latex_manual).
20
+
21
+ ## sample
22
+ 幾つかのサンプルを以下に示す.
23
+ ### caption:hiki2latexにより作成されたpdfファイトとその元ネタ.
24
+
25
+ |ソース(hiki表示)|pdf(latex変換後)|
26
+ |:----|:----|
27
+ |[[Shunkuntype]]|[[Shunkuntype]]のレポート|
28
+ |[[LPSO15研究会の例|LPSO15_fall_meeting_abst]]|{{attach_anchor(LPSO_abst.pdf)}}|
29
+ |[[中間発表hand out例|AbstSample]]|{{attach_anchor(AbstSample.pdf)}}|
30
+ |[[使っているformat集|DocumentFormatter_format_examples]]|
31
+
32
+
33
+ # 【仕様】
34
+ 1. hikdoc.rbにwrap
35
+ 1. header部を独立して提供
36
+ 1. author, titleはheadに手を加えて提供
37
+ 1. 図はattach_viewを変換
38
+ 1. 表はそのまま表示
39
+ 1. tableのmulti対応
40
+ 1. captionはheaderで提供
41
+ 1. citeは対応しない.
42
+ 1. graph, tableは[h]で提供.
43
+
44
+ # 【具体的な使用例rakefile】
45
+ 具体的な使用例として![](Shunkuntype_report)を作成した時のRakefile.rbを示す.何度も書き直す時は,このようにして自動化すべき.
46
+ ```ruby
47
+ task :shunkuntype do
48
+ dir = '~/Sites/nishitani0/Internal/data/text/'
49
+ targets =["Shunkuntype_manual","Shunkuntype_gemizing","TouchTyping_Coding"]
50
+ targets.each{|file|
51
+ p command= "rm -f #{file}.tex"
52
+ system command
53
+ p command= "hiki2latex -l 2 --listings -b #{dir}#{file} > #{file}.tex"
54
+ system command
55
+ }
56
+ file="Shunkuntype_report"
57
+ p command= "rm -f #{file}.tex"
58
+ # p command= "hiki2latex --listings --head head.tex --post post.tex -p #{dir}#{file} > #{file}.tex"
59
+ p command= "hiki2latex --listings --post post.tex -p #{dir}#{file} > #{file}.tex"
60
+ system command
61
+
62
+ p command = "open #{file}.tex"
63
+ system command
64
+ exit
65
+ end
66
+ ```
67
+ 本文(Shunkuntype_report.tex)と付録(targets.texs)がある.付録は'-l 2 -b'によってsubsectionからのtitle levelにしてbare modeで作っている.post.texにpostで付け加えるtex部を指定して,appendixをつけている.
68
+
69
+ # 【code documents】
70
+ [rdoc](http://nishitani0.kwansei.ac.jp/~bob/nishitani0/rdocs/hiki2latex/index.html)に置いといたけど,ruby gemsやgithubに置けば不要となる.
71
+ # 【変更履歴,内容】
72
+ 変更履歴,内容を表に示す.15/8月期で基本開発.16/2月期にgem化.
73
+ ## caption:変更履歴,内容
74
+
75
+ |memo |date|hiki|
76
+ |:----|:----|:----|
77
+ |hikidoc.rbからhiki2latex.rb|15/8/4|[[hiki2latex_init]]|
78
+ |hiki2latex.rbひな形作成|15/8/5|
79
+ |@fをStringIOからStringへ|15/8/5|
80
+ |graph+caption|15/8/6|[[LPSO15_fall_meeting_abst]]|
81
+ |math|15/8/7| [[hiki2latex_math]]|
82
+ |table| 15/8/8| [[hiki2latex_table]]|
83
+ |under_score| 15/8/11 | [[hiki2latex_math]]|
84
+ |gem化| 16/2/13 | [[hiki2latex_gemizing]]|
85
+ |listings| 16/2/16 | [[hiki2latex_listings]]|
86
+
87
+
88
+ # 【開発メモ】
89
+ ## 制限事項
90
+ - title中へuriの埋め込みが未対応.
91
+ - uriのverbがlatexのtitle内で使えないため.
92
+ ## 【 保留項目】
93
+ 1. includegraphicsの自動提供
94
+ 1. hikiに置かれているgraphは劣化版なんでそれをいじるのはあまり筋がよろしくない.
95
+ 1. epsならできるかも.hikeのattach_viewでサイズをどういじっているか...
96
+ 1. underbar(_)がlatexでは全て引っかかる.escapeする?-> 対応済み ![](hiki2latex_math)
97
+ 1. snake表記はrubyではfile名や変数名に頻繁に使われるので対処が必要かも.
98
+
99
+ ## 【math】
100
+ $$での変換がうまくいかない.
101
+ ```
102
+ hikiconf.rb
103
+ ```
104
+ での設定を
105
+ ```
106
+ #@style = 'default'
107
+ @style = 'math'
108
+ ```
109
+ としたらhikiからエラーは出なくなったが.まだまだ....
110
+
111
+ ## 【user def】
112
+ ```
113
+ \def\Vec#1{\mbox{\boldmath $#1$}}
114
+ ```
115
+ はpreambleに置くことが推奨されているが,実際は,使用するまでに定義すればいい.preambleをいじるようになるころには,latexについての十分な経験があると思われるので,hiki2latexではいじらない.ちょこっと必要ならhiki本文中に埋め込むべし.今の仕様では,
116
+ ```ruby
117
+ def initialize(file_name)
118
+ @buf = ""
119
+ @buf << HEADER+"\n"
120
+ @buf << "\\begin{document}\n"
121
+ @buf << HikiDoc.to_latex(file_name)+"\n"
122
+ @buf << REFERENCE+"\n"
123
+ @buf << "\\end{document}\n"
124
+ end
125
+
126
+ def display
127
+ @buf
128
+ end
129
+ ```
130
+ とするのが正しそうなので,無理に入れていない.将来はpreambleを保持するような拡張機能(option)が必要かもしれない.それは,「原典一つ主義」で,hikiを原典とするか,latexを原典とするかの選択が迫られたとき.
131
+ - 追記(2015/02/17) いい考察だ.解はでてないが今はhiki2latexに埋め込んで,それらの仕様をできるだけ吸収しようとしている.
data/docs/readme.hiki ADDED
@@ -0,0 +1,48 @@
1
+ ! Hiki2latex
2
+ convert hikidoc text to latex format.
3
+
4
+ !! Installation
5
+ Add this line to your application's Gemfile:
6
+ <<< ruby
7
+ gem 'hiki2latex'
8
+ >>>
9
+ And then execute:
10
+ $ bundle
11
+ Or install it yourself as:
12
+ $ gem install hiki2latex
13
+
14
+ !! Usage
15
+ Use as a gem library:
16
+ <<<ruby
17
+ require 'hiki2latex'
18
+
19
+ puts HikiDoc.to_latex(File.read(ARGV[0]),{:level=>@level,:listings=>@listings})
20
+ >>>
21
+
22
+ or as a command line tool:
23
+
24
+ :Usage: hiki2latex [options] FILE
25
+
26
+ || option || operation
27
+ || -v, --version || show program Version.
28
+ || -l, --level VALUE || set Level for output section.
29
+ || -p, --plain FILE || make Plain document.
30
+ || -b, --bare FILE || make Bare document.
31
+ || --head FILE || put headers of maketitle file.
32
+ || --pre FILE || put preamble file.
33
+ || --post FILE || put post file.
34
+ || --listings || use listings.sty for preformat with style.
35
+ > hiki2latex --pre PRICM_preamble.tex --post biblio.tex -p test.hiki > test.tex
36
+ > hiki2latex --listings --post post.tex -p ./test.hiki > test.tex
37
+
38
+ !! Development
39
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. Run `bundle exec hiki2latex` to use the gem in this directory, ignoring other installed copies of this gem.
40
+
41
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
42
+
43
+ !! Contributing
44
+ Bug reports and pull requests are welcome on GitHub at https://github.com/daddygongon/hiki2latex. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
45
+
46
+ !! License
47
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
48
+
@@ -0,0 +1,120 @@
1
+ {{toc}}
2
+ !【概要】
3
+ hiki formatで書かれた文章を,latex formatに変換する
4
+ !【documents】
5
+ * [[http://rubygems.org/gems/hiki2latex]]
6
+
7
+ !【使用法】
8
+ <<< bash
9
+ Usage: hiki2latex [options] FILE
10
+ -v, --version show program Version.
11
+ -l, --level VALUE set Level for output section.
12
+ -p, --plain FILE make Plain document.
13
+ -b, --bare FILE make Bare document.
14
+ --head FILE put headers of maketitle file.
15
+ --pre FILE put preamble file.
16
+ --post FILE put post file.
17
+ --listings use listings.sty for preformat with style.
18
+ >>>
19
+ *より詳細な使用法は,[[hiki2latex_gemizing]]にある.
20
+ *西谷研の内部で利用するときに特化したマニュアルは[[こちら|hiki2latex_manual]].
21
+
22
+ !!sample
23
+ 幾つかのサンプルを以下に示す.
24
+ !!!caption:hiki2latexにより作成されたpdfファイトとその元ネタ.
25
+ ||ソース(hiki表示)||pdf(latex変換後)
26
+ ||[[Shunkuntype]]||[[Shunkuntype]]のレポート
27
+ ||[[LPSO15研究会の例|LPSO15_fall_meeting_abst]]||{{attach_anchor(LPSO_abst.pdf)}}
28
+ ||[[中間発表hand out例|AbstSample]]||{{attach_anchor(AbstSample.pdf)}}
29
+ ||[[使っているformat集|DocumentFormatter_format_examples]]||
30
+
31
+ !【仕様】
32
+ # hikdoc.rbにwrap
33
+ # header部を独立して提供
34
+ # author, titleはheadに手を加えて提供
35
+ # 図はattach_viewを変換
36
+ # 表はそのまま表示
37
+ ## tableのmulti対応
38
+ # captionはheaderで提供
39
+ # citeは対応しない.
40
+ # graph, tableは[h]で提供.
41
+
42
+ !【具体的な使用例rakefile】
43
+ 具体的な使用例として[[Shunkuntype_report]]を作成した時のRakefile.rbを示す.何度も書き直す時は,このようにして自動化すべき.
44
+ <<< ruby
45
+ task :shunkuntype do
46
+ dir = '~/Sites/nishitani0/Internal/data/text/'
47
+ targets =["Shunkuntype_manual","Shunkuntype_gemizing","TouchTyping_Coding"]
48
+ targets.each{|file|
49
+ p command= "rm -f #{file}.tex"
50
+ system command
51
+ p command= "hiki2latex -l 2 --listings -b #{dir}#{file} > #{file}.tex"
52
+ system command
53
+ }
54
+ file="Shunkuntype_report"
55
+ p command= "rm -f #{file}.tex"
56
+ # p command= "hiki2latex --listings --head head.tex --post post.tex -p #{dir}#{file} > #{file}.tex"
57
+ p command= "hiki2latex --listings --post post.tex -p #{dir}#{file} > #{file}.tex"
58
+ system command
59
+
60
+ p command = "open #{file}.tex"
61
+ system command
62
+ exit
63
+ end
64
+ >>>
65
+ 本文(Shunkuntype_report.tex)と付録(targets.texs)がある.付録は'-l 2 -b'によってsubsectionからのtitle levelにしてbare modeで作っている.post.texにpostで付け加えるtex部を指定して,appendixをつけている.
66
+
67
+ !【code documents】
68
+ [[rdoc|http://nishitani0.kwansei.ac.jp/~bob/nishitani0/rdocs/hiki2latex/index.html]]に置いといたけど,ruby gemsやgithubに置けば不要となる.
69
+ !【変更履歴,内容】
70
+ 変更履歴,内容を表に示す.15/8月期で基本開発.16/2月期にgem化.
71
+ !!caption:変更履歴,内容
72
+ ||memo ||date||hiki
73
+ ||hikidoc.rbからhiki2latex.rb||15/8/4||[[hiki2latex_init]]
74
+ ||hiki2latex.rbひな形作成||15/8/5
75
+ ||@fをStringIOからStringへ||15/8/5
76
+ ||graph+caption||15/8/6||[[LPSO15_fall_meeting_abst]]
77
+ ||math||15/8/7|| [[hiki2latex_math]]
78
+ ||table|| 15/8/8|| [[hiki2latex_table]]
79
+ ||under_score|| 15/8/11 || [[hiki2latex_math]]
80
+ ||gem化|| 16/2/13 || [[hiki2latex_gemizing]]
81
+ ||listings|| 16/2/16 || [[hiki2latex_listings]]
82
+
83
+ !【開発メモ】
84
+ !!制限事項
85
+ * title中へuriの埋め込みが未対応.
86
+ ** uriのverbがlatexのtitle内で使えないため.
87
+ !!【 保留項目】
88
+ # includegraphicsの自動提供
89
+ ## hikiに置かれているgraphは劣化版なんでそれをいじるのはあまり筋がよろしくない.
90
+ ## epsならできるかも.hikeのattach_viewでサイズをどういじっているか...
91
+ # underbar(_)がlatexでは全て引っかかる.escapeする?-> 対応済み [[hiki2latex_math]]
92
+ ## snake表記はrubyではfile名や変数名に頻繁に使われるので対処が必要かも.
93
+
94
+ !! 【math】
95
+ $$での変換がうまくいかない.
96
+ hikiconf.rb
97
+ での設定を
98
+ #@style = 'default'
99
+ @style = 'math'
100
+ としたらhikiからエラーは出なくなったが.まだまだ....
101
+
102
+ !!【user def】
103
+ \def\Vec#1{\mbox{\boldmath $#1$}}
104
+ はpreambleに置くことが推奨されているが,実際は,使用するまでに定義すればいい.preambleをいじるようになるころには,latexについての十分な経験があると思われるので,hiki2latexではいじらない.ちょこっと必要ならhiki本文中に埋め込むべし.今の仕様では,
105
+ <<< ruby
106
+ def initialize(file_name)
107
+ @buf = ""
108
+ @buf << HEADER+"\n"
109
+ @buf << "\\begin{document}\n"
110
+ @buf << HikiDoc.to_latex(file_name)+"\n"
111
+ @buf << REFERENCE+"\n"
112
+ @buf << "\\end{document}\n"
113
+ end
114
+
115
+ def display
116
+ @buf
117
+ end
118
+ >>>
119
+ とするのが正しそうなので,無理に入れていない.将来はpreambleを保持するような拡張機能(option)が必要かもしれない.それは,「原典一つ主義」で,hikiを原典とするか,latexを原典とするかの選択が迫られたとき.
120
+ **追記(2015/02/17) いい考察だ.解はでてないが今はhiki2latexに埋め込んで,それらの仕様をできるだけ吸収しようとしている.
data/hiki2latex.gemspec CHANGED
@@ -37,5 +37,6 @@ EOF
37
37
  spec.add_development_dependency "yard", "~> 0.8"
38
38
  spec.add_development_dependency "test-unit"
39
39
  spec.add_development_dependency "systemu"
40
+ spec.add_development_dependency "hiki2md"
40
41
  spec.add_runtime_dependency "hikidoc","~>0.1.0"
41
42
  end
@@ -170,8 +170,10 @@ class LatexOutput
170
170
  @f << "#{lines.join("\n")}\n\n"
171
171
  end
172
172
  def blockquote_open()
173
+ @f << "\\begin{quotation}\n"
173
174
  end
174
175
  def blockquote_close()
176
+ @f << "\\end{quotation}\n"
175
177
  end
176
178
 
177
179
  def del(item)
@@ -179,11 +181,12 @@ class LatexOutput
179
181
  end
180
182
 
181
183
  def em(item)
182
- @f << "\\textbf\{#{item}\}"
184
+ # @f << "\\textbf\{#{item}\}"
185
+ @f << "#{item}"
183
186
  end
184
187
 
185
188
  def strong(item)
186
- @f << "\\textbf\{#{item}\}"
189
+ # @f << "\\textbf\{#{item}\}"
187
190
  end
188
191
 
189
192
  def block_preformatted(str, info)
@@ -1,3 +1,3 @@
1
1
  module Hiki2latex
2
- VERSION = "0.9.11"
2
+ VERSION = "0.9.12"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hiki2latex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.11
4
+ version: 0.9.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shigeto R. Nishitani
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-08 00:00:00.000000000 Z
11
+ date: 2016-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: hiki2md
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: hikidoc
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -117,18 +131,26 @@ executables:
117
131
  extensions: []
118
132
  extra_rdoc_files: []
119
133
  files:
134
+ - "#Rakefile#"
135
+ - "#hiki2latex.gemspec#"
120
136
  - ".gitignore"
137
+ - ".rspec"
121
138
  - ".travis.yml"
139
+ - ".yardopts"
122
140
  - CODE_OF_CONDUCT.md
123
141
  - Gemfile
124
142
  - LICENSE.txt
125
- - README.md
143
+ - README.en.md
144
+ - README.ja.md
126
145
  - Rakefile
127
146
  - bin/console
128
147
  - bin/setup
148
+ - docs/README.en.md
149
+ - docs/README.ja.md
150
+ - docs/readme.hiki
151
+ - docs/readme.ja.hiki
129
152
  - exe/hiki2latex
130
153
  - hiki2latex.gemspec
131
- - lib/#hiki2latex.rb#
132
154
  - lib/hiki2latex.rb
133
155
  - lib/hiki2latex/hiki2latex.rb
134
156
  - lib/hiki2latex/version.rb
data/lib/#hiki2latex.rb# DELETED
@@ -1,145 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- require 'optparse'
3
- require "hiki2latex/version"
4
- #require "hiki2latex/hikidoc"
5
- require "hiki2latex/hiki2latex"
6
- require 'pp'
7
-
8
- module Hiki2latex
9
- class Command
10
-
11
- def self.run(argv=[])
12
- new(argv).execute
13
- end
14
-
15
- def initialize(argv=[])
16
- @argv = argv
17
- @pre=@head=@post=nil
18
- @listings=false
19
- end
20
-
21
- def execute
22
- @argv << '--help' if @argv.size==0
23
- command_parser = OptionParser.new do |opt|
24
- opt.on('-v', '--version','show program Version.') { |v|
25
- opt.version = Hiki2latex::VERSION
26
- puts opt.ver
27
- }
28
- opt.on('-l VALUE','--level','set Level for output section.'){|level| @level=level.to_i}
29
- opt.on('-p FILE', '--plain','make Plain document.') { |file| plain_doc(file) }
30
- opt.on('-b FILE', '--bare','make Bare document.') { |file| bare_doc(file) }
31
- opt.on('--head FILE', 'put headers of maketitle file.') { |file| @head=file }
32
- opt.on('--pre FILE', 'put preamble file.') { |file| @pre=file }
33
- opt.on('--post FILE', 'put post file.') { |file| @post=file }
34
- opt.on('--listings', 'use listings.sty for preformat with style.') {@listings=true }
35
- end
36
- command_parser.banner = "Usage: hiki2latex [options] FILE"
37
- command_parser.parse!(@argv)
38
- plain_doc(@argv[0]) if @argv[0]!=nil
39
- exit
40
- end
41
-
42
- # pre, post, listings��ʒ�ɒ�Β�Ȓĥ������
43
- def plain_doc(file)
44
- if @listings==true then
45
- puts listings_preamble
46
- elsif @pre==nil then
47
- puts "\\documentclass[12pt,a4paper]{jsarticle}"
48
- puts "\\usepackage[dvipdfmx]{graphicx}"
49
- else
50
- puts File.read(@pre)
51
- end
52
- puts "\\begin{document}"
53
- puts File.read(@head) if @head!=nil
54
- plain_tex = HikiDoc.to_latex(File.read(file),{:listings=>@listings})
55
- puts mod_abstract(plain_tex)
56
- puts File.read(@post) if @post!=nil
57
- puts "\\end{document}"
58
- end
59
-
60
- def bare_doc(file)
61
- bare_doc = HikiDoc.to_latex(File.read(file),{:level=>@level,:listings=>@listings})
62
- puts kill_head_tableofcontents(bare_doc)
63
- end
64
-
65
- def kill_head_tableofcontents(text)
66
- text.gsub!(/^\\tableofcontents/,'')
67
- return text
68
- end
69
-
70
- # convert section to abstract in the plain text
71
- def mod_abstract(text)
72
- # return text
73
- abstract,section = [],[]
74
- content = ""
75
- text.split("\n").each do |line|
76
- case line
77
- when /^\\section(.+)/
78
- section.push $1
79
- end
80
- # p section[-1]
81
- case section[-1]
82
- when /\{abstract\}/, /\{���abstract���\}/
83
- abstract << line+"\n"
84
- when /\{������\}/, /\{��ڒ����ג��\}/
85
- abstract << line+"\n"
86
- else
87
- content << line+"\n"
88
- end
89
- end
90
- # p abstract
91
- if abstract.size>1 then
92
- abstract.delete_at(0)
93
- content.gsub!(/\\tableofcontents/){|text|
94
- tt="\n\\abstract\{\n#{abstract.join}\}\n\\tableofcontents"
95
- }
96
- end
97
- return content
98
- end
99
-
100
- def listings_preamble
101
- str = <<"EOS"
102
- \\documentclass[12pt,a4paper]{jsarticle}
103
- \\usepackage[dvipdfmx]{graphicx}
104
- \\usepackage[dvipdfmx]{color}
105
- \\usepackage{listings}
106
- % to use japanese correctly, install jlistings.
107
- \\lstset{
108
- basicstyle={\\small\\ttfamily},
109
- identifierstyle={\\small},
110
- commentstyle={\\small\\itshape\\color{red}},
111
- keywordstyle={\\small\\bfseries\\color{cyan}},
112
- ndkeywordstyle={\\small},
113
- stringstyle={\\small\\color{blue}},
114
- frame={tb},
115
- breaklines=true,
116
- numbers=left,
117
- numberstyle={\\scriptsize},
118
- stepnumber=1,
119
- numbersep=1zw,
120
- xrightmargin=0zw,
121
- xleftmargin=3zw,
122
- lineskip=-0.5ex
123
- }
124
- \\lstdefinestyle{customCsh}{
125
- language={csh},
126
- numbers=none,
127
- }
128
- \\lstdefinestyle{customRuby}{
129
- language={ruby},
130
- numbers=left,
131
- }
132
- \\lstdefinestyle{customTex}{
133
- language={tex},
134
- numbers=none,
135
- }
136
- \\lstdefinestyle{customJava}{
137
- language={java},
138
- numbers=left,
139
- }
140
- EOS
141
- end
142
-
143
- end
144
- end
145
-