You are not currently logged in. Are you accessing the unsecure (http) portal? Click here to switch to the secure portal. |
Template:Bq/doc
This is a documentation subpage for Template:Bq. It contains usage information, categories, interlanguage links and other content that is not part of the original template page. |
Usage
This template is to help facilitate the indentation of blocks of content (quotations, computer source code, etc.) with the semantically correct <blockquote></blockquote>
element, which can also be further styled and given metadata. This method is often preferred to using wikimarkup's ";" indentation (actually an abuse of <dt></dt>
code), and other means that can cause problems or which are complicated and error-prone, and for accessibility, content/presentation separation, semantic Web, and metadata reasons; [X]HTML's <blockquote></blockquote>
element has semantic meaning, while many tricks for indenting do not, or even have incorrect semantics.
Example:
{{bq|1={{lorem}}}}
which renders as:
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
compare to the longwinded <blockquote>{{lorem}}</blockquote>
markup:
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Parameters
|text=
or|quote=
or|1=
(required) the content of the indented block; it is always safest to specify this parameter explicitly, as it will otherwise break if the content ever contains the "=" character, and can also fail under other technical circumstances|class=
an additional CSS class; it already usestemplatequote
by default|id=
an identifier, which can be used as a link target or for other purposes, e.g. custom user scripts; it must begin with a letter, not a number or symbol, and be unique on a page|style=
inline CSS directives for custom styling, like background color|title=
metadata that indicates a title or label for the element; different browsers handle this differently, most often as a pop-up "tooltip" on mouseover.
Cited quotations
For use with cited quotations, {{bq}} supports the sourcing parameters (and their aliases) of the older and simpler {{quote}}
templates and the frequently abused {{cquote}}
, so {{bq}} can be used as a drop-in replacement for them that provides the above additional features. Conversion from several other templates, including {{quote box}}
and {{quotation}}
, even {{talkquote}}
, is trivially easy. Converting from {{rquote}}
requires deletion of its first parameter, which is always left
or right
and then the rest of its data will just work without modification. Such conversions of course lose features (decoration, etc.) of many of those templates, but sometimes that is precisely what is desired.
|2=
or|sign=
or|cite=
or|author=
or|by=
author/speaker of the quotation; this is free-form text and can including a link to the author's article.|3=
or|source=
or|ts=
source from which the quotation is drawn; this is free-form text and can including links, styling, etc.; if converting from{{quote box}}
, the author would also be included in|source=
, but should really be moved manually to the above parameter.|4=
or|diff=
optionally, you can divide the citation up further, e.g.|2=Lastname, Firstname
|3="Article Title"
|4=Book Title
, but this is not really necessary, and is mainly to make conversion from{{quotation}}
a little easier. Parameter 4 is automatically italicized, since it is only used for larger works like books, albums, magazines, or TV shows. It also maps to|diff=
for conversion of{{talkquote}}
.
Examples:
{{bq |text={{Lorem}} |sign=Anne O. Nymus |source=''<cite>The Unlightable Being of Bareness</cite>'', 1992, p. 37}}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.—Anne O. Nymus, The Unlightable Being of Bareness, 1992, p. 37
{{bq |1={{Lorem}} |2=Anne O. Nymus |3=1992, "Introduction", pp. vii–ix |4=The Unlightable Being of Bareness}}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.—Anne O. Nymus, 1992, "Introduction", pp. vii–ix, The Unlightable Being of Bareness
Working around display problems
- Lists and other complexities
Complex markup may require a simple trick to work around a longstanding MediaWiki bug; this is the inclusion of the code <nowiki />
immediately after the |1=
(or |text=
if the content following the =
begins with a linebreak:
This fails: | {{bq|1= *Foo *Bar *Baz }} |
as: |
| |
---|---|---|---|---|
This works properly: | {{bq|1=<nowiki /> *Foo *Bar *Baz }} |
as: |
|
This tweak unfortunately cannot be put into the template code itself, as the nowiki markup doesn't pass through the transclusion process.
- Multiple paragraphs
Due to the utterly intractable MediaWiki bug reported at Bugzilla: 6200, and still unfixed as of February 2012[update], block quoting on Wikipedia, with or without a template, cannot handle freeform linebreaking for paragraphs and poems and the like, unless formatted one very specific (and annoying) way. It's not a problem of blockquote templates, but all uses of <blockquote>
.
The problem in action: test cases that seem like they should work but fail |
---|
The intuitive choice:
results in the mangled:
Blank lines seem to work at first:
though with quite tall spacing between the content blocks (lines, in our test cases):
Yet this markup fails with wiki ":" indentation: Line 1 Line 2 Line 3 Line 4Just trying to use
results in odd spacing, with the middle blocks too close together:
Meanwhile this version seems okay at first:
but again can't be indented: Line 1 Line 2 Line 3 Line 4 |
As of February 2012[update], the only solution for the problem is to use unbroken markup with <p></p>
or <br/>
elements (or others, like nested blockquotes and lists):
- {{bq|Line 1<br/>Line 2<br/>Line 3<br/>Line 4.}}
which, while hard to read, especially for long content, results in the expected:
Line 1
Line 2
Line 3
Line 4.
And it does work with wikimarkup ":" indentation, unlike the failed test cases above:
Line 1
Line 2
Line 3
Line 4.
Happily, there is an HTML-comment workaround for readability that lets you do whatever you want:
{{Bq|1=<!--
-->Line 1<br/><!--
-->Line 2<br/><!--
-->Line 3<br/><!--
-->Line 4.}}
or even:
{{Bq|1=<!--
-->Line 1<br/><!--
-->Line 2<br/><!--
-->Line 3<br/><!--
-->Line 4.}}
which results in the expected:
Line 1
Line 2
Line 3
Line 4.
They are indentable:
Line 1
Line 2
Line 3
Line 4.
- URLs and other breakage
Make sure that all the parameters are named (e.g. |1=
, etc. or with word names like |source=
). Many URLs, and plenty of other things, contain the "=" character, which due to MediaWiki limitations, will cause the template to malfunction if used in an unnamed parameter.
See also
- Block quotations
- Similar templates
- Template:Epigraph – quote without border, page-wide, normal-sized attribution
- Template:Quote – quote without border, page-wide, smaller-sized attribution
- Template:Quotation – quote with border, page-wide
- Template:Quote box – quote with border, in a reduced floating box
- Template:Cquote – pull-quote between graphic quotation marks, page-wide
- Template:Rquote – pull-quote between graphic quotation marks, in a reduced floating area
- Category:Quotation templates – more templates
- Semantic markup
- {{strong}} – for semantically indicating strong emphasis instead of simple typographical boldfacing
- {{strongbad}} – same as {{strong}} but red like this: Never use {{strongbad}} in articles.
- {{stronggood}} – same as {{strongbad}} but green like this: Only use {{stronggood}} on non-article pages.
- {{em}} – similar template for semantically indicating mild emphasis instead of simple typographical italicization
- {{var}} – same as {{varserif}} use for all variables (e.g. strIllustratePrefix), except for 'I' (upper-case i) and 'l' (lower-case L), for which use {{varserif}}
- {{varserif}} – same as {{var}} but uses serif font (e.g. strIllustratePrefix), especially for distinguishing between 'I' (upper-case i) and 'l' (lower-case L) as variables
- {{wikivar}} – for displaying wikicode variables and magicwords as they would appear in source code, e.g.
{{PAGENAME}}
,{{DEFAULTSORT:Lastname, Firstname}}
- {{para}} – for displaying wiki template parameters (
|title=
) or parameters and values (|year=2008
) - {{tlx}} and related – for displaying entire templates (with or without parameters and values) as code
- {{tag}} – for using HTML elements ("tags") in prose (e.g. "When coding HTML
<img></img>
tags, always include ...") - {{code}} – for computer source code (e.g. "... always include the
alt=
parameter.") (Note: to nest other templates like {{var}} inside, use<code></code>
instead of {{code}}) - {{syntaxhighlight}} or {{sxhl}} – wrapper for
<syntaxhighlight></syntaxhighlight>
, but will wrap overflowing text - {{deprecated code}} or {{dc}} – for deprecated source code in template documentation, articles on HTML specs, etc.
- {{pre}} – for larger blocks of source code and other pre-formatted text
- {{bq}} – for indented blocks of content, such as block quotations, examples, poems, etc.
- {{kbd}} – for indicating user input
- {{key press}} – for indicating the input of specific keystrokes, e.g. CtrlX
- {{PlayStation key press}} – for indicating PS-style gamepad key presses, e.g. ×
- {{samp}} – for example output
- Basic block and inline element wrappers
- {{div}} – the block-level equivalent, it is a wrapper for
<div></div>
- {{span}} – the inline-level equivalent; it is a wrapper for
<span></span>