ToshioCP / Gtk4-tutorial

GTK 4 tutorial for beginners
https://toshiocp.github.io/Gtk4-tutorial/
548 stars 50 forks source link

rake html command produces different format #41

Closed yihuajack closed 1 year ago

yihuajack commented 1 year ago

When I test my PR #40 I found that if I run rake html, then in every generated HTML file, all the text inside an element are not line-broken like this: Screenshot from 2023-01-19 13-31-44 Are there any extra configurations needed for automatically do line breaks with fixed letters in a line? I didn't find that in Readme_for_developers; lib_mk_html_template.rb and Rakefile not modified

ToshioCP commented 1 year ago

Thank you for posting the issue, Yihua.

I think the line break is done by Pandoc. However, browsers display the paragraph in the same style. That means either output doesn't have problems.

Markdown recognizes a newline as a blank. It is called "softbreak". Because newline is softbreak, pandoc can translate a newline to a blank and vice versa. So, it can put a newline at any blank or no newline. You can control it by --column option. It gives a line length to your pandoc. The default is 72. So, my output lines are broken around 72 characters.

There's no relation between the line breaking and Rakefile.

Is the comment help you? If not, additional question is welcome.

Toshio Sekiya

yihuajack commented 1 year ago

Hi Toshio, thanks for your reply. It seems that the text inside <p></p> <li></li> tags of HTML pages does not have a fixed column, some are 60+, and some are 70+, rather than 72. I tried to modify Line 160 and add the columns parameter --columns=72 to the pandoc command, but nothing changed. I learned that by default the value of this parameter is 72 indeed. It is weird that no matter I add this argument or not, the behavior is like the argument is set to none. The generated GFMs are the same as the main branch's; only generated HTML files are different from the main branch's. Though the line breaks in HTML do not produce line breaks in the browser, if contributors and the maintainer could not produce the same format, many meaningless changes may be introduced every commit. Rakefile shows that the GFMs and HTML files are generated at the same time, so why this happens?

ToshioCP commented 1 year ago

My pandoc version is: pandoc 2.17.1.1 -- Ubuntu 22.10 (kinetic) package

It is obvious that the line break is done by pandoc. (Rakefile doesn't use pandoc when it generates GFM.)

I mistook the option name, --columns (s is added) is correct. I tested this option as follows:

First, create a file "test.md". test.md: abc abc ... ... ... (repeat the same line 10 times)

Then,

$ pandoc --columns=10 test.md -o test.html
$ cat test.html
<p>abc abc
abc abc
abc abc
abc abc
abc
abc</p>
$ pandoc --columns=20 test.md -o test.html
$ cat test.html
<p>abc abc abc abc
abc abc abc abc abc
abc</p>
$

HTML files depend on pandoc anyway. So, HTML files can be different in the different environment. If we wanted to avoid this, pandoc could not be used. But, in my opinion, it makes too much work for a developer and not a good choice.

The different HTML generation is not a serious problem. So, I will keep it (Rakefile) as it is now. If you have better idea, please let me know.

yihuajack commented 1 year ago

Thank you! After much troubleshooting, I found that my pandoc on my Ubuntu is too old - it's astonishing that for the latest LTS version Ubuntu 22.04, apt only provides 2.9.2, which is just too old - for this version, the --columns parameter does not take effects (but without any error messages). By testing, my pandoc on Windows is version 2.17.1.1, which can properly do line breaks. Now I use the GitHub released Debian package .deb to install the latest version pandoc 3.0.1, and everything works fine. In a nutshell, just use a new version of pandoc 😄 This issue could be a reminder for other contributors