Giter Club home page Giter Club logo

kirby-typography's Introduction

Kirby-Typography

This is a port of wp-Typography for Kirby CMS. Based on the PHP_Typography class, this plugin enhances the typography of you kirby-powered website. Think of it a more advanced alternative to the built-in SmartyPants parser.

Current version: 1.0.0-beta1


Table of Contents


1 Key Features

  • Hyphenation: Hyphenate text, very handy for justified text or languages with very long words, but also for English. Supports a large number of languages and offers fine-grained control over hyphenation.
  • Smart Replacements: Includes Smart quotes (i.e. „Curly Quotes“, «Guillemets», »Chevrons« or German „Gänsefüßchen“) and smart ordinal suffixes.
  • CSS Hooks: Add <span class="[…]"> tags around characters like ampersands, CAPITALIZED WORDS etc.
  • Hanging Punctuation: Add the twinkle of the print-era to your site.
  • Wraps URLs: Prevents long URLs from overflowing their container element on small screens.
  • Smart Math: Converts mathematical symbols into their correct counterpart. E.g. (2x6)/3=4 becomes (2×6)÷3=4.
  • Caching: Processing text like this plugin does is a very performance-hungry task. So the results are always cached, even if Kirby’s cache option is turned off. Cache will automatically be updated, if you change your content or update the plugin. It also comes with a Dashboard Widget, so you can flush the cache from your panel.

… and basically every other feature of wp-Typography :-)

2 Download and Installation

2.1 Requirements

  • PHP 5.4.0+ with multibyte extension (mbstring)
  • Kirby 2.3.0+ (not compatible with Kirby 3)

2.2 Kirby CLI

If you’re using the Kirby CLI, you need to cd to the root directory of your Kirby installation and run the following command:

kirby plugin:install fabianmichael/kirby-typography

This will download and copy Kirby-Typography into site/plugins/typography.

2.3 Git Submodule

To install this plugin as a git submodule, execute the following command from the root of your kirby project:

$ git submodule add https://github.com/fabianmichael/kirby-typography.git site/plugins/typography

2.4 Copy and Paste

  1. Download the contents of this repository as ZIP-file.
  2. Rename the extracted folder to typography and copy it into the site/plugins/ directory in your Kirby project.

3 Usage

The plugin is enabled by default and replaces the SmartyPants parser of your Kirby installation. That means, typographic enhancements are applied to Kirbytext by default.

I tried to setup sane defaults, but you might have different requirements for your site. You can change any of the plugin’s settings in your config.php file.

3.1 CSS and JavaScript Setup

CSS: Not all features of the plugin need extra CSS rules, but for stuff like hanging punctuation, and character styling to work properly, it is recommended or even necessary to add the plugin’s CSS file to your site. Add <?= css('assets/plugins/typography/css/typography.css') ?> to your template or – even better – copy the rules to your own stylesheet. Note, that some features like hanging punctuation should be tuned in accordance to the font you have chosen.

JavaScript: Hyphenation works by inserting invisible so-called »shy hyphens« (&shy;) into works, telling the browser where a word may be hyphenated. Unfortunately, these invisible characters stay in the text, when it is copied from your site. To keep copied text easily editable, it is recommended (though not mandatory) to also include the supplied JavaScript file to your code. Just add <?= js('assets/plugins/typography/js/dist/copyfix.min.js') ?> into to your template.

4 Configuration

You can find a description of all available configuration options below. Customization works just like with any other configuration of Kirby. Your can read more about configuration in the Kirby docs. The default settings of this plugin were chosen for United States (US) English.

4.1 Localization for Multilingual Sites

If your Kirby installation is configured for multiple languages, you might want to use different settings for every language. In this case, you can define a common baseline of settings – shared by all languages – in your config file. Use the language files in site/languages/ to define localized versions of your settings. Note, that in the language files, settings need to be configured with l::set(), because those localizations are treated as language variables:

# site/config/config.php
c::set('typography.class.ampersand', 'ch-amp'); // CSS classes are most likely shared across languages
# site/languages/fr.php
l::set('typography.quotes.primary', 'doubleGuillemetsFrench'); // Quote styles are language-specific …
l::set('typography.quotes.secondary', 'doubleCurled');
l::set('typography.hyphenation.language', 'fr'); // … and so are hyphenation rules

# site/languages/de.php
l::set('typography.quotes.primary', 'doubleLow9Reversed');
l::set('typography.quotes.secondary', 'singleLow9Reversed');
l::set('typography.hyphenation.language', 'de');

At the end of this document, you can find a list of recommended settings for different languages, you can use as a starting point for your own configuration.

4.2 General Options

Option Default value Description
typography true Set to false to disable plugin functionality.
typography.debug false set to true to disable the built-in caching mechanism.
typography.widget true Set to false to disable the dashboard widget.
typography.ignore.tags ['code', 'head', 'kbd', 'object', 'option', 'pre', 'samp', 'script', 'noscript', 'noembed', 'select', 'style', 'textarea', 'title', 'var', 'math'] Defines elements to be ignored by their tag name.
typography.ignore.classes ['vcard', 'typography--off'] Defines elements to be ignored by their class.
typography.ignore.ids [] Defines elements to be ignored by their ID.

4.3 Smart Quotes

Option Default value Description
typography.quotes true Transform straight quotes [ ' " ] to typographically correct characters.
typography.quotes.primary 'doubleCurled' Primary quotes style.
typography.quotes.secondary 'singleCurled' Secondary quotes style (for nested quotations).

Available Styles for Smart Quotes:

Option value Example
'doubleCurled' (default) “foo”
'doubleCurledReversed' ”foo”
'doubleLow9' „foo”
'doubleLow9Reversed' „foo“
'singleCurled' (default) ‘foo’
'singleCurledReversed' ’foo’
'singleLow9' ‚foo’
'singleLow9Reversed' ‚foo‘
'doubleGuillemetsFrench' « foo »
'doubleGuillemets' «foo»
'doubleGuillemetsReversed' »foo«
'singleGuillemets' ‹foo›
'singleGuillemetsReversed' ›foo‹
'cornerBrackets' 「foo」
'whiteCornerBracket' 『foo』

4.4 Smart Character Replacements

Option Default value Description
typography.dashes true Transform minus-hyphens [ - -- ] to contextually appropriate dashes, minus signs, and hyphens [ – — − ‐ ].
typography.dashes.style 'em' Sets the style of smart dashes. Alternative value: 'em'.1
typography.dashes.spacing true Force thin spaces between em & en dashes and adjoining words.
typography.diacritics false Force diacritics where appropriate (i.e. creme brulee becomes crème brûlée).
typography.diacritics.language en-US Language for diacritic replacements. Language definitions will purposefully not process words that have alternate meaning without diacritics like resume & résumé, divorce & divorcé, and expose & exposé. Currently available options are only 'en-US' and 'de-DE'.
typography.diacritics.custom [] Custom diacritic word replacements: Takes an associative array with the searches as keys and the replacements as values. Note, that this is case-sensitive.
typography.ellipses true Transform three periods [ ... ] to ellipses [ … ].
typography.marks true Transform registration marks [ (c) (r) (tm) (sm) (p) ] to proper characters [ © ® ™ ℠ ℗ ].
typography.ordinal.suffix true Transform ordinal suffixes [ 1st ] to pretty ordinals [ 1st ].
typography.math true Transforms math symbols [ (2x6)/3=4 ] to correct symbols [ (2×6)÷3=4 ].
typography.fractions true Transform fractions [ 1/2 ] to pretty fractions [ 12 ].
typography.exponents true Transform exponents [ 3^2 ] to pretty exponents [ 32 ].

1) In the US, the em dash — with no or very little spacing — is used for parenthetical expressions, while internationally, the en dash – with spaces – is more prevalent.

2) Some fonts support smart fractions via an OpenType feature called “frac”, but is has to be enabled manually by declaring the font-feature-settings property in CSS. As of 2016, this is not supported by all major browsers. If you need this to work in everywhere, you should not rely on the OpenType feature and leave this setting turned on. The only exception where you really should disable this feature are monospaced fonts, because using smaller digits will break the fixed-width grid, your letters are sitting on. Details on browser support for the frac feature can be found at The State of Web Type and Can I use.

4.5 Smart Spacing

Option Default value Description
typography.wordspacing.singlecharacter true Enable forcing single character words to next line with the insertion of &nbsp; (no-break space).
typography.fraction.spacing true Inserts a no-break space into fractions to prevent wrapping [ 5 12 ].
typography.punctuation.spacing.french false Enable extra whitespace before certain punctuation marks, as is the French custom.
typography.units.spacing true Keep values and units together [ 12 cm ].
typography.units.custom [] Additional units to match (Kirby-Typography already recognizes a with a large amount of different units).
typography.dewidow true Prevent widows.
typography.dewidow.maxlength 5 Only protect widows with x or fewer letters.
typography.dewidow.maxpull 5 Pull at most x letters from the previous line to keep the widow company.
typography.wrap.hardhyphens true Enable wrapping after hard hyphens. Adds zero-width spaces after hard hyphens (like in “zero-width”).
typography.wrap.url true Enable wrapping of long URLs. Adds zero-width spaces throughout the URL.
typography.wrap.email true Enable wrapping of long emails. Adds zero-width spaces throughout the email.
typography.wrap.url.minafter 5 Keep at least the last x characters of a URL together.
typography.domains.custom ['local', 'onion', 'exit', 'tor', 'test', 'example'] The parser looks for domains in your content, based on a list of all valid Top-Level-Domains (updated and cached automatically once a week). Use this option to define additional domains, the parser should look for.
typography.space.collapse true Remove superfluous whitespace from your content.
typography.space.nobreak.narrow false Enable to use true no-break narrow space (U+202F) instead of regular no-break space (&nbsp;). Disabled by default, because this glyph is missing in most fonts. Make sure, that your

4.6 Character Styling and Hanging Punctuation

The following options add <span> tags around certain parts of your content to create CSS hooks, allowing you to style specific parts of your text.

Option Default value Description
typography.style.ampersands false Wrap ampersands [ & ] with a <span> tag.
typography.style.caps true Wrap words in ALL CAPS with a <span> tag.
typography.style.numbers false Wrap numbers with a <span> tag.
typography.style.punctuation.hanging false Enable hanging punctuation. Also see the included stylesheet to see how this works.
typography.style.quotes.initial true Wrap initial quotes with a <span> tag.
typography.style.quotes.initial.tags ['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'blockquote', 'li', 'dd', 'dt'] Only style initial quotes within these tags.

4.7 Hyphenation

Option Default value Description
typography.hyphenation true Enables hyphenation.
typography.hyphenation.language 'en-US' Sets the language for hyphenation rules.3
typography.hyphenation.minlength 7 Do not hyphenate words with less than x letters.
typography.hyphenation.minbefore 3 Number of letters to keep before hyphenation.
typography.hyphenation.minafter 2 Number of letters to keep after hyphenation.
typography.hyphenation.headings true Disabling this option will disallow hyphenation of headings, even if allowed in the general scope.
typography.hyphenation.allcaps true Hyphenate words in ALL CAPS.
typography.hyphenation.titlecase true Allow hyphenation of words that begin with a capital letter. Disable to avoid hyphenation of proper nouns.
typography.hyphenation.compounds true Allow hyphenation of the components of hyphenated compound words. Disable to disallow the hyphenation of the words making up a hyphenated compound (e.g. editor-in-chief).
typography.hyphenation.exceptions [] Exception List (array): Mark allowed hyphenations with "-" (e.g. typo-graphy).

3) Hyphenation rules are available for the following languages: af, hy, eu, bg, ca, zh-Latn, hr, cs, da, nl, en-GB, en-US, et, fi, fr, gl, ka, de, de-1901, grc, el-Mono, el-Poly, hu, is, id, ia, ga, it, la, la-classic, lv, lt, mn-Cyrl, no, pl, pt, ro, ru, sa, sr-Cyrl, sh-Cyrl, sh-Latn, sk, sl, es, sv, th, tr, tk, uk, cy

4.8 CSS Classes

Some of the options above add <span> tags around single characters or sequences of characters, so you hook into their presentation via good ol’ CSS. If you don’t like the rather long class names I have chosen as default, feel free to change ’em to whatever you like by settings the options below:

Option Default value
typography.class.ampersand 'char--ampersand'
typography.class.caps 'char--caps'
typography.class.numbers 'char--numbers'
typography.class.fraction.numerator 'frac--numerator'
typography.class.fraction.denominator 'frac--denominator'
typography.class.quote.initial.single 'char--singleQuoteInitial'
typography.class.quote.initial.double 'char--doubleQuoteInitial'
typography.class.push.single 'push--singleQuote'
typography.class.push.double 'push--doubleQuote'
typography.class.pull.single 'pull--singleQuote'
typography.class.pull.double 'pull--doubleQuote'
typography.class.ordinal.suffix 'char--ordinalSuffix'

5 Recommended Settings for Different Languages

The following recommendations are based on common typographic conventions of those languages. That does not mean, that you have to stick to them, but their make a good starting point for your own settings. Is your language missing in this list? Feel free to create an issue or pull request and I will add settings for your language to the list.

Important: If your site is multilingual, you need to define those settings in site/languages/[language code].php, using l::set() instead of c::set, if you want to use different settings per language.

French (France):

c::set([
  'typography.punctuation.spacing.french' => true,
  'typography.dashes.style'               => 'em', // cadratin ('en' for demi-cadratin)
  'typography.quotes.primary'             => 'doubleGuillemetsFrench',
  'typography.quotes.secondary'           => 'doubleCurled',
  'typography.hyphenation.language'       => 'fr',
]);

German (Germany):

c::set([
  'typography.dashes.style'         => 'en',
  'typography.quotes.primary'       => 'doubleLow9Reversed',
  'typography.quotes.secondary'     => 'singleLow9Reversed',
  'typography.hyphenation.language' => 'de',
]);

Note: In books, sometimes Chevrons [ »foo« ] are used as quotation marks instead. Use doubleGuillemetsReversed and singleGuillemetsReversed if you prefer that style.

6 License

Kirby-Typography is released under the GNU General Public License 3.0 or later. See LICENSE file for details (FYI: This is mandatory, because wp-Typography is also released under GPL. I would have preferred the MIT license.).

7 Credits

Kirby-Typography is developed and maintained by Fabian Michael.

The plugin includes or is based on the following third-party libraries:

  • PHP-Typography: Copyright 2014-2016 Peter Putzer; 2012-2013 Marie Hogebrandt; 2009-2011 KINGdesk, LLC. Released under the GPL 2.0 or later. Large parts of this documentation have also been copied and/or adapted from the original WordPress plugin.
  • HTML5-PHP: Released under the HTML5Lib License (see vendors/masterminds/HTML5/LICENSE for details and contributors)
  • A List of all Top-Level-Domains, maintained by the Internet Assigned Numbers Authority (IANA) (automatically updated once a week)
  • JavaScript (copyfix.js) based on Hyphenator 5.2.0(devel). Copyright 2015 by Mathias Nater. Originally released under the MIT license.

kirby-typography's People

Contributors

fabianmichael avatar tobiasfabian avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kirby-typography's Issues

Hyphenation of headings

'typography.hyphenation.headings'       => 'false',

Has strictly no effect (words are hypheteted)

Kirby version : 2.3
Language : French

'typography.punctuation.spacing.french' doesn't work on « »

Hi, it's me again.
"Noooo, not them again."
Sorry. :D

Okay, so this might be a problem upstream in php-Typography.

Provided the following input:

Les « courants de bord ouest » du Pacifique ?
Eh bien : ils sont "fabuleux".

and using the smartypants function or kirbytext method on this input, the result is:

 Les « courants de bord ouest » du Pacifique&nbsp;?
Eh bien&nbsp;: ils sont «&nbsp;fabuleux&nbsp;».

config is:

// config/config.php
c::set([
    'smartypants' => true,
    'typography' => true,
    'typography.style.punctuation.hanging' => false,
    'typography.style.quotes.initial' => false,
    'typography.hyphenation' => false,
]);

// languages/fr.php
l::set('typography.punctuation.spacing.french', true);
l::set('typography.quotes.primary', 'doubleGuillemetsFrench');
l::set('typography.quotes.secondary', 'doubleCurled');

Ideally, I would like the typography.punctuation.spacing.french setting to deal with « » quotes in the same way it deals with ?!:;, i.e. to transform «\s+ to «&nbsp; and \s+» to &nbsp;». Since it's a setting for French, there should be no doubt whether » is a closing or opening quote (it's a closing quote).

Do you think that's a limitation of php-Typography that I should bring up with them?

Issue with unwanted pull/push--doubleQuote

I have an issue that I don't seem to be able to resolve with config options only.

I have those two textareas, for example :

He was co-editor of the magazine ​*Name of magazine* and created ​*Name of creation*.

and

Editorial manager: Name
​Address: 75 Street City
Email: [email protected]

I have two languages. English (default) and french. And I only changed the hyphenation to falsein my config file. My issue :

First scenario : I don't change any config

The first textarea renders as :

He was co-editor of the magazine<em>Name of magazine<em> and created<em>Name of creation</em>.

and the second :

Editorial manager: Name<br>
​Address: 75 Street City<br>
Email: <a href="mailto:[email protected]">example@&#8203;example.&#8203;com</a>

So, the first text is missing its spaces before the <em> tags.

Second scenario : space.collapse set to false

With this option, the first text renders as it should :

He was co-editor of the magazine <em>Name of magazine<em> and created <em>Name of creation</em>.

But in the meantime, it introduced some doubleQuote after each <br> on the second text :

Editorial manager: Gauthier Roussilhe<br>
<span class="push--doubleQuote"></span>&#8203;<span class="pull--doubleQuote">
</span>Address: 75 Street City<br>
<span class="push--doubleQuote"></span>&#8203;<span class="pull--doubleQuote">
</span>Email: <a href="mailto:[email protected]">example@&#8203;example.&#8203;com</a>

What should I do ?

(you can see the code of the entire website here)

typography.diacritics.custom [documentation]

Can you provide an exemple for "typography.diacritics.custom" ? I want to use it in French recommended Settings but it doesn't work. Also, "typography.punctuation.spacing.french" doesn't seems to add thin spaces inside French quotes (ex. : « foo »).
Thanks!

Kirby 3

Do you plan to make a K3 version of this great plugin ? :)

Consider disabling by default: typography.hyphenation

Feel free to close this issue if you disagree. :)

Rationale: while other things like typographically incorrect quotes and fake dashes (--) can be seen as defects or limitations of the source text that should probably be corrected whenever possible, hyphenation is a design choice that designers should probably opt in. Especially since it's very uncommon on the web.

Providing a hyphenate field method

Would this plugin be able provide a $field->hyphenate($lang) method, without major refactoring?

As argued in #6, hyphenation is a design choice. And I'll add that a designer or client may want hyphenation for some texts (e.g. an article's body) but not for others (e.g. a big title).

What might serve this use case:

<article>
  <header>
    <h1><?php echo $page->title()->smartypants(); ?></h1>
  </header>
  <div class="article-body">
    <?php echo $page->text()->kirbytext()->hyphenate(); ?>
  </div>
</article>

Adding a basic composer.json

Hi,

It would be nice to add a simple composer.json file to this repo, to make installation with Composer quite easier.

It could look like:

{
  "name": "fabianmichael/kirby-typography",
  "description": "This is a port of [wp-Typography](https://de.wordpress.org/plugins/wp-typography/) for Kirby CMS. Based on the `PHP_Typography` class, this plugin enhances the typography of you kirby-powered website. Think of it a more advanced alternative to the built-in `SmartyPants` parser.",
  "authors": [{"name": "Fabian Michael"}],
  "license": "GPL-3.0"
}

The "version" key is optional, and it’s recommended to omit it to let Composer (and Packagist) retrieve the available versions from git tags. Note that Composer will only see those tags which have a composer.json file, so if you add a commit with a composer.json you will need to add a tag.

It could be nice to publish this package on Packagist as well.

Use case

If one wants to install this plugin with Composer today, one needs a verbose definition:

{
  "minimum-stability": "beta",
  "require": {
    "fabianmichael/kirby-typography": "^1.0.0"
  },
  "repositories": [
    {
      "type": "package",
      "package": {
        "name": "fabianmichael/kirby-typography",
        "version": "1.0.0",
        "source": {
          "type": "git",
          "url": "https://github.com/fabianmichael/kirby-typography.git",
          "reference": "1.0.0-beta1"
        }
      }
    }
  ]
}

With a composer.json in this repo, it gets shorter:

{
  "minimum-stability": "beta",
  "require": {
    "fabianmichael/kirby-typography": "^1.0.0"
  },
  "repositories": [
    { "type": "vcs", "url": "https://github.com/fabianmichael/kirby-typography" }
  ]
}

And if this package is also published on Packagist, you can just use:

{
  "minimum-stability": "beta",
  "require": {
    "fabianmichael/kirby-typography": "^1.0.0"
  }
}

Text-Squashing (in Safari 11)

(This could be a Safari bug, I am not sure at all.)

I have a small container with a max-width applied and a monospaced font. When I enable the kirby-typography plugin (with just smartypants it works fine) the text looks squashed:

bildschirmfoto 2017-09-22 um 10 28 58

How can I debug this or do you have any idea?
Dennis

How to deal with the caching gotcha

Hi,

So I spent a few hours the other day trying to get settings for a multilingual site working. Most of the settings I was declaring, in site/config/config.php or in languages/fr.php were not working. for instance I couldn't get the &nbsp; added before double punctuation marks. It just wouldn't work.

Today I realized that this plugin uses a week-long cache, and what I was seeing was perhaps the result from older settings. So I set c::set('typography.debug', true); and taddaaaa it worked.

I'm suspecting many users would have this issue, if following this scenario:

  1. Install plugin
  2. Enable it
  3. Load a page to see the result
  4. Tweak configuration
  5. Refresh page: nothing changes

Different ways to prevent that:

  1. Document it more prominently in the README (might still be easy to miss)
  2. Default typography.debug to the value of the debug config.
  3. Best but more complex: build a hash string out of the typography config values, and use it as a key when storing the cache. Changed config = cache doesn't match anymore.

Custom typography.quotes.primary strings

Not sure that's something you have control over, if the options come from the libraries used.

I was thinking that for typography.quotes.primary and typography.quotes.secundary it would be nice to be able to provide custom strings, like:

c::set('typography.quotes.primary', '«&#8239;foo&#8239;»');

The foo string or another marker would act as a way to detect a custom setting and split the opening/closing parts.

Error with Smartypants in Kirby 2.5.8

Declaration of Kirby\Plugins\Typography\Component\Typography::parse($text, $force = false) should be compatible with Kirby\Component\Smartypants::parse($text, $force, Field $field)

Any idea how to fix this ?

Thanks a lot

Requirements bug?

On simple php webserver i get this

Fatal error: Method Kirbytext::__toString() must not throw an exception, caught Error: Call to undefined function Masterminds\HTML5\Parser\ctype_alpha() in /Users/krisa/dev/sok_bz/website/kirby/helpers.php on line 0

I was thinking that maybe its some extension missing, but that html5 parser seems OK and should work even in php5.3

I tested this in php5.6 and 7 not sure what i am missing.

Loads non-existent file in panel

This plugin loads a non existing file (also i couldn't find a htaccess with this path in it).

http://127.0.0.1/plugins/typography/widget/api/status

Implement API Methods and helper Functions

Using Kirby-Typography should not be limited to Kirbytext or by utilizing the Smartypants component. In Some cases, you want to use different settings for different fields and/or in different sections of a template (see #7).

Kirby-Typography should provide methods utilizing the plugin directly:

typography($text, $settings = []);

This should always be based a language’s default settings with the possibility to override them using the $settings parameter. It could also be possible to define presets in the config file, which can then be used in templates by providing a string instead of an array for $settings.

regex pattern or specific replacement

Hi Fabian, your adaption is pretty neat! Will there be a way to make further typographical corrections in your next version? like searching for regex patterns or speficic word combinations, then changing the whitespace to a smaller one and wrap the term to prevent line breaking etc?

Change default quotes to doubleCurled and singleCurled

I understand the personal preference and perhaps the willingness to depart from English/American norms all the time everywhere, but:

  • People who are already using the built-in SmartyPants filter in Kirby might get surprised by the change
  • doubleCurled and singleCurled are closest to the replaced characters
  • Kirby and this plugin are both documented in English

Parse error on PHP 5.5

On PHP 5.4 (yeah there are some old servers around) and PHP 5.5 (built-in PHP version in latest OSX, I’m getting a parse error in lib/kirbytypography.php, line 9.
Apparently PHP prior to 5.6 does not like computing stuff when declaring class properties.

class KirbyTypography extends PHP_Typography {

  protected $domainListUrl = 'http://data.iana.org/TLD/tlds-alpha-by-domain.txt';
  protected $domainListCacheLifetime = 60 * 24 * 7; // one week

Changing to protected $domainListCacheLifetime = 10080; seems to fix the issue (tested with PHP 5.5).

By the way, is that property supposed to represent a number of minutes?
Because 60 * 24 * 7 = 10080 is the number of minutes in a week.
If you want seconds, that’s 60 * 60 * 24 * 7 = 604800.

Can't disable hyphenation

My current config.php looks like this:

c::set([
    'typography.dashes'          => 'false', // I already care for that
    'typography.hyphenation'     => 'false' // disable hyphenation
]);

But it doesn't work. The text still gets hyphenated :(

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.