Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

[インデックス 13591] ファイルの概要

このコミットは、Go言語の公式ドキュメント内のHTMLファイルに存在するいくつかの構文エラーを修正することを目的としています。具体的には、誤ったHTMLタグの修正、特殊文字のエスケープ処理の適用、および見出しタグのレベルの調整が含まれています。これにより、ドキュメントの表示の一貫性と正確性が向上します。

コミット

commit edc7b4739d750b7954a588a2a6b359db90861da3
Author: Shenghou Ma <minux.ma@gmail.com>
Date:   Tue Aug 7 11:12:54 2012 +0800

    doc: fix some HTML syntax errors
    
    R=adg
    CC=golang-dev
    https://golang.org/cl/6458043

GitHub上でのコミットページへのリンク

https://github.com/golang/go/commit/edc7b4739d750b7954a588a2a6b359db90861da3

元コミット内容

doc: fix some HTML syntax errors

このコミットメッセージは、ドキュメント内のいくつかのHTML構文エラーを修正したことを簡潔に示しています。

変更の背景

HTMLドキュメントにおける構文エラーは、ウェブブラウザでの表示崩れ、アクセシビリティの問題、検索エンジン最適化(SEO)への悪影響、および将来的なメンテナンスの困難さを引き起こす可能性があります。特に、Go言語のような公式ドキュメントでは、正確で標準に準拠したHTMLが求められます。このコミットは、これらの問題を解消し、ドキュメントの品質と信頼性を向上させるために行われました。具体的には、以下の種類の問題が修正されています。

  1. 誤ったタグの使用: <code>タグを意図している箇所でcdeのようなタイプミスがあった場合、ブラウザはそれを認識できず、期待通りの表示(通常は等幅フォントでの表示)が行われません。
  2. 特殊文字のエスケープ不足: HTMLでは、<(小なり記号)や&(アンパサンド)などの一部の文字は特殊な意味を持ちます。これらをそのまま記述すると、ブラウザがタグやエンティティとして解釈してしまい、意図しない表示になったり、構文エラーを引き起こしたりします。これらを正しく表示するためには、それぞれ&lt;&amp;といったHTMLエンティティにエスケープする必要があります。
  3. 見出しタグの不整合: HTMLの見出しタグ(<h1>から<h6>)は、ドキュメントの構造と階層を示すために使用されます。<h3></h4>のように、開始タグと終了タグのレベルが一致しない場合、ブラウザはエラーとして処理し、ドキュメントのアウトラインが正しく構築されなかったり、CSSの適用が意図通りに行われなかったりする可能性があります。

これらの修正は、ドキュメントの正確なレンダリングと、HTML標準への準拠を保証するために不可欠です。

前提知識の解説

HTML (HyperText Markup Language)

HTMLは、ウェブページの構造と内容を定義するための標準マークアップ言語です。要素はタグ(例: <p>, <div>, <a>)で構成され、これらのタグがコンテンツを囲み、その意味や表示方法をブラウザに伝えます。

HTMLタグ

HTMLタグは、通常、開始タグ(例: <p>) と終了タグ(例: </p>) のペアで構成されます。タグ名は大文字と小文字を区別しませんが、小文字で記述することが推奨されています。

  • <code>タグ: プログラムのコード、変数名、ファイル名など、コンピュータコードの一部であることを示すために使用されます。通常、ブラウザでは等幅フォントで表示されます。
  • 見出しタグ (<h1> - <h6>): ドキュメントのセクション見出しを定義します。<h1>が最も重要な見出しで、<h6>が最も重要度の低い見出しです。これらのタグは、ドキュメントの構造をセマンティックに定義し、検索エンジンやスクリーンリーダーに情報を提供します。

HTMLエンティティ

HTMLエンティティは、HTMLで特殊な意味を持つ文字(例: <, >, &, ")や、キーボードから直接入力できない文字(例: 著作権記号 ©)を表現するために使用される特殊な文字シーケンスです。これらはアンパサンド (&) で始まり、セミコロン (;) で終わります。

  • &lt;: 小なり記号 (<) を表します。HTMLタグの開始を示す文字であるため、コンテンツとして表示したい場合はエスケープが必要です。
  • &amp;: アンパサンド (&) を表します。HTMLエンティティの開始を示す文字であるため、コンテンツとして表示したい場合はエスケープが必要です。

HTML構文エラー

HTML構文エラーは、HTMLのルールに違反する記述のことです。これには、タグの閉じ忘れ、誤ったタグ名の使用、属性値の引用符の欠落、特殊文字のエスケープ不足などが含まれます。ブラウザはこれらのエラーをある程度許容して表示しようとしますが、予期せぬ表示崩れや機能不全の原因となることがあります。

技術的詳細

このコミットで行われた修正は、主に以下の3つのカテゴリに分類されます。

  1. 誤ったタグ名の修正:

    • doc/articles/concurrency_patterns.html ファイルにおいて、<cde> というタイプミスを <code> に修正しています。これは、コードスニペットを表示するための正しいHTMLタグです。この修正により、該当箇所のテキストが意図通りに等幅フォントで表示されるようになります。
  2. HTML特殊文字のエスケープ:

    • doc/articles/image_package.html ファイルでは、Go言語のコードスニペット内で使用されている <& 記号が、HTMLエンティティにエスケープされていませんでした。
      • const M = 1<<16 - 1const M = 1&lt;&lt;16 - 1 に修正されました。
      • r.Min.X <= p.X && p.X < r.Max.Xr.Min.X &lt;= p.X &amp;&amp; p.X &lt; r.Max.X に修正されました。
    • doc/articles/json_rpc_tale_of_interfaces.html ファイルでは、URL内の & 記号がエスケープされていませんでした。
      • &r=&amp;r= に修正されました。
    • doc/code.html ファイルでは、Go言語のコードスニペット内で使用されている < 記号がエスケープされていませんでした。
      • for i := 0; i < 1000; i++ {for i := 0; i &lt; 1000; i++ { に修正されました。 これらの修正により、ブラウザがこれらの記号をHTMLタグやエンティティの開始として誤って解釈することを防ぎ、コードスニペットが正しく表示されるようになります。
  3. 見出しタグのレベルの修正:

    • doc/install.html ファイルでは、<h3> で開始された見出しが </h4> で閉じられていました。これはHTMLの構文エラーであり、見出しの階層構造を破壊します。
      • <h4 id="windows_zip">Zip archive</h3><h4 id="windows_zip">Zip archive</h4> に修正されました。
      • <h4 id="windows_msi">MSI installer (experimental)</h3><h4 id="windows_msi">MSI installer (experimental)</h4> に修正されました。 この修正により、見出しの開始タグと終了タグのレベルが一致し、ドキュメントのセマンティックな構造が正しくなります。

これらの変更は、HTMLの基本的な構文規則に準拠するためのものであり、ドキュメントのレンダリングの正確性と堅牢性を高めます。

コアとなるコードの変更箇所

diff --git a/doc/articles/concurrency_patterns.html b/doc/articles/concurrency_patterns.html
index 63c8cd59e8..515d974d2b 100644
--- a/doc/articles/concurrency_patterns.html
+++ b/doc/articles/concurrency_patterns.html
@@ -17,7 +17,7 @@ and launching a goroutine that sleeps before sending on the channel:
 We can then use a <code>select</code> statement to receive from either
 <code>ch</code> or <code>timeout</code>. If nothing arrives on <code>ch</code>
 after one second, the timeout case is selected and the attempt to read from
-<cde>ch</cde> is abandoned.
+<code>ch</code> is abandoned.
 </p>
 
 {{code "/doc/progs/timeout1.go" `/select {/` `/STOP/`}}
diff --git a/doc/articles/image_package.html b/doc/articles/image_package.html
index a9d2f3581d..24601b5749 100644
--- a/doc/articles/image_package.html
+++ b/doc/articles/image_package.html
@@ -45,7 +45,7 @@ classic algebra:
 dstr, dstg, dstb, dsta := dst.RGBA()
 srcr, srcg, srcb, srca := src.RGBA()
 _, _, _, m := mask.RGBA()
-const M = 1<<16 - 1
+const M = 1&lt;&lt;16 - 1
 // The resultant red value is a blend of dstr and srcr, and ranges in [0, M].
 // The calculation for green, blue and alpha is similar.
 dstr = (dstr*(M-m) + srcr*m) / M
@@ -130,7 +130,7 @@ much easier to type.
 A <code>Rectangle</code> is inclusive at the top-left and exclusive at the
 bottom-right. For a <code>Point p</code> and a <code>Rectangle r</code>,
 <code>p.In(r)</code> if and only if
-<code>r.Min.X <= p.X && p.X < r.Max.X</code>, and similarly for <code>Y</code>. This is analagous to how
+<code>r.Min.X &lt;= p.X &amp;&amp; p.X &lt; r.Max.X</code>, and similarly for <code>Y</code>. This is analagous to how
 a slice <code>s[i0:i1]</code> is inclusive at the low end and exclusive at the
 high end. (Unlike arrays and slices, a <code>Rectangle</code> often has a
 non-zero origin.)
@@ -193,8 +193,8 @@ way to iterate over an <code>Image</code> m's pixels looks like:
 
 <pre>
 b := m.Bounds()
-for y := b.Min.Y; y < b.Max.Y; y++ {
-\tfor x := b.Min.X; y < b.Max.X; x++ {
+for y := b.Min.Y; y &lt; b.Max.Y; y++ {
+\tfor x := b.Min.X; y &lt; b.Max.X; x++ {
  	\tdoStuffWith(m.At(x, y))\n \t}\n }\ndiff --git a/doc/articles/json_rpc_tale_of_interfaces.html b/doc/articles/json_rpc_tale_of_interfaces.html
index a545f55f61..0db366f33a 100644
--- a/doc/articles/json_rpc_tale_of_interfaces.html
+++ b/doc/articles/json_rpc_tale_of_interfaces.html
@@ -57,7 +57,7 @@ original functionality. From there it is simple to build a
 After some similar changes to the client side, this was the full extent of the
 work we needed to do on the RPC package. This whole exercise took about 20
 minutes! After tidying up and testing the new code, the
-<a href="http://code.google.com/p/go/source/diff?spec=svn9daf796ebf1cae97b2fcf760a4ab682f1f063f29&r=9daf796ebf1cae97b2fcf760a4ab682f1f063f29&format=side&path=/src/pkg/rpc/server.go">final changeset</a>
+<a href="http://code.google.com/p/go/source/diff?spec=svn9daf796ebf1cae97b2fcf760a4ab682f1f063f29&amp;r=9daf796ebf1cae97b2fcf760a4ab682f1f063f29&amp;format=side&amp;path=/src/pkg/rpc/server.go">final changeset</a>
 was submitted.
 </p>
 
diff --git a/doc/code.html b/doc/code.html
index efbe7eed02..d11685f796 100644
--- a/doc/code.html
+++ b/doc/code.html
@@ -182,7 +182,7 @@ func Sqrt(x float64) float64 {
         // This is a terrible implementation.
         // Real code should import "math" and use math.Sqrt.
         z := 0.0
-        for i := 0; i < 1000; i++ {
+        for i := 0; i &lt; 1000; i++ {
                 z -= (z*z - x) / (2 * x)
         }\n         return z
diff --git a/doc/install.html b/doc/install.html
index ae5bffab18..ec78d2a5a8 100644
--- a/doc/install.html
+++ b/doc/install.html
@@ -41,7 +41,7 @@ proceeding. If your OS or architecture is not on the list, it's possible that
 </tr>
 <tr><td colspan="3"><hr></td></tr>
 <tr><td>FreeBSD 7 or later</td> <td>amd64, 386</td> <td>Debian GNU/kFreeBSD not supported</td></tr>
-<tr><td>Linux 2.6.23 or later with glibc</td> <td>amd64, 386, arm</td> <td>CentOS/RHEL 5.x not supported; no binary distribution for ARM yet</tr>
+<tr><td>Linux 2.6.23 or later with glibc</td> <td>amd64, 386, arm</td> <td>CentOS/RHEL 5.x not supported; no binary distribution for ARM yet</td></tr>
 <tr><td>Mac OS X 10.6/10.7</td> <td>amd64, 386</td> <td>use the gcc<sup>&#8224;</sup> that comes with Xcode</td></tr>
 <tr><td>Windows 2000 or later</td> <td>amd64, 386</td> <td>use mingw gcc<sup>&#8224;</sup>; cygwin or msys is not needed</td></tr>
 </table>
@@ -155,7 +155,7 @@ a zip archive that requires you to set some environment variables and an
 experimental MSI installer that configures your installation automatically.
 </p>
 
-<h4 id="windows_zip">Zip archive</h3>
+<h4 id="windows_zip">Zip archive</h4>
 
 <p>
 Extract the <a href="http://code.google.com/p/go/downloads/list?q=OpSys-Windows+Type%3DArchive">zip file</a>
@@ -171,7 +171,7 @@ the <code>GOROOT</code> environment variable to your chosen path.
 Add the <code>bin</code> subdirectory of your Go root (for example, <code>c:\\Go\\bin</code>) to to your <code>PATH</code> environment variable.
 </p>
 
-<h4 id="windows_msi">MSI installer (experimental)</h3>
+<h4 id="windows_msi">MSI installer (experimental)</h4>
 
 <p>
 Open the <a href="http://code.google.com/p/go/downloads/list?q=OpSys-Windows+Type%3DInstaller">MSI file</a>

コアとなるコードの解説

上記の差分は、Go言語のドキュメントにおけるHTML構文エラーの具体的な修正を示しています。

  1. doc/articles/concurrency_patterns.html:

    • -<cde>ch</cde> is abandoned. から +<code>ch</code> is abandoned. への変更。
    • これは、<code>タグのタイプミスであるcdeを正しいcodeに修正したものです。これにより、chというテキストがコードとして適切にレンダリングされます。
  2. doc/articles/image_package.html:

    • -const M = 1<<16 - 1 から +const M = 1&lt;&lt;16 - 1 への変更。
    • -<code>r.Min.X <= p.X && p.X < r.Max.X</code>, and similarly for <code>Y</code>. This is analagous to how から +<code>r.Min.X &lt;= p.X &amp;&amp; p.X &lt; r.Max.X</code>, and similarly for <code>Y</code>. This is analagous to how への変更。
    • -for y := b.Min.Y; y < b.Max.Y; y++ { から +for y := b.Min.Y; y &lt; b.Max.Y; y++ { への変更。
    • -\tfor x := b.Min.X; y < b.Max.X; x++ { から +\tfor x := b.Min.X; y &lt; b.Max.X; x++ { への変更。
    • これらの変更は、Goのコードスニペット内で使用されている<(小なり記号)と&(アンパサンド)を、それぞれHTMLエンティティの&lt;&amp;にエスケープしたものです。これにより、ブラウザがこれらの記号をHTMLタグの開始やエンティティの開始として誤って解釈することを防ぎ、コードが正しく表示されます。
  3. doc/articles/json_rpc_tale_of_interfaces.html:

    • -final changeset</a> から +final changeset</a> への変更。
    • これは、URL内の&記号をHTMLエンティティの&amp;にエスケープしたものです。これにより、URLが正しく解析され、リンクが機能するようになります。
  4. doc/code.html:

    • -for i := 0; i < 1000; i++ { から +for i := 0; i &lt; 1000; i++ { への変更。
    • これも、Goのコードスニペット内で使用されている<(小なり記号)をHTMLエンティティの&lt;にエスケープしたものです。
  5. doc/install.html:

    • -<tr><td>Linux 2.6.23 or later with glibc</td> <td>amd64, 386, arm</td> <td>CentOS/RHEL 5.x not supported; no binary distribution for ARM yet</tr> から +<tr><td>Linux 2.6.23 or later with glibc</td> <td>amd64, 386, arm</td> <td>CentOS/RHEL 5.x not supported; no binary distribution for ARM yet</td></tr> への変更。
    • これは、<tr>タグの閉じ忘れを修正したものです。これにより、テーブルの行が正しく閉じられ、HTMLの構造が健全になります。
    • -<h4>Zip archive</h3> から +<h4 id="windows_zip">Zip archive</h4> への変更。
    • -<h4>MSI installer (experimental)</h3> から +<h4 id="windows_msi">MSI installer (experimental)</h4> への変更。
    • これらの変更は、<h3>で閉じられていた見出しタグを、開始タグと一致する</h4>に修正したものです。これにより、見出しの階層構造が正しくなり、ドキュメントのセマンティクスが改善されます。

これらの修正は、ドキュメントのHTMLがW3C標準に準拠し、様々なブラウザやデバイスで一貫して正しく表示されることを保証するために重要です。

関連リンク

参考にした情報源リンク