Oi Spudseses,
I remember waffling about simplifying quote markup a while back, but can't find where it was. Anyway, this was what I had in mind. It uses the same basic markup as SMF 2.1, which I think is the most sensible way of doing it. I've bunged all the sources stuff into one file, with the CSS done as comments.
<?php
// Current markup (from GitHub).
array(
self::ATTR_TAG => 'quote',
self::ATTR_TYPE => self::TYPE_PARSED_CONTENT,
self::ATTR_BEFORE => '<div class="quoteheader">' . $txt['quote'] . '</div><blockquote>',
self::ATTR_AFTER => '</blockquote>',
self::ATTR_BLOCK_LEVEL => true,
self::ATTR_AUTOLINK => true,
self::ATTR_LENGTH => 5,
),
array(
self::ATTR_TAG => 'quote',
self::ATTR_TYPE => self::TYPE_PARSED_CONTENT,
self::ATTR_PARAM => array(
'author' => array(
self::PARAM_ATTR_MATCH => '([^<>]{1,192}?)',
self::PARAM_ATTR_QUOTED => self::OPTIONAL,
),
),
self::ATTR_BEFORE => '<div class="quoteheader">' . $txt['quote_from'] . ': {author}</div><blockquote>',
self::ATTR_AFTER => '</blockquote>',
self::ATTR_BLOCK_LEVEL => true,
self::ATTR_AUTOLINK => true,
self::ATTR_LENGTH => 5,
),
array(
self::ATTR_TAG => 'quote',
self::ATTR_TYPE => self::TYPE_PARSED_EQUALS,
self::ATTR_BEFORE => '<div class="quoteheader">' . $txt['quote_from'] . ': $1</div><blockquote>',
self::ATTR_AFTER => '</blockquote>',
self::ATTR_QUOTED => self::OPTIONAL,
self::ATTR_PARSED_TAGS_ALLOWED => array(
'url',
'iurl',
),
self::ATTR_BLOCK_LEVEL => true,
self::ATTR_AUTOLINK => true,
self::ATTR_LENGTH => 5,
),
array(
self::ATTR_TAG => 'quote',
self::ATTR_TYPE => self::TYPE_PARSED_CONTENT,
self::ATTR_PARAM => array(
'author' => array(
self::PARAM_ATTR_MATCH => '([^<>]{1,192}?)',
),
'link' => array(
self::PARAM_ATTR_MATCH => '(?:board=\d+;)?((?:topic|threadid)=[\dmsg#\./]{1,40}(?:;start=[\dmsg#\./]{1,40})?|msg=\d{1,40}|action=profile;u=\d+)',
),
'date' => array(
self::PARAM_ATTR_MATCH => '(\d+)',
self::PARAM_ATTR_VALIDATE => 'htmlTime',
),
),
self::ATTR_BEFORE => '<div class="quoteheader"><a href="' . $scripturl . '?{link}">' . $txt['quote_from'] . ': {author} ' . ($modSettings['todayMod'] == 3 ? ' - ' : $txt['search_on']) . ' {date}</a></div><blockquote>',
self::ATTR_AFTER => '</blockquote>',
self::ATTR_BLOCK_LEVEL => true,
self::ATTR_AUTOLINK => true,
self::ATTR_LENGTH => 5,
),
array(
self::ATTR_TAG => 'quote',
self::ATTR_TYPE => self::TYPE_PARSED_CONTENT,
self::ATTR_PARAM => array(
'author' => array(
self::PARAM_ATTR_MATCH => '([^<>]{1,192}?)',
),
),
self::ATTR_BEFORE => '<div class="quoteheader">' . $txt['quote_from'] . ': {author}</div><blockquote>',
self::ATTR_AFTER => '</blockquote>',
self::ATTR_BLOCK_LEVEL => true,
self::ATTR_AUTOLINK => true,
self::ATTR_LENGTH => 5,
),
// Proposed markup (simpler, easier to deal with).
array(
self::ATTR_TAG => 'quote',
self::ATTR_TYPE => self::TYPE_PARSED_CONTENT,
self::ATTR_BEFORE => '<blockquote><cite>' . $txt['quote'] . '</cite>',
self::ATTR_AFTER => '</blockquote>',
self::ATTR_BLOCK_LEVEL => true,
self::ATTR_AUTOLINK => true,
self::ATTR_LENGTH => 5,
),
array(
self::ATTR_TAG => 'quote',
self::ATTR_TYPE => self::TYPE_PARSED_CONTENT,
self::ATTR_PARAM => array(
'author' => array(
self::PARAM_ATTR_MATCH => '([^<>]{1,192}?)',
self::PARAM_ATTR_QUOTED => self::OPTIONAL,
),
),
self::ATTR_BEFORE => '<blockquote><cite>' . $txt['quote_from'] . ': {author}</cite>',
self::ATTR_AFTER => '</blockquote>',
self::ATTR_BLOCK_LEVEL => true,
self::ATTR_AUTOLINK => true,
self::ATTR_LENGTH => 5,
),
array(
self::ATTR_TAG => 'quote',
self::ATTR_TYPE => self::TYPE_PARSED_EQUALS,
self::ATTR_BEFORE => '<blockquote><cite>' . $txt['quote_from'] . ': $1</cite>',
self::ATTR_AFTER => '</blockquote>',
self::ATTR_QUOTED => self::OPTIONAL,
self::ATTR_PARSED_TAGS_ALLOWED => array(
'url',
'iurl',
),
self::ATTR_BLOCK_LEVEL => true,
self::ATTR_AUTOLINK => true,
self::ATTR_LENGTH => 5,
),
array(
self::ATTR_TAG => 'quote',
self::ATTR_TYPE => self::TYPE_PARSED_CONTENT,
self::ATTR_PARAM => array(
'author' => array(
self::PARAM_ATTR_MATCH => '([^<>]{1,192}?)',
),
'link' => array(
self::PARAM_ATTR_MATCH => '(?:board=\d+;)?((?:topic|threadid)=[\dmsg#\./]{1,40}(?:;start=[\dmsg#\./]{1,40})?|msg=\d{1,40}|action=profile;u=\d+)',
),
'date' => array(
self::PARAM_ATTR_MATCH => '(\d+)',
self::PARAM_ATTR_VALIDATE => 'htmlTime',
),
),
self::ATTR_BEFORE => '<blockquote><cite><a href="' . $scripturl . '?{link}">' . $txt['quote_from'] . ': {author} ' . ($modSettings['todayMod'] == 3 ? ' - ' : $txt['search_on']) . ' {date}</a></cite>',
self::ATTR_AFTER => '</blockquote>',
self::ATTR_BLOCK_LEVEL => true,
self::ATTR_AUTOLINK => true,
self::ATTR_LENGTH => 5,
),
array(
self::ATTR_TAG => 'quote',
self::ATTR_TYPE => self::TYPE_PARSED_CONTENT,
self::ATTR_PARAM => array(
'author' => array(
self::PARAM_ATTR_MATCH => '([^<>]{1,192}?)',
),
),
self::ATTR_BEFORE => '<blockquote><cite>' . $txt['quote_from'] . ': {author}</cite>',
self::ATTR_AFTER => '</blockquote>',
self::ATTR_BLOCK_LEVEL => true,
self::ATTR_AUTOLINK => true,
self::ATTR_LENGTH => 5,
),
/*
CSS for the proposed new markup would essentially be:
/* ---------------------------- */
/* themes/default/css/index.css */
/* ---------------------------- */
/* The "Quote:" and "Code:" header parts... *//*
.codeheader, blockquote > cite {
font-size: var(--font13);
font-weight: 600;
padding: .2em .4em;
border-bottom: 1px solid;
}
.codeheader {
margin-top: .4em;
border-top: 3px solid;
border-bottom: none;
}
/* [Select] link to copy code. *//*
.codeoperation {
font-weight: normal;
}
/* A quote, perhaps from another post. *//*
blockquote,
/* A code block - maybe PHP ;) - shared styles. *//*
.bbc_code {
font-size: var(--font13);
overflow: auto;
margin: 0 0 1em 0;
padding: .4em .67em;
border: 1px solid;
border-top: none;
}
blockquote {
margin: .4em 0 1em 0;
border: 1px solid;
}
/* ---------------------------- */
/* themes/default/css/light.css */
/* ---------------------------- */
/* The "Quote:" and "Code:" header parts... *//*
.codeheader, blockquote > cite {
color: var(--body_text);
border-color: var(--primary_border);
background: var(--primary_white);
}
*/
// Fancy stuffz from BBCParser.php... (Ant liketh not teh fancy stuffz. :P )
protected function alternateQuoteStyle(array &$tag)
{
// Start with standard
$quote_alt = false;
$first_quote = 0;
foreach ($this->open_tags as $open_quote)
{
if (isset($open_quote[Codes::ATTR_TAG]) && $open_quote[Codes::ATTR_TAG] === 'quote')
{
$quote_alt = !$quote_alt;
$first_quote++;
}
}
if ($first_quote === 0)
{
// First quote (of nested or single) receives a wrapper so its markup will be:
// <div class="quote-read-more"> .. relative
// <input type="checkbox" class="quote-show-more">.. absolute over the blockquote
// <blockquote> .. same as always ... with a max height that is removed on input click
// </div>
$tag[Codes::ATTR_BEFORE] = str_replace('<blockquote>', '<div class="quote-read-more"><input type="checkbox" class="quote-show-more"><blockquote>', $tag[Codes::ATTR_BEFORE]);
$tag[Codes::ATTR_AFTER] = str_replace('</blockquote>', '</blockquote></div>', $tag[Codes::ATTR_AFTER]);
}
else
{
// Nested quotes, located inside the above parent quote
// @NOTE: I might be missing something, but I can't see why you would need anything extra here.
// With the proposed change in quote markup, a simple max-height and hidden overflow on the first quote should deal with all child elements.
}
}
?>