public function TypogrifyFilter::tips in Typogrify 8
Generates a filter's tip.
A filter's tips should be informative and to the point. Short tips are preferably one-liners.
@todo Split into getSummaryItem() and buildGuidelines().
Parameters
bool $long: Whether this callback should return a short tip to display in a form (FALSE), or whether a more elaborate filter tips should be returned for template_preprocess_filter_tips() (TRUE).
Return value
string|null Translated text to display as a tip, or NULL if this filter has no tip.
Overrides FilterBase::tips
File
- src/
Plugin/ Filter/ TypogrifyFilter.php, line 428
Class
- TypogrifyFilter
- Provides a filter to restrict images to site.
Namespace
Drupal\typogrify\Plugin\FilterCode
public function tips($long = FALSE) {
$settings = $this->settings;
static::settingsUnserialize($settings);
if ($long) {
$output = $this
->t('Typogrify.module brings the typographic refinements of Typogrify to Drupal.');
$output .= '<ul>';
if ($settings['wrap_ampersand']) {
$output .= '<li>' . $this
->t('Wraps ampersands (the “&” character) with <code>@wrapper-code</code>.', [
'@wrapper-code' => '<span class="amp">&</span>',
]) . '</li>';
}
if ($settings['widont_enabled']) {
$output .= '<li>' . $this
->t("Prevents single words from wrapping onto their own line using Shaun Inman's Widont technique.") . '</li>';
}
if ($settings['wrap_initial_quotes']) {
$output .= '<li>' . $this
->t("Converts straight quotation marks to typographer's quotation marks, using SmartyPants.");
$output .= '</li><li>' . $this
->t('Wraps initial quotation marks with <code>@wrapper-code-quote</code> or <code>@wrapper-code-dquote</code>.', [
'@wrapper-code-quote' => '<span class="quo"></span>;',
'@wrapper-code-dquote' => '<span class="dquo"></span>;',
]) . '</li>';
}
$output .= $this
->t('<li>Converts multiple hyphens to en dashes and em dashes (according to your preferences), using SmartyPants.</li>');
if ($settings['hyphenate_shy']) {
$output .= '<li>' . $this
->t('Words may be broken at the hyphenation points marked by “=”.') . '</li>';
}
if ($settings['wrap_abbr']) {
$output .= '<li>' . $this
->t('Wraps abbreviations as “e.g.” to <code>@wrapper-code</code> and adds a thin space (1/6 em) after the dots.</li>', [
'@wrapper-code' => '<span class="abbr">e.g.</span>',
]) . '</li>';
}
if ($settings['wrap_numbers']) {
$output .= '<li>' . $this
->t('Wraps large numbers > 1 000 with <code>@wrapper-code</code> and inserts thin space for digit grouping.', [
'@wrapper-code' => '<span class="number">…</span>',
]) . '</li>';
}
if ($settings['wrap_caps']) {
$output .= '<li>' . $this
->t('Wraps multiple capital letters with <code>@wrapper-code</code>.', [
'@wrapper-code' => '<span class="caps">CAPS</span>',
]) . '</li>';
}
$output .= '<li>' . $this
->t('Adds a css style sheet that uses the <span> tags to substitute a showy ampersand in headlines, switch caps to small caps, and hang initial quotation marks.') . '</li>';
// Build a list of quotation marks to convert.
foreach (UnicodeConversion::map('quotes') as $ascii => $unicode) {
if (!empty($settings['quotes'][$ascii])) {
$ascii_to_unicode = $this
->t('Converts <code>@ascii</code> to @unicode', [
'@ascii' => $ascii,
'@unicode' => $unicode,
]);
$output .= "<li>{$ascii_to_unicode}</li>\n";
}
}
$output .= '</ul>';
}
else {
$output = $this
->t('Typographic refinements will be added.');
}
return $output;
}