Bản mẫu:Markupv
Cách sử dụng
[sửa mã nguồn]This template is used to present markup or code in a vertical format above the rendered output.
Các tham số:
- markup or m: Content of Markup cell
- renders or r: Content of Renders as cell
- title or t: Title of table; defaults to none
- margin: Set table left margin in em
- width: Table width; defaults to 90%
- style: Additional CSS for the table
The Markup cell is pre-formatted with <pre>
to retain newlines and spaces, but styled to allow content to wrap within the cell. It is usually desirable to escape the content of the Markup cell so that the markup is displayed by wrapping the markup in <nowiki>
. It is technically not possible to add this feature to the template.
In the Renders as cell, the content is usually the unescaped markup copied from the Markup cell. There are instances where this may differ:
- If the first line includes wikimarkup that must start on a new line such as #, * or ; then use
<nowiki />
before the first line. - Header markup such as
==
will show in the page table of contents; use{{fake heading}}
. - When using
{{tham khảo}}
with no other parameters, use{{tham khảo|close=1}}
to ensure that the reference list is closed. - Some templates will place the page in a maintenance category, which is usually undesired:
- Instead of
{{citation needed}}
, use{{fake citation needed}}
.
- Instead of
- Some templates may have error checking that places the page in a maintenance category. Suppress the category as possible:
- Chú thích kiểu 1 templates can suppress the maintenance category by setting
|template doc demo=true
.
- Chú thích kiểu 1 templates can suppress the maintenance category by setting
Ví dụ
[sửa mã nguồn]The following meta-example uses {{markupv}} to create an example of using <score>...</score>
:
{{markupv|title=Ví dụ: |markup=<nowiki><score>\relative c' { c( b~ c b c b c b c~ c)}</score></nowiki> |renders=<score>\relative c' { c( b~ c b c b c b c~ c)}</score> }}
It generates:
Cú pháp | <score>\relative c' { c( b~ c b c b c b c~ c)}</score> |
Kết quả |
Giới hạn
[sửa mã nguồn]If you don't wrap the content of the markup cell in <nowiki>
, then any template markup will not be escaped, it will be expanded.
This example shows the markup for {{tl|tag}}:
Cú pháp | {{[[Bản mẫu:tag|tag]]}} |
Kết quả | {{tl|tag}} |
HTML entities are parsed in the markup cell
Cú pháp | – |
Kết quả | – |
To work around this, replace the &
with &
thus &nbsp;
will show as
Các ví dụ
[sửa mã nguồn]Ví dụ đơn giản:
Cú pháp | '''Chữ đậm''' |
Kết quả | Chữ đậm |
Cú pháp | ''Chữ nghiêng'' |
Kết quả | Chữ nghiêng |
Ví dụ phức tạp:
Note that the second argument to {{markupv}}
uses {{fake heading}}
and {{fake citation needed}}
.
Cú pháp | The quick brown fox jumps over the lazy dog.{{#tag:ref|A footnote.<ref>A reference for the footnote.</ref>|group=nb}} The cow jumped over the moon.{{fact}} ==Ghi chú== {{tham khảo|group=nb}} ==Tham khảo== {{tham khảo}} |
Kết quả | The quick brown fox jumps over the lazy dog.[nb 1] The cow jumped over the moon.[Cần chú thích]
|
Có tiêu đề:
Cú pháp | The quick brown fox jumps over the lazy dog. |
Kết quả | The quick brown fox jumps over the lazy dog. |
When a template is enclosed within {{code}}, it shows the rendered HTML:
Cú pháp | {{chú thích sách |last=White |first=T. H. |title=The Book of Merlyn |year=1977}} |
Kết quả | White, T. H. (1977). The Book of Merlyn. |
Cú pháp | {{code|{{chú thích sách |last=White |first=T. H. |title=The Book of Merlyn |year=1977}}}} |
Kết quả | '"`UNIQ--templatestyles-00000021-QINU`"'<cite id="CITEREFWhite1977" class="citation book cs1">White, T. H. (1977). ''The Book of Merlyn''.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=book&rft.btitle=The+Book+of+Merlyn&rft.date=1977&rft.aulast=White&rft.aufirst=T.+H.&rfr_id=info%3Asid%2Fvi.wikipedia.org%3AB%E1%BA%A3n+m%E1%BA%ABu%3AMarkupv" class="Z3988"></span>
|