1.1 What is ruby?

转载自: http://www.w3.org/TR/2001/REC-ruby-20010531/#what 1.1 What is ruby? Ruby is the term used for a run of text that is associated with another run of text, referred to as the base text. Ruby text is used to provide a short annotation of the associated base text. It is most often used to provide a reading (pronunciation guide). Ruby annotations are used frequently in Japan in many kinds of publications, including books and magazines. Ruby is also used in China, especially in schoolbooks. Ruby text is usually presented alongside the base text, using a smaller typeface. The name "ruby" in fact originated from the name of the 5.5pt font size in British printing, which is about half the 10pt font size commonly used for normal text. Figure 1.1 shows an example, with three ideographs (kanji) as base text, and six hiragana giving the reading (shinkansen - Japanese bullet train). 500)this.width=500'> Figure 1.1: Ruby text giving the reading of each character of the base text. East Asian typography has developed various features that do not appear in western typography. Most of these can be addressed appropriately with style sheet languages such as CSS or XSL. However, additional markup is required to define the association between base text and ruby text. This specification defines such markup, designed to be usable with XHTML, so that ruby text is available on the Web without using special workarounds or graphics. Although this specification gives examples of actual rendering to make it easier for most readers to understand the markup, all such examples are informational only. This document does not specify any mechanisms for presentation or styling; this is part of the respective style sheet languages. Sometimes more than one ruby text is associated with the same base text. A typical example is to indicate both meaning as well as reading for the same base text. In such cases, ruby texts may appear on both sides of the base text. Ruby text before the base text is often used to indicate reading; ruby text after the base text is often used to indicate meaning. Figure 1.2 shows an example of base text with two ruby texts, giving reading using hiragana and Latin letters. 500)this.width=500'> Figure 1.2: Two ruby texts applied to the same base text. In addition, each ruby text may be associated with different, but overlapping, parts of the base text, such as in the following example: Month Day Year 10 31 2002 Expiration Date Figure 1.3: Base text with two ruby texts using different associations In this example, the base text is the date "10 31 2002". One ruby text is the phrase "Expiration Date". This ruby text is associated with the entire base text. The other ruby text has 3 parts: "Month", "Day" and "Year". Each part is associated with a different part of the base text. "Month" is associated with "10", "Day" is associated with "31", and "Year" is associated with "2002". 1.2 Ruby markup overview The markup defined in this specification is designed to cover all the above cases, namely markup for one or two ruby texts associated with the same base text and markup for associations of substrings of the ruby text(s) with components of the base text. There are two variants of ruby markup, called simple ruby markup and complex ruby markup. Simple ruby markup associates a single ruby text with a run of base text. Simple ruby markup can also specify a fallback mechanism to allow display of ruby text by (older) browsers that do not know about ruby markup. Complex ruby markup can associate two ruby texts with one base text, and can define a more fine-grained association between components of the ruby text and the base text. However, complex ruby markup does not provide a fallback mechanism for browsers that do not understand ruby markup. This section gives an overview of the markup for ruby defined in this specification. A full formal definition can be found in Section 2. 1.2.1 Simple ruby markup In the simplest case, ruby markup defines a ruby element which contains one rb element for the base text and one rt element for the ruby text. This ruby element therefore creates an association between the base text and the ruby text, and is sufficient for most cases. Here is an example of simple ruby markup: WWW World Wide Web Figure 1.4: Example of simple ruby markup This may be rendered as follows: 500)this.width=500'> Figure 1.5: Example of rendering for simple ruby markup in Figure 1.4 Note: The name of this enclosing element, "<ruby>", should be interpreted to mean that its contents are associating ruby text with base text. It must not be misunderstood to mean that everything inside, including the base text, is ruby. The name of the enclosing element was chosen to compactly and clearly identify the function of the markup construct; the names for the other elements were chosen to keep the overall length short. 1.2.2 Simple ruby markup with parentheses Some user agents might not understand ruby markup, or may not be able to render ruby text appropriately. In either situation, it is generally preferable to render ruby text, so that information is not lost. A generally acceptable fallback is to place the ruby text immediately after the base text, and to enclose the ruby text in parentheses. The parentheses reduce the potential for confusing the ruby text with other text. (It should be noted that text in parentheses in Japanese typography is never called "ruby".) For compatibility with older user agents that do not understand ruby markup and simply render the content of elements they do not understand, rp elements can be added to simple ruby markup to distinguish ruby text. The element name rp stands for "ruby parenthesis". The rp elements and the parentheses (or other characters) inside them are provided as a fallback mechanism only. User agents that ignore unknown elements, but render their contents, will display the contents of each rp element. Therefore the rp element can be used to denote both the beginning and end of ruby text. User agents that do know about ruby markup will recognize the rp element, and intentionally not display its contents. Instead, they will render the simple ruby markup in a more appropriate way. The following example demonstrates the use of the rp element: WWW (World Wide Web) Figure 1.6: Example of simple ruby markup including rp elements for fallback User agents that either: do not know about ruby markup but render the contents of unknown elements, or cannot render the ruby text alongside the base text, will render the above markup as: WWW (World Wide Web) Figure 1.7: Rendering of simple ruby markup using fallback parentheses User agents that do know about ruby markup, and that have more sophisticated presentation styles for ruby text, will choose to not render the parentheses. For example, the markup of figure 1.6 can be rendered as shown in the next figure. 500)this.width=500'> Figure 1.8: rp element ignored in favor of more sophisticated rendering 1.2.3 Complex ruby markup Complex ruby markup is used to associate more than one ruby text with a base text, or to associate parts of ruby text with parts of base text. Complex ruby markup provides for multiple rb and rt elements. This specification defines container elements that make the association between the individual elements clear. The ruby base container element, rbc, encloses rb elements. There can be one or two ruby text container elements, rtc, that enclose rt elements. This allows association of two ruby text containers with the same base text. With complex ruby markup it is also possible to associate parts of the base text with parts of a ruby text by using a number of rb elements, and a corresponding number of rt elements. In addition, the rt element may use the rbspan attribute to indicate that a single rt element spans (is associated with) multiple rb elements. This is similar to the colspan attribute of the th and td elements in tables ([HTML4], section 11.2.6). Where and how each part of complex ruby markup is rendered is defined as part of the respective style sheet languages; see also section 3 for further information. The following example shows all these features. 10 31 2002 Month Day Year Expiration Date Figure 1.9: Complex ruby markup to associate two ruby texts with different parts of the same base text. In this example, the first ruby text container encloses 3 components ("Month", "Day", "Year"). Each of these components is associated with a corresponding component in the base text ("10", "31", "2002"). The second ruby text container ("Expiration Date") consists of a single ruby text, and is associated with the entire base text ("10 31 2002"). It may be rendered as shown in figure 1.10. Month Day Year 10 31 2002 Expiration Date Figure 1.10: Rendering of the complex ruby markup in figure 1.9 The example shows that the association of ruby text with base text can be more or less granular as needed. For example, the ruby text can be associated with the entire base text in cases where: a more detailed relationship is unknown, or when the reading or annotation only applies to the whole unit and cannot be split into pieces. More fine-grained associations can also be made when the relationships are known. For these situations, an improved rendering can therefore be provided. For example, a person's name can be decomposed into family name and given name, or a kanji compound or phrase can be decomposed into semantic subparts or individual characters. With either fine or course granularity, the spans of the ruby text can be set with the corresponding spacing in the base text, and better readability and a more balanced layout may be achieved. The rp element is not available in the case of complex ruby markup. There are two reasons for this. First, the rp element is only a fallback mechanism, and it was considered that this is much more important for the more frequent simple case. Second, for the more complex cases, it is difficult to come up with a reasonable fallback display, and constructing markup for such cases can be even more difficult if not impossible. 1.2.4 Summary In summary, the ruby element serves as a container for one of the following: a combination of rb, rt and possibly rp elements (simple ruby markup) for: Association of a single ruby text with a single base text Fallback in case the ruby markup is not understood. a combination of a single rbc and one or two rtc container elements (complex ruby markup) for: Associating two ruby texts with the same base text Defining more fine-grained associations between parts of a ruby text and parts of the base text.




发表评论:
昵称:
密码:
主页:
标题:
验证码:  (不区分大小写,请仔细填写,输错需重写评论内容!)

日历 | CALENDAR

«July 2025»
12345
6789101112
13141516171819
20212223242526
2728293031
blog名称:World Wide Web Watch
日志总数:193
评论数量:665
留言数量:75
访问次数:6081599
建立时间:2004年10月30日
站点首页 | 联系我们 | 博客注册 | 博客登陆

Sponsored By W3CHINA
W3CHINA Blog 0.8 Processed in 0.047 second(s), page refreshed 144754099 times.
《全国人大常委会关于维护互联网安全的决定》  《计算机信息网络国际联网安全保护管理办法》
苏ICP备05006046号