Template:Code/testcases
| This is the template test cases page for the sandbox of Template:Code. to update the examples. If there are many examples of a complicated template, later ones may break due to limits in MediaWiki; see the HTML comment "NewPP limit report" in the rendered page. You can also use Special:ExpandTemplates to examine the results of template uses. You can test how this page looks in the different skins and parsers with these links: |
Live version
<html> <head> <title>...</title> </head> <body>...</body> </html>
Most HTML elements are enclosed between a start tag and an end tag, such as <p>...</p>. Some are not, such as <br>.
Sandbox version
<html> <head> <title>...</title> </head> <body>...</body> </html>
Most HTML elements are enclosed between a start tag and an end tag, such as <p>...</p>. Some are not, such as <br>.
Testing sandbox version
Font Size
Fontsize in FF:
- Plain
- Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
- {{code}}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
- {{code/sandbox}}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
<code>...</code>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
- syntaxhighlight
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
- font-family:monospace; only
- Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Markup behaviour
| plain | ''ABC'' | <b>bold</b> | <b>bold</b> lang=html | {{mdash}} | {{PAGENAME}} | |
|---|---|---|---|---|---|---|
| {{code}} | plain |
''ABC'' |
<b>bold</b> |
<b>bold</b> |
— |
Code/testcases
|
| {{code/sandbox}} | plain |
''ABC'' |
<b>bold</b> |
<b>bold</b> |
— |
Code/testcases
|
| <syntaxhighlight inline> | plain |
''ABC'' |
<b>bold</b> |
<b>bold</b> |
{{mdash}} |
{{PAGENAME}}
|
| <code><nowiki> | plain |
''ABC'' |
<b>bold</b> |
<b>bold</b> |
{{mdash}} |
{{PAGENAME}}
|
| <code> | plain |
ABC |
bold |
bold |
— |
Code/testcases
|
| – | – lang=something | |
|---|---|---|
| {{code}} | –
|
–
|
| {{code/sandbox}} | –
|
–
|
| <syntaxhighlight inline> | –
|
–
|
| <code><nowiki> | –
|
–
|
| <code> | –
|
–
|
Misc tests
- Sandbox code
- Foo bar
fee fi fo fumbaz quux. - Foo bar
<div id="quux" class="weasel-razor">blah blah blah</div>baz quux. - Measure me: ! !
! !! !
Spaces between proportional and monospaced segments are (depending on browser) precisely or very close to precisely the same as the spaces between characters inside the monospaced segment (which are necessarily larger than those between characters in the proportional segments).
- Old code
- Foo bar
fee fi fo fumbaz quux. - Foo bar
<div id="quux" class="weasel-razor">blah blah blah</div>baz quux. - Measure me: ! !
! !! !
Spaces between proportional and monospaced segments are (depending on browser) farcically smaller than the spaces between characters inside the monospaced segment, making the content weird-looking and hard to parse.
- Comparisons
Blow up your font size to twice normal or so, and get out a ruler.
- Measure me: ! ! ! ! ! !
{{kbd}}(intentionally wider padding to match wider monospacing) - Measure me: ! ! ! ! ! !
{{kbd|spacing=n}} - Measure me: ! ! ! ! ! !
{{samp}} - Measure me: ! !
! !! !{{code/sandbox}} - Measure me: ! !
! !! !{{code}} - Measure me: ! !
! !! !<code>
For cases where the padding left or right is undesirable, use |l=n or |r=n (or any other value, like 'no" or "0", with either parameter:
- Measure me: ! !
! !! !{{code/sandbox|l=n}} - Measure me: ! !
! !! !{{code/sandbox|r=n}} - Measure me: ! !
! !! !{{code/sandbox|l=n|r=n}} - Measure me: ! !
! !! !{{code/sandbox}} - Measure me: ! !
! !! !{{code|l=n}} - Measure me: ! !
! !! !{{code|r=n}} - Measure me: ! !
! !! !{{code|l=n|r=n}} - Measure me: ! !
! !! !{{code}}
lang tests
- Test cases
The declaration {{code |lang=cpp |int foo(const std::string& bar, const std::vector<long double*>& baz);}} is the prototype for a function defined later.If the code contains an [[equals sign]], such as {{code |lang=javascript |code=var img = document.getElementsByTagName("img");}}...The following is an example of a main method in Java: {{code | public static void main(string[] args){ System.out.println("Hello world!"); } | java}}
- {{code}}
- The declaration
int foo(const std::string& bar, const std::vector<long double*>& baz);is the prototype for a function defined later. - If the code contains an equals sign, such as
var img = document.getElementsByTagName("img");... - The following is an example of a main method in Java:
public static void main(string[] args){ System.out.println("Hello world!"); }
- {{code/sandbox}}
- The declaration
int foo(const std::string& bar, const std::vector<long double*>& baz);is the prototype for a function defined later. - If the code contains an equals sign, such as
var img = document.getElementsByTagName("img");... - The following is an example of a main method in Java:
public static void main(string[] args){ System.out.println("Hello world!"); }
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.