{"id":13722286,"url":"https://github.com/michelf/php-smartypants","last_synced_at":"2025-04-05T10:09:25.119Z","repository":{"id":934034,"uuid":"706322","full_name":"michelf/php-smartypants","owner":"michelf","description":"Web typography prettifyier tools derived from the original SmartyPants.pl by John Gruber.","archived":false,"fork":false,"pushed_at":"2021-08-14T10:13:06.000Z","size":77,"stargazers_count":108,"open_issues_count":6,"forks_count":22,"subscribers_count":7,"default_branch":"lib","last_synced_at":"2025-03-29T09:11:56.020Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://michelf.ca/php-smartypants/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/michelf.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"License.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-06-06T18:15:42.000Z","updated_at":"2024-12-27T18:07:32.000Z","dependencies_parsed_at":"2022-07-15T05:30:34.844Z","dependency_job_id":null,"html_url":"https://github.com/michelf/php-smartypants","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michelf%2Fphp-smartypants","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michelf%2Fphp-smartypants/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michelf%2Fphp-smartypants/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michelf%2Fphp-smartypants/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/michelf","download_url":"https://codeload.github.com/michelf/php-smartypants/tar.gz/refs/heads/lib","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247318745,"owners_count":20919484,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T01:01:26.877Z","updated_at":"2025-04-05T10:09:25.095Z","avatar_url":"https://github.com/michelf.png","language":"PHP","readme":"PHP SmartyPants\n===============\n\nPHP SmartyPants Lib 1.8.1 - 12 Dec 2016\n\nby Michel Fortin  \n\u003chttps://michelf.ca/\u003e\n\nOriginal SmartyPants by John Gruber  \n\u003chttps://daringfireball.net/\u003e\n\n\nIntroduction\n------------\n\nThis is a library package that includes the PHP SmartyPants and its\nsibling PHP SmartyPants Typographer with additional features.\n\nSmartyPants is a free web typography prettifyier tool for web writers. It\neasily translates plain ASCII punctuation characters into \"smart\" typographic \npunctuation HTML entities.\n\nPHP SmartyPants is a port to PHP of the original SmartyPants written \nin Perl by John Gruber.\n\nSmartyPants can perform the following transformations:\n\n*   Straight quotes (`\"` and `'`) into “curly” quote HTML entities\n*   Backtick-style quotes (` ``like this'' `) into “curly” quote HTML\n    entities\n*   Dashes (`--` and `---`) into en- and em-dash entities\n*   Three consecutive dots (`...`) into an ellipsis entity\n\nSmartyPants Typographer can perform additional transformations:\n\n*\tFrench guillemets done using (`\u003c\u003c` and `\u003e\u003e`) into true « guillemets »\n\tHTML entities.\n*\tComma-style quotes (` ,,like this`` ` or ` ''like this,, `) into their \n\tcurly equivalent.\n*\tReplace existing spaces with non-break spaces around punctuation marks \n\twhere appropriate, can also add or remove them if configured to.\n*\tReplace existing spaces with non-break spaces for spaces used as \n\ta thousand separator and between a number and the unit symbol that \n\tfollows it (for most common units).\n\nThis means you can write, edit, and save using plain old ASCII straight \nquotes, plain dashes, and plain dots, but your published posts (and \nfinal HTML output) will appear with smart quotes, em-dashes, proper\nellipses, and proper no-break spaces (with Typographer).\n\nSmartyPants does not modify characters within `\u003cpre\u003e`, `\u003ccode\u003e`,\n`\u003ckbd\u003e`, or `\u003cscript\u003e` tag blocks. Typically, these tags are used to\ndisplay text where smart quotes and other \"smart punctuation\" would not\nbe appropriate, such as source code or example markup.\n\n\n### Backslash Escapes ###\n\nIf you need to use literal straight quotes (or plain hyphens and\nperiods), SmartyPants accepts the following backslash escape sequences\nto force non-smart punctuation. It does so by transforming the escape\nsequence into a decimal-encoded HTML entity:\n\n\n    Escape  Value  Character\n    ------  -----  ---------\n      \\\\    \u0026#92;    \\\n      \\\"    \u0026#34;    \"\n      \\'    \u0026#39;    '\n      \\.    \u0026#46;    .\n      \\-    \u0026#45;    -\n      \\`    \u0026#96;    `\n\n\nThis is useful, for example, when you want to use straight quotes as\nfoot and inch marks:\n\n    6\\'2\\\" tall\n\ntranslates into:\n\n    6\u0026#39;2\u0026#34; tall\n\nin SmartyPants's HTML output. Which, when rendered by a web browser,\nlooks like:\n\n    6'2\" tall\n\n\nRequirements\n------------\n\nThis library package requires PHP 5.3 or later.\n\nNote: The older plugin/library hybrid package for PHP SmartyPants and\nPHP SmartyPants Typographer is still will work with PHP 4.0.5 and later.\n\n\nUsage\n-----\n\nThis library package is meant to be used with class autoloading. For autoloading \nto work, your project needs have setup a PSR-0-compatible autoloader. See the \nincluded Readme.php file for a minimal autoloader setup. (If you don't want to \nuse autoloading you can do a classic `require_once` to manually include the \nfiles prior use instead.)\n\nWith class autoloading in place, putting the 'Michelf' folder in your \ninclude path should be enough for this to work:\n\n\tuse Michelf\\SmartyPants;\n\t$html_output = SmartyPants::defaultTransform($html_input);\n\nSmartyPants Typographer is also available the same way:\n\n\tuse Michelf\\SmartyPantsTypographer;\n\t$html_output = SmartyPantsTypographer::defaultTransform($html_input);\n\nIf you are using PHP SmartyPants with another text filter function that \ngenerates HTML such as Markdown, you should filter the text *after* the \nthe HTML-generating filter. This is an example with [PHP Markdown][pmd]:\n\n\tuse Michelf\\Markdown, Michelf\\SmartyPants;\n\t$my_html = Markdown::defaultTransform($my_text);\n\t$my_html = SmartyPants::defaultTransform($my_html);\n\nTo learn more about configuration options, see the full list of\n[configuration variables].\n\n [configuration variables]: https://michelf.ca/projects/php-smartypants/configuration/\n [pmd]: https://michelf.ca/projects/php-markdown/\n\n\n### Usage Without an Autoloader ###\n\nIf you cannot use class autoloading, you can still use include or require to \naccess the parser. To load the Michelf\\SmartyPants parser, do it this way:\n\n\trequire_once 'Michelf/SmartyPants.inc.php';\n\t\nOr, if you need the Michelf\\SmartyPantsTypographer parser:\n\n\trequire_once 'Michelf/SmartyPantsTypographer.inc.php';\n\nWhile the plain `.php` files depend on autoloading to work correctly, using the \n`.inc.php` files instead will eagerly load the dependencies that would be loaded \non demand if you were using autoloading.\n\n\nAlgorithmic Shortcomings\n------------------------\n\nOne situation in which quotes will get curled the wrong way is when\napostrophes are used at the start of leading contractions. For example:\n\n    'Twas the night before Christmas.\n\nIn the case above, SmartyPants will turn the apostrophe into an opening\nsingle-quote, when in fact it should be a closing one. I don't think\nthis problem can be solved in the general case -- every word processor\nI've tried gets this wrong as well. In such cases, it's best to use the\nproper HTML entity for closing single-quotes (`\u0026#8217;` or `\u0026rsquo;`) by\nhand.\n\n\nBugs\n----\n\nTo file bug reports or feature requests (other than topics listed in the\nCaveats section above) please send email to:\n\n\u003cmichel.fortin@michelf.ca\u003e\n\nIf the bug involves quotes being curled the wrong way, please send\nexample text to illustrate.\n\n\nVersion History\n---------------\n\nPHP SmartyPants Lib 1.8.1 (12 Dec 2016)\n\n*\tFixed an issue introduced in 1.8.0 where backtick quotes were broken.\n\n\nPHP SmartyPants Lib 1.8.0 (13 Nov 2016)\n\n*\tCan now set replacement characters for all transformations using \n\tconfiguration variables, including ellipses and dashes.\n\n*\tRelocated replacement quotes configuration variables from\n\t`SmartyPantsTyppographer` to `SmartyPants`. Also relocated\n\t`decodeEntitiesInConfiguration()` to follow the configuration variables.\n\n*\tAdded conversion of apostrophe and double quote to Hebrew Geresh \n\tand Gershayim when the apostrophe or double quote is surrounded on\n\tboth sides by a Hebrew character. For instance:\n\n\t\tinput:  צה\"ל / צ'ארלס\n\t\toutput: צה״ל / צ׳ארלס\n\n\tYou can still put quotes around Hebrew words and they'll become curled \n\tquotation marks (if that is enabled). This new transform only applies \n\tin the middle of a word, and only to words in Hebrew.\n\n\nPHP SmartyPants Lib 1.7.1 (16 Oct 2016)\n\n*\tFixing bug where `decodeEntitiesInConfiguration()` would cause the \n\tconfiguration to set the space for units to an empty string.\n\n\nPHP SmartyPants Lib 1.7.0 (15 Oct 2016)\n\n*\tMade `public` some configuration variables that were documented\n\twere documented as `public` but were actually `protected`.\n\n*\tAdded the `decodeEntitiesInConfiguration()` method on \n\t`SmartyPantsTypographer` to quickly convert HTML entities in configuration \n\tvariables to their corresponding UTF-8 character.\n\n\nPHP SmartyPants Lib 1.6.0 (10 Oct 2016)\n\nThis is the first release of PHP SmartyPants Lib. This package requires PHP\nversion 5.3 or later and is designed to work with PSR-0 autoloading and,\noptionally with Composer. Here is a list of the changes since\nPHP SmartyPants 1.5.1f:\n\n*\tPlugin interface for Wordpress and Smarty is no longer present in\n\tthe Lib package. The classic package is still available if you need it:\n\t\u003chttps://michelf.ca/projects/php-markdown/classic/\u003e\n\n*\tSmartyPants parser is now encapsulated in its own class, with methods and\n\tconfiguration variables `public` and `protected` protection attributes.\n\tThis has been available in unreleased versions since a few years, but now \n\tit's official.\n\n*\tSmartyPants now works great with PSR-0 autoloading and Composer. If\n\thowever you prefer to more directly `require_once` the files, the\n\t\".inc.php\" variants of the file will make sure everything is included.\n\n*\tFor those of you who cannot use class autoloading, you can now\n\tinclude `Michelf/SmartyPants.inc.php` or\n\t`Michelf/SmartyPantsTypographer.inc.php` (note the `.inc.php` extension)\n\tto automatically include other files required by the parser.\n","funding_links":[],"categories":["📦 Legacy \u0026 Inactive Projects","PHP"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichelf%2Fphp-smartypants","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmichelf%2Fphp-smartypants","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichelf%2Fphp-smartypants/lists"}