Giter VIP home page Giter VIP logo

typographie.php's Introduction

#Typographie.php Build Status Dependency Status

Library for preparation of russian texts to web publication.
Core of Typographie web service.

Installation

Add package to the composer.json:

composer require asleepwalker/typographie

Run Composer:

composer install

Example

<?php

use asleepwalker\typographie\Typographie;

$engine = new Typographie('quotes,inquot,dashes,specials,paragraphs');

$raw = 'Сервис "Typographie" - подготовка текстов к веб-публикации онлайн (с) 2014-2017';
echo $engine->process($raw);
// > Сервис «Typographie» — подготовка текстов к веб-публикации онлайн © 2014–2017

Actions

quotes : Correction of quotes: "" becomes «».
inquot (requires quotes) : Nested quotes: «„“» (otherwise — duplicate quotes stashing).
dashes : If necessary replace hyphens with dashes and minus signs.
angles : Replace asterisks and quotes with degrees, feet, inches.
dblspace : Fix duplicate spaces in the text.
specials : Insert special characters (from the symbol table).
mathchars : Insert mathematical symbols (from the same table).
punctuation : Fix punctuation, such as spaces before commas.
specialspaces : Fix the wrong skip special characters with spaces.
nbsp : Attach short words to following words in the text.
hellip : Replace repeating dot symbols with ellipsis.
paragraphs : Puts paragraphs (<p>) when converting to HTML (with empty string as a delimeter).
safehtml : Don't process text inside of <code> and <pre> blocks.
entities : Replace special chars with HTML entities.

The list should be comma separated, e.g. action1,action2,action3.

Beside defining in the object constructor, use can change configuration by method actions:

$engine->actions('punctuation,dblspace');
echo $engine->process('К  чёрту орфографию ,главное   все понимают !Ведь так  ?..');
// > К чёрту орфографию, главное все понимают! Ведь так?..

Modes

plain : Just plain text.
html : Safe HTML processing.

The mode could be defined in the constructor:

$engine = new Typographie('quotes,dashes', $in, $out);

Or by method mode:

$engine->mode('html', 'plain');

Default congifuration is plain mode for both input and output.

License

The MIT License.

typographie.php's People

Contributors

cybran111 avatar tyrain avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

vaslog

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.