模板:Hyphenated word end

(重定向自Template:Hwe
文档图示 模板文档[查看] [编辑] [历史] [清除缓存]

This document covers both the {{hyphenated word start}} and {{hyphenated word end}} templates, which must be used together as a pair. The abbreviated forms {{hws}} and {{hwe}} can be used instead. Together they allow the hyphenated word to be displayed in fragmented form in the Page: environment, while the whole word is displayed when the pages are transcluded. In addition, in the Page: environment, the whole word is displayed in the formatted version of the page when the pointer hovers over the word fragment.

The {{hws}} template appears on the individual page, but its contents are not transcluded into the book when pages are assembled; that is done by {{hwe}}. Therefore, italics must be placed within the template to prevent unwanted bold formatting (see below).

There are only a few cases where this template is still the best option. These include if Labelled Section Transclusion stops automatic hyphen joining from working, if an image page appears before a hyphenated word is ended, and for footnotes.

For more specialized usage—if the hyphenated word is part of an HTML link, for instance—see {{linkable phrase start}} and {{linkable phrase end}}.

The {{hyphenated word start}} template is used for the beginning of a word that is hyphenated and split between two pages; {{hyphenated word end}} is used for the end of the word. They must be used together: at the bottom of the first page, and at the top of the following page, respectively.

Regular version (using unnamed parameters, 1 and 2)

编辑

The {{hyphenated word start}} template displays param 1 (1st word-fragment) followed by a hyphen (-) in the "Page" namespace, and nothing in the "main" namespace. An optional parameter can be used to change this hyphen to something else, or suppress it entirely.

The {{hyphenated word end}} template displays param 1 (2nd word-fragment) in the "Page" namespace, and param 2 in the "main" namespace.

In both cases, Param 2 (the full-word) is used as the title-attribute for the text; i.e. a tooltip appears, showing the complete word, when you mouseover the word fragments in the "Page" namespace.

Alternate version (using named parameters, "s" and "e")

编辑

The {{hyphenated word start}} template displays param "s" (1st or "start" word-fragment) followed by a hyphen (-) in the "Page" namespace, and nothing in the "main" namespace. An optional parameter can be used to change this hyphen to something else, or suppress it entirely.

The {{hyphenated word end}} template displays param "e" (2nd or "end" word-fragment) in the "Page" namespace, and a concatenation of param "s" and param "e" in the "main" namespace.

In both cases, the full-word (concatenation of params "s" and "e") is used as the title-attribute for the text; i.e. a tooltip appears, showing the complete word, when you mouseover the word fragments in the "Page" namespace.

Examples

编辑
Regular version (copy and paste text below)
{{hyphenated word start | | }}
{{hws | | }}
{{hyphenated word end | | }}
{{hwe | | }}
Alternate version (copy and paste text below)
{{hyphenated word start |s= |e= }}
{{hws |s= |e= }}
{{hyphenated word end |s= |e= }}
{{hwe |s= |e= }}
Page namespace Transcluded
Example 1 (start)

{{hws |antici|anticipation}}

antici-

Example 1 (end)

{{hwe |pation|anticipation}}

pation

anticipation[2]

Example 1a (start)

{{hws |s= antici |e= pation }}

antici-

Example 1a (end)

{{hwe |s= antici |e= pation }}

pation

anticipation[2]

Example 2 (start)

{{hws |mother|mother-in-law}}

mother-

Example 2 (end)

{{hwe |in-law|mother-in-law}}

in-law

mother-in-law

Example 2a (start)

{{hws |s=mother- |hyph= |e=in-law }}

mother-

Example 2a (end)

{{hwe |s=mother- |hyph= |e=in-law }}

in-law

mother-in-law

Example 3 (start)

{{hws |'''antici| hyph=-''' |'''anticipation'''}}

antici-

Example 3 (end)

{{hwe |'''pation'''|'''anticipation'''}}

pation

anticipation

Example 4 (start)

{{hws |punc|punctuation}}

punc-

Example 4 (end)

{{hwe |tuation|punctuation}}!

tuation!

punctuation![2]

Note: in Example 1, you cannot use any blank spaces around the input data ("antici" and "anticipation", or "pation" and "anticipation"). This is due to the Mediawiki implementation of templates: leading and trailing blank spaces are not stripped when using unnamed (numbered) parameters.

Example 1a reproduces Example 1, using the alternate version with named parameters "s" and "e". You can leave blank spaces around the input data ("antici" and "pation") for readability. This is because in the Mediawiki implementation of templates, leading and trailing blanks are stripped when using named parameters.

This alternate version is more compact but less flexible (see Example 2).

Example 2 is a case where the hyphen must not be dropped when the two halves of a hyphenated word are joined together. This is easily handled with the regular version; however, using the alternate version with s and e parameters in the obvious way would give "motherin-law". A workaround, shown in Example 2a, is to hardcode the hyphen into the "s" parameter and use the "hyph" parameter to set the normally-occurring hyphen to blank.

However, there are more general situations where the unsplit word is not merely a simple unmodified fusion of the split halves: cases involving ligatures or variant letterforms in non-English languages, where letters may change their form depending on the surrounding letters; or, German-language hyphenation rules prior to the 1996 orthography reform (bäcker hyphenated to bäk-ker). These can only be handled by the regular version, not the alternate version.

In Example 3 the word is in boldface, and we want the hyphen to be in boldface too. The hyph parameter can be used to accomplish this (the visual difference between a regular hyphen and a boldface hyphen is admittedly barely perceptible).

"hyph" parameter

编辑

The hyph parameter is usually omitted, which results in an ordinary ASCII hyphen (U+002D) being added at the end of the first part of a split word.

  • If specified, then the given character (or string of characters) is displayed instead of a hyphen, which could be useful for some situations or for non-English languages: eg, Unicode hyphen (U+2010), Armenian hyphen (U+058A), etc.
  • If specified and left blank, then no hyphen at all is displayed. Note: specifying this parameter but leaving it blank is not the same as omitting it.

"Namespace" parameter

编辑

This parameter is only used for special purposes: by setting |namespace=Page you can force the templates to act as though they have been invoked within the "Page" namespace. This can be useful for testing; it is also used within this documentation page to create the examples in the table above.

"title" parameter

编辑

This parameter is normally omitted but may be used to override the tool tip pop up generated in Page: space when the default behaviour becomes problematic (for example any hyphenation component involving additional <span>s can generate invalid HTML.)

A real world example can be found with the word "approach-ing" at Page namespace Page:Wind in the Willows (1913).djvu/306 and Page:Wind in the Willows (1913).djvu/307; observe also the results in the main namespace at The Wind in the Willows (1913)/Chapter 10.

Invalid invocations are placed into Category:Invalid template invocation.

(There have been problems in the past with spurious blank lines added to main namespace versions with the use of this template. Check the template code history/discussion for the latest scoop.)

Formatting

编辑

There are occasions where formatting is required to the hyphenated word, eg. italics. Due to the means of wiki-coding, it is recommended that formatting be done inside {{hyphenated word start}} and outside of {{hyphenated word end}}, for example,

  • {{hyphenated word start|''format''|formatting}}
  • ''{{hyphenated word end|ing|formatting}}'', alternatively {{hyphenated word end|''ing''|''formatting''}}

TemplateData

编辑

Used to format a hyphenated word or phrase that is split over a page break (in the Page namespace).

模板参数[编辑模板数据]

此模板首选参数不换行的行内格式。

参数描述类型状态
Start1 s

The hyphenated half of the word or phrase (without the hyphen).

示例值
antici
字符串必需
Full word2 e

The full word or phrase (without the hyphen)

示例值
anticipation
字符串必需
Hyphenhyph

The hyph parameter is usually omitted, which results in an ordinary ASCII hyphen (U+002D) being added at the end of the first part of a split word.

  • If specified, then the given character (or string of characters) is displayed instead of a hyphen, which could be useful for some situations or for non-English languages: eg, Unicode hyphen (U+2010), Armenian hyphen (U+058A), etc.
  • If specified and left blank, then no hyphen at all is displayed. Note: specifying this parameter but leaving it blank is not the same as omitting it.

    默认值
    -
字符串推荐
Titletitle

This parameter is normally omitted but may be used to override the tool tip pop up generated in Page: space when the default behaviour becomes problematic (for example any hyphenation component involving additional <span>s can generate invalid HTML.)

未知可选
Namespacenamespace

This parameter is only used for special purposes: by setting it you can force the templates to act as though they have been invoked within the 'Page' namespace. This can be useful for testing; it is also used within this documentation page to create the examples in the table above.

字符串可选

See also

编辑

Footnotes

编辑
  1. See: Wikisource:Scriptorium/Archives/2018-09#hyphenated_words.
  2. ^ 2.0 2.1 2.2 For this case, use of these templates is not necessary if there are no footnotes since the transclusion software connects the hyphenated word automatically.