public function filter($text)
 {
     if (Options::get('typogrify__do_amp')) {
         $text = amp($text);
     }
     if (Options::get('typogrify__do_widont')) {
         $text = widont($text);
     }
     if (Options::get('typogrify__do_smartypants')) {
         // Standard options plus convert_quot ('w') to
         // convert " entities, that Habari might
         // already have converted '"' characters into.
         $text = SmartyPants($text, "qbdew");
     }
     if (Options::get('typogrify__do_caps')) {
         $text = caps($text);
     }
     if (Options::get('typogrify__do_initial_quotes')) {
         $text = initial_quotes($text);
     }
     if (Options::get('typogrify__do_guillemets')) {
         $text = initial_quotes($text, true);
     }
     if (Options::get('typogrify__do_dash')) {
         $text = dash($text);
     }
     return $text;
 }
Example #2
0
 * Converts the field value to upper case
 * @param Field $field The calling Kirby Field instance
 * @return Field
 */
field::$methods['upper'] = function ($field) {
    $field->value = str::upper($field->value);
    return $field;
};
/**
 * Applies the widont rule to avoid single 
 * words on the last line
 * @param Field $field The calling Kirby Field instance
 * @return Field
 */
field::$methods['widont'] = function ($field) {
    $field->value = widont($field->value);
    return $field;
};
/**
 * Creates a simple text excerpt without formats
 * @param Field $field The calling Kirby Field instance
 * @param integer $chars The desired excerpt length
 * @return string
 */
field::$methods['excerpt'] = function ($field, $chars = 140, $mode = 'chars') {
    return excerpt($field, $chars, $mode);
};
/**
 * Shortens the field value by the given length
 * @param Field $field The calling Kirby Field instance
 * @param integer $length The desired string length
 public function widontFilter($str)
 {
     $charset = craft()->templates->getTwig()->getCharset();
     $str = widont($str);
     return new \Twig_Markup($str, $charset);
 }
Example #4
0
<?php

/**
 * Widont
 * ----
 * Remove widows from text string.
 *
 * What it does:
 * Replaces last space by a non-breaking-space (e.g. `&nbsp;`).
 * Uses Kirby toolkit's widont helper function (based on str::widont)
 *
 * Usage:
 * (widont: This is a title without widows)
 */
kirbytext::$tags['widont'] = array('html' => function ($tag) {
    $text = $tag->attr('widont');
    return widont($text);
});
Example #5
0
<?php

snippet('forum.header');
?>

<article class="topic topic-details<?php 
e($page->isSolved(), ' topic-is-solved');
?>
">

  <header class="topic-header cf">
    <h1 class="topic-headline alpha"><?php 
echo widont(html($page->title(), false));
?>
</h1>
    <div class="topic-meta">
      <time class="date topic-date"><?php 
echo $page->date('d.m.Y - H:i');
?>
</time>
      <a class="user" href="https://twitter.com/<?php 
echo $page->user();
?>
">by <?php 
echo $page->user();
?>
</a>
    </div>
  </header>

  <div class="topic-body">
/**
 * typogrify
 * 
 * The super typography filter.   
 * Applies the following filters: widont, smartypants, caps, amp, initial_quotes
 * Optionally choose to apply quote span tags to Gullemets as well.
 */
function typogrify($text, $do_guillemets = false)
{
    $text = amp($text);
    $text = widont($text);
    $text = SmartyPants($text);
    $text = caps($text);
    $text = initial_quotes($text, $do_guillemets);
    $text = dash($text);
    return $text;
}
Example #7
0
<?php

snippet('header');
?>

<main class="main" role="main">
  <article class="article grid">

    <header class="article-header">
      <h1 class="alpha"><?php 
echo widont(kirbytext($page->title(), false));
?>
</h1>

      <time class="article-date" datetime="<?php 
echo $page->date('c');
?>
">
        <span class="month"><?php 
echo $page->date('M d');
?>
</span>
        <span class="year"><?php 
echo $page->date('Y');
?>
</span>
      </time>
    </header>

    <div class="article-body col-4-6">