پرش به محتوا

الگو:لنگر/توضیحات: تفاوت میان نسخه‌ها

از ویکی البرز
صفحه‌ای تازه حاوی «{{زیرصفحه توضیحات}} <!-- لطفاً رده‌ها و پیوندهای میان‌ویکی را در انتهای این صفحه اضافه کنید --> {{لوآ|Module:Anchor}} {{چپ‌چین}} The template <nowiki>{{</nowiki>[[{{ns:Template}}:{{BASEPAGENAME}}|{{lc:{{BASEPAGENAME}}}}]]<nowiki>}}</nowiki> inserts one or more HTML fragment identifiers (anchor names) in a page. Those locations...» ایجاد کرد
 
جز جایگزینی صفحه با '.'
برچسب: جایگزین شد
 
خط ۱: خط ۱:
{{زیرصفحه توضیحات}}
.
<!-- لطفاً رده‌ها و پیوندهای میان‌ویکی را در انتهای این صفحه اضافه کنید -->
{{لوآ|Module:Anchor}}
 
{{چپ‌چین}}
The template <nowiki>{{</nowiki>[[{{ns:Template}}:{{BASEPAGENAME}}|{{lc:{{BASEPAGENAME}}}}]]<nowiki>}}</nowiki> inserts one or more [[:en:Fragment identifier|HTML fragment identifiers]] (anchor names) in a page. Those locations can then be linked to using <code><nowiki>[[#Location|...]]</nowiki></code> syntax. {{#ifeq:{{BASEPAGENAME}}|Visible anchor|&nbsp;Unlike {{پیوند الگو|لنگر}}, the first parameter will be visible text on the page.|}} (Usually the first letter of the ''location'' is capitalised to reflect the common capitalisation used in section headers – see [[ویکی‌پدیا:شیوه‌نامه]].)
{{پایان چپ‌چین}}
 
=== استفاده ===
<nowiki>{{لنگر|فلان}}</nowiki>
 
== نمونه‌ها ==
{{چپ‌چین}}
# <code style="color:darkgreen;"><nowiki>{{</nowiki>{{lc:{{BASEPAGENAME}}}}|Foo<nowiki>}}</nowiki></code> <br> could be linked to with <code><nowiki>[[#Foo|...]]</nowiki></code> from within the same article, <br> or it could be linked to with {{Nowrap|<code><nowiki>[[</nowiki>''<small>Article name</small>''#Foo<nowiki>|...]]</nowiki></code>}} from other articles and from redirects.
# Anchors can be more suitable for inter-article linking than section titles are. For example: <br> {{Nowrap|1=<code style="color:dimgray;"><nowiki>==</nowiki><span>{{Sp}}</span><code style="color:darkgreen;"><nowiki>{{</nowiki>{{lc:{{BASEPAGENAME}}}}<nowiki>|Foo}}</nowiki></code><span>{{Sp}}</span>Section title <nowiki>==</nowiki></code>}} <br> Here, links via {{Nowrap|1=<code><nowiki>[[</nowiki>''Article name''#Foo<nowiki>]]</nowiki></code>}} would remain valid even if the section were renamed. (Note that the anchor is placed ''before'' the section name; otherwise browsers may hide the section title from view.) However, as noted under [[#Limitations|Limitations]] below, it may be preferable to use direct HTML rather than the template within section titles: <br> {{Nowrap|1=<code style="color:dimgray;"><nowiki>==</nowiki><span>{{Sp}}</span><code style="color:darkgreen;"><nowiki><span id="Foo"></span></nowiki></code><span>{{Sp}}</span>Section title <nowiki>==</nowiki></code>}}
# The template can be used to create multiple anchors with a single call. For example, <br> {{Nowrap|1=<code style="color:darkgreen;"><nowiki>{{</nowiki>{{lc:{{BASEPAGENAME}}}}<nowiki>|Foo|Bar|baz}}</nowiki></code>}} <br> will create three anchors that can then be linked to with <code><nowiki>[[#Foo]]</nowiki></code>, <code><nowiki>[[#Bar]]</nowiki></code> and <code><nowiki>[[#baz]]</nowiki></code>.
{{پایان چپ‌چین}}
* برای مثال واقعی بر روی [[ویکی‌پدیا:شیوه‌نامه/پیونددهی#مثال لنگر]] کلیک کنید.
=== محدودیت‌ها ===
{{چپ‌چین}}
{|class="wikitable" style="float:right"
!نویسه
![[:en:Character entity reference|کد]]
!الگو
!مفهوم
|-
|"
|<code>&amp;quot;</code> <br /><code>&amp;#34;</code>
|{{ن-م}}
|(double)&nbsp;[[علامت گفتاورد]]
|-
|#
|<code>&amp;#35;</code>
|{{ن-م}}
|[[Number sign|hash]]
|-
|&#124;
|<code>&amp;#124;</code>
|{{پیوند الگو|!}}
|[[خط عمودی|خط عمودی (pipe)]]
|-
|&#61;
|<code>&amp;#61;</code>
|{{پیوند الگو|{{=}}}}
|[[علامت مساوی|مساوی (equals)]]
|}
* Anchor names that contain any character shown in the table on the right will not work as expected. However, any of these characters can be replaced with the "&amp;#" codes shown for them here. Or, the pipe symbol and equals sign can be worked around with {{پیوند الگو|!}} and {{پیوند الگو|{{=}}}}, respectively. Markup code such as {{برچسب|sup|o}} and {{برچسب|sub|o}} (superscript and subscript) cannot be used. Most other characters, including white space and punctuation, are not a problem.
* Anchor names should be unique on a page, and should not duplicate any heading titles. Duplicate anchors will not work as expected since the <code><nowiki>#location</nowiki></code> links go to the first anchor with that name. Duplicate anchors result in invalid HTML; you can check for duplicate anchors by running the page through the [[:en:W3C Markup Validation Service|W3C Markup Validation Service]].
* If the template is added to a section title then the code will appear in the edit summary window when that section is edited, as in {{Nowrap|1="<code><nowiki>/* {{لنگر|Issues}}Limitations */ New issue</nowiki></code>"}}. Also, when the section is saved, browsers may not return to the section. Consider using <code><nowiki><span id="..."></span></nowiki></code> directly, rather than using the anchor template, when in a section title.
* Anchor links are case sensitive in some browsers, so treat all anchor links as case sensitive.
{{پایان چپ‌چین}}
 
=== استفاده در جداول ===
{{چپ‌چین}}
Anchors may be used within tables, subject to certain restrictions. The {{الگوب|anchor}} template may be used in the caption and cells of a table, but not those portions of a table that are outside the caption and cells. It is used on the table's caption thus:<syntaxhighlight lang="text">|+ {{لنگر|FooX}} A table caption</syntaxhighlight> and the following forms of cell are valid:<syntaxhighlight lang="text">!{{لنگر|Foo1}} A header cell
!style="background:white;" |{{لنگر|Foo2}} A header cell with styling
|{{لنگر|Foo3}} A data cell
|rowspan=2 |{{لنگر|Foo4}} A data cell spanning two rows</syntaxhighlight> You need to ensure that the {{الگوب|anchor}} is not in that portion of the markup intended for the classes, styles etc. Thus, {{الگوب|anchor}} cannot be placed anywhere on lines that begin with <code><nowiki>{|</nowiki></code> (start of table) or <code><nowiki>|-</nowiki></code> (new row), and the following forms of cell are not valid:<syntaxhighlight lang="text">!{{لنگر|Foo1}} |A header cell
!style="background:white;" {{لنگر|Foo2}} |A header cell with styling
|{{لنگر|Foo3}} |A data cell
|rowspan=2 {{لنگر|Foo4}} |A data cell spanning two rows</syntaxhighlight> If it is necessary for an anchor to be in any of these positions, a different technique is used - the <code>id=</code> attribute. This is placed in that portion of the markup where the classes, styles etc. may be used, as follows:<syntaxhighlight lang="text">{| id=FooX class=wikitable
|- id=FooY
!id=Foo1 |A header cell
!style="background:white;" id=Foo2 |A header cell with styling
|id=Foo3 |A data cell
|rowspan=2 id=Foo4 |A data cell spanning two rows</syntaxhighlight> The <code>id=</code> attribute may appear before, between or after any other attributes that may be present, but only one <code>id=</code> attribute may be used in each of these areas.
{{پایان چپ‌چین}}
 
=== داده‌های الگو ===
{{TemplateDataHeader}}
<templatedata>{
"description": "The template {{لنگر}} inserts one or more HTML anchors in a page. Those locations can then be linked to using [[#location|...]] syntax.  The parameters here are for convenience; no parameter name is required in the template itself.",
"params": {
  "1": {
    "label": "First anchor",
    "description": "First anchor; Only the first anchor is required.",
    "type": "string",
    "required": true
  },
  "2": {
    "label": "Second anchor",
    "description": "Second anchor.",
    "type": "string",
    "required": false
  },
  "3": {
    "label": "Third anchor",
    "description": "Third anchor.  For additional anchors, just type in 4 as the parameter name for the next, 5 for the next after that, and so on.",
    "type": "string",
    "required": false
  }
}}</templatedata>
 
== جستارهای وابسته ==
* {{#ifeq:{{BASEPAGENAME}}|Visible anchor|{{پیوند الگو|Anchor}}|{{پیوند الگو|Visible anchor}}}}
* {{پیوند الگو|Anchored list}}
* {{پیوند الگو|Anchor comment}}
* {{پیوند الگو|میانبر}}
* [[راهنما:فهرست/پیوند‌ها]]
* [[ویکی‌پدیا:تغییرمسیر]]
 
<includeonly>
<!-- رده‌ها و میان‌ویکی‌ها را در اینجا اضافه کنید، ممنون -->
[[رده:الگو:مبتنی بر لوآ]]
[[رده:الگو:قالب‌بندی و عملکرد ویکی‌پدیا]]
</includeonly>

نسخهٔ کنونی تا ‏۱۲ مارس ۲۰۲۶، ساعت ۰۰:۰۸

.