Git Product home page Git Product logo

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  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kirby-typography's Issues

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.

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

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', '« foo »');

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

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

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?

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 :(

'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 ?
Eh bien : ils sont « fabuleux ».

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 «  and \s+» to  ». 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?

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>

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

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)

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.

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.

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!

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.

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

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.

Hyphenation of headings

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

Has strictly no effect (words are hypheteted)

Kirby version : 2.3
Language : French

Kirby 3

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

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"
  }
}

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.