Bug fixed in Rakefile and lib_src2md.rb. Add image size for latex.

This commit is contained in:
Toshio Sekiya 2021-04-22 11:48:18 +09:00
parent 327ddc4931
commit f90ef5b3ef
7 changed files with 50 additions and 53 deletions

View file

@ -12,10 +12,10 @@ end
srcfiles = Sec_files.new srcfiles
srcfiles.renum!
mdfilenames = srcfiles.map {|srcfile| "gfm/#{srcfile.to_md}"}
htmlfilenames = srcfiles.map {|srcfile| "html/#{srcfile.to_html}"}
texpathnames = srcfiles.map {|srcfile| "latex/#{srcfile.to_tex}"}
texfilenames = srcfiles.map {|srcfile| srcfile.to_tex}
mdpathnames = srcfiles.map {|srcfile| "gfm/#{srcfile.to_md}"}
htmlpathnames = srcfiles.map {|srcfile| "html/#{srcfile.to_html}"}
texpathnames = srcfiles.map {|srcfile| "latex/#{srcfile.to_tex}"}
texfilenames = srcfiles.map {|srcfile| srcfile.to_tex}
["gfm", "html", "latex"].each do |d|
if ! Dir.exist?(d)
@ -23,7 +23,7 @@ texfilenames = srcfiles.map {|srcfile| srcfile.to_tex}
end
end
CLEAN.append(*mdfilenames)
CLEAN.append(*mdpathnames)
CLEAN << "Readme.md"
# tasks
@ -33,18 +33,12 @@ task all: [:md, :html, :pdf]
task md: ["Readme.md", "src/turtle/turtle_doc.md"]
file "Readme.md" => mdfilenames do
file "Readme.md" => mdpathnames+["src/abstract.src.md"] do
buf = [ "# Gtk4 Tutorial for beginners\n", "\n" ]
src2md "src/abstract.src.md", "abstract.md"
File.open("abstract.md") do |file|
file.readlines.each do |line|
buf << line
end
end
buf += File.readlines("abstract.md")
File.delete("abstract.md")
buf << "\n"
buf << "## Table of contents\n\n"
buf << "\n"
buf.append("\n", "## Table of contents\n", "\n")
0.upto(srcfiles.size-1) do |i|
h = File.open(srcfiles[i].path) { |file| file.readline }
h = h.gsub(/^#* */,"").chomp
@ -65,10 +59,10 @@ end
else
nav = "Up: [Readme.md](../Readme.md), Prev: [Section #{i}](#{srcfiles[i-1].to_md}), Next: [Section #{i+2}](#{srcfiles[i+1].to_md})\n"
end
buf = IO.readlines "gfm/#{srcfiles[i].to_md}"
buf = File.readlines "gfm/#{srcfiles[i].to_md}"
buf.insert(0, nav, "\n")
buf.append("\n", nav)
IO.write "gfm/#{srcfiles[i].to_md}", buf.join
File.write "gfm/#{srcfiles[i].to_md}", buf.join
end
end
@ -76,25 +70,22 @@ file "src/turtle/turtle_doc.md" => "src/turtle/turtle_doc.src.md" do
src2md "src/turtle/turtle_doc.src.md", "src/turtle/turtle_doc.md"
end
task html: ["html/index.html", "html/tfetextview_doc.html", "html/turtle_doc.html"]
task html: ["html/index.html", "html/tfetextview_doc.html", "html/turtle_doc.html", "html/Readme_for_developers.html"]
file "html/index.html" => htmlfilenames do
file "html/index.html" => htmlpathnames+["src/abstract.src.md"] do
buf = [ "# Gtk4 Tutorial for beginners\n", "\n" ]
src2md "src/abstract.src.md", "html/abstract.md"
File.open("html/abstract.md") do |file|
file.readlines.each do |line|
buf << line
end
end
buf += File.readlines("html/abstract.md")
File.delete("html/abstract.md")
buf << "\n"
buf.append("\n", "## Table of contents\n", "\n")
0.upto(srcfiles.size-1) do |i|
h = File.open(srcfiles[i].path) { |file| file.readline }
h = h.gsub(/^#* */,"").chomp
buf << "1. [#{h}](#{srcfiles[i].to_html})\n"
end
buf.each do |line|
line.gsub!(/(\[[^\]]*\])\((sec\d+)\.md\)/,"\\1(\\2.html)")
line.gsub!(/doc\/Readme_for_developers.md/,"html/Readme_for_developers.html")
line.gsub!(/(\[[^\]]*\])\((.+)\.md\)/,"\\1(\\2.html)")
end
File.write("html/index.md", buf.join)
sh "pandoc -o html/index.html html/index.md"
@ -114,6 +105,11 @@ file "html/turtle_doc.html" => "src/turtle/turtle_doc.src.md" do
add_head_tail_html "html/turtle_doc.html"
end
file "html/Readme_for_developers.html" => "doc/Readme_for_developers.md" do
sh "pandoc -o html/Readme_for_developers.html doc/Readme_for_developers.md"
add_head_tail_html "html/Readme_for_developers.html"
end
0.upto(srcfiles.size - 1) do |i|
html_md = "html/#{srcfiles[i].to_md}"
html_html = "html/#{srcfiles[i].to_html}"
@ -128,13 +124,13 @@ end
else
nav = "Up: [index.html](index.html), Prev: [Section #{i}](#{srcfiles[i-1].to_html}), Next: [Section #{i+2}](#{srcfiles[i+1].to_html})\n"
end
buf = IO.readlines html_md
buf = File.readlines html_md
buf.insert(0, nav, "\n")
buf.append("\n", nav)
buf.each do |line|
line.gsub!(/(\[[^\]]*\])\((sec\d+)\.md\)/,"\\1(\\2.html)")
line.gsub!(/(\[[^\]]*\])\((.+)\.md\)/,"\\1(\\2.html)")
end
IO.write html_md, buf.join
File.write html_md, buf.join
sh "pandoc -o #{html_html} #{html_md}"
File.delete(html_md)
add_head_tail_html html_html
@ -170,10 +166,12 @@ file "latex/turtle_doc.tex" => "src/turtle/turtle_doc.src.md" do
end
0.upto(srcfiles.size - 1) do |i|
file "latex/#{srcfiles[i].to_tex}" => (srcfiles[i].c_files << srcfiles[i].path) do
src2md srcfiles[i].path, "latex/#{srcfiles[i].to_md}"
sh "pandoc --listings -o latex/#{srcfiles[i].to_tex} latex/#{srcfiles[i].to_md}"
File.delete("latex/#{srcfiles[i].to_md}")
latex_md = "latex/#{srcfiles[i].to_md}"
latex_tex = "latex/#{srcfiles[i].to_tex}"
file latex_tex => (srcfiles[i].c_files << srcfiles[i].path) do
src2md srcfiles[i].path, latex_md
sh "pandoc --listings -o #{latex_tex} #{latex_md}"
File.delete(latex_md)
end
end

View file

@ -9,26 +9,24 @@ The table of contents are shown at the end of this abstract.
- Section 24 to 27 describes list model and list view (GtkListView, GtkGridView and GtkColumnView).
It also describes GtkExpression.
Please refer [Gnome API reference](https://developer.gnome.org/) for further topics.
Please refer to [Gtk API reference](https://developer.gnome.org/gtk4/stable/index.html)
and [Gnome Developer Center](https://developer.gnome.org/) for further topics.
This tutorial is under development and unstable.
Even though the examples written in C language have been tested on gtk4 version 4.0,
there might exist bugs.
If you find any bugs, errors or mistakes in the tutorial and C examples,
please let me know.
Even though the codes of the examples have been tested on gtk4 version 4.0, there might exist bugs.
If you find any bugs, errors or mistakes in the tutorial and C examples, please let me know.
You can post it to [github issues](https://github.com/ToshioCP/Gtk4-tutorial/issues).
The latest version of the tutorial is located at [Gtk4-tutorial github repository](https://github.com/ToshioCP/Gtk4-tutorial).
You can read it without download.
If you want to get a html or pdf version, you can make them with `rake`, which is a ruby version of make.
There is a [documentation](doc/Readme_for_developers.md) how to make them.
There is a documentation \("[How to build Gtk4 Tutorial](doc/Readme_for_developers.md)"\) that describes how to make them.
If you have a question, feel free to post an issue.
If you have a question, feel free to post it to the issue.
Any question is helpful to make this tutorial get better.
## Table of contents
1. [Prerequisite and License](gfm/sec1.md)
1. [Installation of gtk4 to linux distributions](gfm/sec2.md)
1. [GtkApplication and GtkApplicationWindow](gfm/sec3.md)

View file

@ -239,7 +239,9 @@ def src2md srcmd, md, type="gfm"
else
line = change_rel_link(line, src_dir, md_dir)
if type == "latex" # remove relative link
line.gsub!(/(^|[^!])\[([^\]]*)\]\((?~http)\)/,"\\1\\2")
if ! (line =~ /\[[^\]]*\]\(http[^)]*\)/)
line.gsub!(/^([^!]*)\[([^\]]*)\]\([^\)]*\)/,"\\1\\2")
end
else # type == "gfm" or "html", then remove size option from link to image files.
line.gsub!(/(!\[[^\]]*\]\([^\)]*\)) *{width *= *\d*(|\.\d*)cm *height *= *\d*(|\.\d*)cm}/,"\\1")
end

View file

@ -7,19 +7,18 @@ The table of contents are shown at the end of this abstract.
- Section 24 to 27 describes list model and list view (GtkListView, GtkGridView and GtkColumnView).
It also describes GtkExpression.
Please refer [Gnome API reference](https://developer.gnome.org/) for further topics.
Please refer to [Gtk API reference](https://developer.gnome.org/gtk4/stable/index.html)
and [Gnome Developer Center](https://developer.gnome.org/) for further topics.
This tutorial is under development and unstable.
Even though the examples written in C language have been tested on gtk4 version 4.0,
there might exist bugs.
If you find any bugs, errors or mistakes in the tutorial and C examples,
please let me know.
Even though the codes of the examples have been tested on gtk4 version 4.0, there might exist bugs.
If you find any bugs, errors or mistakes in the tutorial and C examples, please let me know.
You can post it to [github issues](https://github.com/ToshioCP/Gtk4-tutorial/issues).
The latest version of the tutorial is located at [Gtk4-tutorial github repository](https://github.com/ToshioCP/Gtk4-tutorial).
You can read it without download.
If you want to get a html or pdf version, you can make them with `rake`, which is a ruby version of make.
There is a [documentation](../doc/Readme_for_developers.md) how to make them.
There is a documentation \("[How to build Gtk4 Tutorial](../doc/Readme_for_developers.md)"\) that describes how to make them.
If you have a question, feel free to post an issue.
If you have a question, feel free to post it to the issue.
Any question is helpful to make this tutorial get better.

View file

@ -125,5 +125,5 @@ Compile and run it, then a window with a black rectangle (square) appears.
Try resizing the window.
The square always appears at the center of the window because the drawing function is invoked every moment the window is resized.
![Square in the window](../image/da1.png)
![Square in the window](../image/da1.png){width=8cm height=3.4cm}

View file

@ -425,7 +425,7 @@ $ build/exp
Then, two windows appear.
![Expression](../image/expression.png)
![Expression](../image/expression.png){width=12cm height=9.1cm}
If you put some text in the field of the entry, then the same text appears in the second GtkLabel.
Because the "label" property of the second GtkLabel instance is bound to the text in the GtkEntryBuffer.

View file

@ -5,7 +5,7 @@
GtkColumnView is like GtkListView, but it has multiple columns.
Each column is GtkColumnViewColumn.
![Column View](../image/column_view.png)
![Column View](../image/column_view.png){width=11.3cm height=9cm}
- GtkColumnView has "model" property.
The property points a GtkSelectionModel object.
@ -17,7 +17,7 @@ This process is the same as the one in GtkListView.
The following diagram shows the image how everything above works.
![ColumnView](../image/column.png)
![ColumnView](../image/column.png){width=12cm height=9cm}
The example in this section is a window that displays information of files in a current directory.
The information is the name, size and last modified datetime of files.
@ -210,7 +210,7 @@ $ _build/column
Then, a window appears.
![Column View](../image/column_view.png)
![Column View](../image/column_view.png){width=11.3cm height=9cm}
If you click the header of a column, then the whole lists are sorted by the column.
If you click the header of another column, then the whole lists are sorted by the newly chosen column.