From 2b2929e0901a98a37a32e18934c9675dff63d1e7 Mon Sep 17 00:00:00 2001 From: Toshio Sekiya Date: Sat, 16 Apr 2022 17:31:29 +0900 Subject: [PATCH] Bug fixed. --- Rakefile | 4 ++-- gfm/sec6.md | 2 +- lib/lib_src2md.rb | 2 +- src/sec6.src.md | 2 +- test/test_lib_src2md.rb | 16 ++++++++++++++++ 5 files changed, 21 insertions(+), 5 deletions(-) diff --git a/Rakefile b/Rakefile index a1cd1a5..7550070 100644 --- a/Rakefile +++ b/Rakefile @@ -113,7 +113,7 @@ task pdf: %w[latex/main.tex] do sh "mv latex/main.pdf latex/gtk4_tutorial.pdf" end -file "latex/main.tex" => [abstract_tex] + sectexfiles + othertexfiles do +file "latex/main.tex" => [abstract_tex] + texfiles do gen_main_tex "latex", abstract.to_tex, sectexfiles, othertexfiles end @@ -124,7 +124,7 @@ file abstract_tex => abstract do File.delete(abstract_md) end -(0...srcfiles.size).each do |i| +(0...texfiles.size).each do |i| file texfiles[i] => [srcfiles[i]] + srcfiles[i].c_files do tex_md = "latex/#{srcfiles[i].to_md}" src2md srcfiles[i], tex_md, "latex" diff --git a/gfm/sec6.md b/gfm/sec6.md index 5ad729d..68226ba 100644 --- a/gfm/sec6.md +++ b/gfm/sec6.md @@ -159,7 +159,7 @@ char *s; s = g_new (char, 10); /* s points an array of char. The size of the array is 10. */ -struct tuple (int x, int y) *t; +struct tuple {int x, y;} *t; t = g_new (struct tuple, 5); /* t points an array of struct tuple. */ /* The size of the array is 5. */ diff --git a/lib/lib_src2md.rb b/lib/lib_src2md.rb index 8becf1a..acd8230 100644 --- a/lib/lib_src2md.rb +++ b/lib/lib_src2md.rb @@ -329,7 +329,7 @@ def change_link src, old_dir, type, new_dir=nil when "html" "#{name}(#{target})" when "latex" - chunk + "#{name}(#{target})#{size}" end else p_target = Pathname.new "#{old_dir}/#{target}" diff --git a/src/sec6.src.md b/src/sec6.src.md index 97329d9..a3609de 100644 --- a/src/sec6.src.md +++ b/src/sec6.src.md @@ -157,7 +157,7 @@ char *s; s = g_new (char, 10); /* s points an array of char. The size of the array is 10. */ -struct tuple (int x, int y) *t; +struct tuple {int x, y;} *t; t = g_new (struct tuple, 5); /* t points an array of struct tuple. */ /* The size of the array is 5. */ diff --git a/test/test_lib_src2md.rb b/test/test_lib_src2md.rb index e47f1c4..58d5973 100644 --- a/test/test_lib_src2md.rb +++ b/test/test_lib_src2md.rb @@ -878,6 +878,22 @@ class Test_lib_src_file < Minitest::Test assert_equal files_src2md()[:sample_md_gfm], dst_md["gfm"] assert_equal files_src2md()[:sample_md_html], dst_md["html"] assert_equal files_src2md()[:sample_md_latex], dst_md["latex"] + + temp = "temp"+Time.now.to_f.to_s.gsub(/\./,'') + src_dir = "#{temp}/src" + dst_dir = "#{temp}/dst" + Dir.mkdir(temp) unless Dir.exist?(temp) + Dir.mkdir(src_dir) unless Dir.exist?(src_dir) + Dir.mkdir(dst_dir) unless Dir.exist?(dst_dir) + File.write("#{src_dir}/sample.src.md", "![image](image/image.png){width=8cm hight=6cm}\n") + ["gfm", "html", "latex"].each do |d| + src2md "#{src_dir}/sample.src.md", "#{dst_dir}/sample.md", d + dst_md[d] = File.read "#{dst_dir}/sample.md" + end + remove_entry_secure(temp) + assert_equal "![image](../src/image/image.png)\n", dst_md["gfm"] + assert_equal "![image](../src/image/image.png)\n", dst_md["html"] + assert_equal "![image](../src/image/image.png){width=8cm hight=6cm}\n", dst_md["latex"] end end