Bước tới nội dung

Bản mẫu:Markup/doc

Bách khoa toàn thư mở Wikipedia

This template is used to present markup or code side by side with the output it renders.

Tham số bản mẫu

Tham sốMiêu tảKiểuTrạng thái
margin-leftmargin-left

To set a margin on the table's lefthand side.

Mặc định
0
Chuỗi dàitùy chọn
widthwidth

To set the table's overall width.

Mặc định
100%
Chuỗi dàitùy chọn
stylestyle

For CSS styles amending the table's overall appearance.

Chuỗi dàitùy chọn
noheadersnoheaders

Set (as e.g. noheaders=on) to suppress the columns' headings and table's title.

Chuỗi dàitùy chọn
titletitle

Title above table.

Chuỗi dàitùy chọn
colheaderstylecolheaderstyle

For CSS styling to amend the appearance of each column's heading.

Chuỗi dàitùy chọn
col1headerstylecol1headerstyle

For CSS styling to amend the appearance of the first column's heading. Overrides (but does not replace) colheaderstyle.

Chuỗi dàitùy chọn
col1col1

First column (markup/code)'s heading.

Mặc định
"Markup"
Chuỗi dàitùy chọn
col2headerstylecol2headerstyle

For CSS styling to amend the appearance of the second column's heading. Overrides (but does not replace) colheaderstyle.

Chuỗi dàitùy chọn
col2col2

Second column (output)'s heading.

Mặc định
"Renders as"
Chuỗi dàitùy chọn
codestylecodestyle markupstyle

For CSS styles amending the presentation of the first column (markup/code)'s content (e.g. a smaller font-size).

Chuỗi dàitùy chọn
outputstyleoutputstyle

For CSS styles amending the presentation of the second column (output)'s content.

Chuỗi dàitùy chọn
11

row 1, first column (markup/code)'s content.

Chuỗi dàitùy chọn
22

row 1, second column (output)'s content.

Chuỗi dàitùy chọn
33

row 2, first column's content (etc).

Chuỗi dàitùy chọn
44

row 2, second column's content (etc).

Chuỗi dàitùy chọn
3939

First column's content in last possible row.

Chuỗi dàitùy chọn
4040

Second column's content in last possible row.

Chuỗi dàitùy chọn

Cách sử dụng

Each cell in the first ("Markup") column uses <pre> to retain newlines and spaces but styled to allow content to wrap within it. It is usually desirable to escape the content of these cells so that the markup is displayed by wrapping the markup in <nowiki>. It is technically not possible to add this feature to the template.

Each cell in the second ("Renders as") column is usually the unescaped markup copied from the corresponding "Markup" cell before it. 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; see examples below.
  • Header markup such as == will show in the page table of contents; use {{fake heading}}.
  • Some templates will place the page in a maintenance category, which is usually undesired:
  • Some templates may have error checking that places the page in a maintenance category. Suppress the category as possible:

Giới hạn

<nowiki>

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}}:

Renders asExpected rendering
{{[[Bản mẫu:tag|tag]]}}

{{tl|tag}}

Thực thể HTML

HTML entities are parsed in the markup cell:

Nowikied markup shows asExpected markup
 –

&nbsp;&ndash;

To work around this, replace the & with &amp; thus &amp;nbsp; will show as &nbsp;

Danh sách và cú pháp thụt lề

If the first line includes wikimarkup that must start on a new line such as #, * or ; then use <nowiki />:

Không có <nowiki />
Cú phápKết quả
# Item 1# Item 2# Item 3# Item 4
  1. Item 1
  2. Item 2
  3. Item 3
  4. Item 4
<nowiki />
Cú phápKết quả
<nowiki /># Item 1# Item 2# Item 3# Item 4
  1. Item 1
  2. Item 2
  3. Item 3
  4. Item 4

Các ví dụ

Đơn giản

Cú phápKết quả
'''Chữ đậm'''

Chữ đậm

''Chữ nghiêng''

Chữ nghiêng

Viết tắt

Xem Bản mẫu:Mra.

Nhập vào đây:

{{thế:mra|'''Chữ đậm'''|''Chữ nghiêng''}}

Để làm điều này:

{{markup|<nowiki>'''Chữ đậm'''</nowiki>|'''Chữ đậm'''|<nowiki>''Chữ nghiêng''</nowiki>|''Chữ nghiêng''}}

Hiển thị đó như:

Cú phápKết quả
'''Chữ đậm'''

Chữ đậm

''Chữ nghiêng''

Chữ nghiêng

Phức tạp hơn

Note that {{Markup}}'s second argument here uses {{fake heading}} and {{fake citation needed}}.

Cú phápKết quả
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}}== Chú thích =={{tham khảo|group=nb}}== Tham khảo =={{tham khảo}}

The quick brown fox jumps over the lazy dog.[nb 1] The cow jumped over the moon.[Cần chú thích]

Chú thích
  1. A footnote.[1]
Tham khảo
  1. A reference for the footnote.

Nhiều hàng

Cú phápKết quả
The quick brown fox jumps over the lazy dog.

The quick brown fox jumps over the lazy dog.

The quick brown fox jumps over the lazy dog.

The quick brown fox jumps over the lazy dog.

The quick brown fox jumps over the lazy dog.

The quick brown fox jumps over the lazy dog.

The quick brown fox jumps over the lazy dog.

The quick brown fox jumps over the lazy dog.

The quick brown fox jumps over the lazy dog.

The quick brown fox jumps over the lazy dog.

Với tiêu đề

Foxes and dogs
Cú phápKết quả
The quick brown fox jumps over the lazy dog.

The quick brown fox jumps over the lazy dog.

Hiển thị kết quả HTML

When a template is enclosed within {{}}, it shows the rendered HTML:

Cú phápKết quả
{{chú thích sách |last=White |first=T. H. |title=The Book of Merlyn |year=1977}}

White, T. H. (1977). The Book of Merlyn.

{{mã|lang=html|{{chú thích sách |last=White |first=T. H. |title=The Book of Merlyn |year=1977}}}}

<templatestyles src="Module:Citation/CS1/styles.css"></templatestyles><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%3AMarkup%2Fdoc" class="Z3988"></span>

Xem thêm

  • {{Markup2}} for bulleted and indented markup.
  • {{Markupv}} for the vertical presentation (above/below) of markup/code and its output.
  • {{Automarkup}} does not require to write the code samples twice.