Summary: Markup for Blockquote, Cite and Quote HTML tags
Version: 2017-06-16
Prerequisites: PmWiki 2.2.56 (compatible with PHP 5.5)
Status: new
Maintainer: HansB
Categories: Markup PHP55 PHP72
Users: (view? / edit)

Questions answered by this recipe

How can I add HTML blockquote, cite or quote tags?


Markup for Blockquote, Cite and Quote HTML tags.

This recipe adds the following markup:

""quoted text""
HTML <q> tag - inline quotation. Modern browsers surround quote with opening and closing double quotation marks.
["block of quoted text"]
HTML <blockquote> tag - extended quotation, can go over several lines. Use cite markup within the blockquote markup to display quote source (even URL link).
> email type quoted text
HTML <blockquote class"email"> tag - extended quotation, can go over several lines. Mainly for copying and pasting email quotes (lines starting with > (right arrow and space).
{"cite reference"}
HTML <cite> tag - source or author cited (quoted).


Add all or some of the following markup definitions to config.php:

## ""quote""

## ["blockquote"]

## > blockquote (email type)
Markup('>','>> ','/^&gt;$/',"<:block,1><blockquote class=\"email qlv0\"></blockquote>");
Markup('> ','block','/^((&gt;)+) (.*)$/',"EmailBlockquote");
function EmailBlockquote ($m) {
	$cnt = strlen($m[1])/4; if ($cnt>3) $cnt = 3;
	return "<:block,1><blockquote class=\"email qlv".$cnt."\">".$m[3]."</blockquote>";

## {"cite"}
Markup("^{\"","<{\"","/^\{\"(.*?)\"\}/",'<cite class="citeblock">$1</cite>');
Note: A HTML cite tag with class="citeblock" will be produced if cite markup appears at the beginning of a line.

The following are alternative markup definitions for blockquote and quote.
With these one can add text for a (hidden) cite HTML attribute, by placing the text after the opening markup, followed by a pipe (vertical line) character:

## ""cite source| quoted text"", ""quoted text""
Markup("\"\"","inline","/\"\"(?>([^|\\]]*)\\|\\s*)?(\\S.*?\\S)\"\"/",	"QuoteMarkup");
function QuoteMarkup($m) {
	return ($m[1]) ? '<q cite="'.$m[1].'">'.$m[2].'</q>' : '<q>'.$m[2].'</q>';

## ["cite source| blockquote content"], ["blockquote content"]
Markup("bq",">[=","/(\n[^\\S\n]*)?\\[([\"])(?>([^|\\]]*)\\|\\s*)?(.*?)\\2\\]/s", "BlockquoteMarkup");
function BlockquoteMarkup($m) {
	return ($m[3]) ? $m[1].'<blockquote cite="'.$m[3].'">'.$m[4].'</blockquote>' 
						: $m[1].'<blockquote>'.$m[4].'</blockquote>';



""quoted text"" produces an inline quote, with opening and closing double quote marks added by the browser. The quoted text is wrapped in HTML <q> tags. This is similar than surrounding text with two single quotes left and right, to mark it as emphasised, wrapped in HTML <em> tags.

The alternative markup allows for inclusion of a cite attribute. Use like ""cite source| quoted text"".

Normal use of single double quote marks will be as before, like "this is quoted text but not in HTML <q> tags".

If you want to display code, make sure to escape your code block using square brackets and @ characters: [@escaped code@]


["block of quoted text"] produces a HTML block quote. The alternative markup allows for inclusion of a cite attribute. Use like ["cite source| block of quoted text"].

The quoted text can go over several lines, including empty lines (paragraph breaks). Inline markup is allowed too.

To display the origin of the quoted text (not just have the source as a hidden HTML attribute called cite), one could insert cite markup into the block text, for instance at the foot.

["cite source|
block quote text
over several lines perhaps.
{"displayed cite source"}

Blockquote (email type)

The blockquote (email type) markup allows pasting of email text quotes, which will be displayed as blockquotes. Lines starting with a > (greater than) character followed by a space are converted into blockquotes. For example:

> HTML offers the use of <q>quoted text</q>
> which browsers display as text surrounded by a left and a right double
> quote.

The markup definitions for this are not ideal as yet. Several lines of email quoted text will be rendered as several blockquotes, although they can be displayed without empty lines in between, via CSS rules using the class (see CSS example below). Nesting levels can be displayed using qlv2, qlv3 etc. classes. Nesting levels up to 3 deep will be distinguishably displayed using the CSS example below (by different left border lines, and indenting of text).


{"cite reference"} produces a HTML cite tag. This is an inline markup.

CSS Styling

Add CSS rules to pub/css/local.css to style the added HTML tags as suited.

An example of CSS rules for a blockquote with modern styling of a line to the left:

blockquote cite {
	margin:0 2em; 
blockquote cite:before { content:"\2014 \A0"; }
blockquote {
	position: relative;
	border-left: 4px solid #ccc;
	font-style: italic;
	margin: 0 0 0 1em;
	padding-left: 0.7em;
} {
	min-height: .6em;
	margin: 0 0 0 1em;
	padding-left: 0.7em;
	border-left: 4px solid #ccc; 
} { border-left:12px double #ccc; padding-left: 1.5em; } { border-left:12px double #ccc; padding-left: 2.0em; margin:0 0 0 1.2em; } 


Change log / Release notes

  • 2016-09-24: initial publication.

If the recipe has multiple releases, then release notes can be placed here. Note that it's often easier for people to work with "release dates" instead of "version numbers".

See also

  • PITS.01396 - request to add such or similar markup to PmWiki core.
  • CurlyQuotes - Display Curly Double/Single Quotes and M/N Dashes
  • MarkupExtensions - Adds a range of character, start of line, and link markup extensions



See discussion at Blockquote-Cite-Quote-Talk?

User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.