Snippet for text typography. The snippet doesn’t use third-party services, also it sends no requests. In other words, everything is performed on your server.
You can turn off typography for a text fragment using the <notg></notg> or <span class="notg"></span> tags.
- PHP >= 5.6
- (MODX)EvolutionCMS.libraries.ddTools >= 0.48.1
- PHP.libraries.EMT 3.5 (contains in archive)
Just run the following PHP code in your sources or Console:
// Include (MODX)EvolutionCMS.libraries.ddInstaller
require_once(
$modx->getConfig('base_path')
. 'assets/libs/ddInstaller/require.php'
);
// Install (MODX)EvolutionCMS.snippets.ddTypograph
\DDInstaller::install([
'url' => 'https://github.com/DivanDesign/EvolutionCMS.snippets.ddTypograph',
'type' => 'snippet',
]);- If
ddTypographis not exist on your site,ddInstallerwill just install it. - If
ddTypographis already exist on your site,ddInstallerwill check it version and update it if needed.
- Snippet name:
ddTypograph. - Description:
<b>2.7.1</b> Snippet for text typography. The snippet doesn’t use third-party services, also it sends no requests. In other words, everything is performed on your server.. - Category:
Core. - Parse DocBlock:
no. - Snippet code (php): Insert content of the
ddTypograph_snippet.phpfile from the archive.
- Create a new folder
assets/snippets/ddTypograph/. - Extract the archive to the folder (except
ddTypograph_snippet.php).
-
text- Description: Text to correct.
- Valid values:
string - Required
-
optAlign- Description: Optical alignment (hanging punctuation).
- Valid values:
01
- Default value:
0
-
optAlign_useClasses- Description: Use CSS classes instead of inline styles for optical alignment (
<span class="oa_comma_b">instead of<span style="margin-right:-0.2em;">).
If the parameter is enabled, don't forget to specify the following CSS rules on your site:.oa_obracket_sp_s {margin-right:0.3em;} .oa_obracket_sp_b {margin-left:-0.3em;} .oa_obracket_nl_b {margin-left:-0.3em;} .oa_comma_b {margin-right:-0.2em;} .oa_comma_e {margin-left:0.2em;} .oa_oquote_nl {margin-left:-0.44em;} .oa_oqoute_sp_s {margin-right:0.44em;} .oa_oqoute_sp_q {margin-left:-0.44em;}
- Valid values:
01
- Default value:
0
- Description: Use CSS classes instead of inline styles for optical alignment (
-
text_paragraphs- Description: Section signs and line breaks insertion.
- Valid values:
01
- Default value:
0
-
text_autoLinks- Description: Marking links (including email ones).
- Valid values:
01
- Default value:
0
-
etc_unicodeConvert- Description: Convert HTML entities into Unicode (
—instead of—, etc). - Valid values:
01
- Default value:
1
- Description: Convert HTML entities into Unicode (
-
noTags- Description: Whether HTML element insertion is allowed or not.
There are cases when using tags causes the text to be invalid, for example, using the snippet inside of an HTML attribute. - Valid values:
01
- Default value:
0
- Description: Whether HTML element insertion is allowed or not.
-
excludeTags- Description: HTML tags which content will be ignored by snippet.
- Valid values:
stringCommaSeparated - Default value:
'notg,code'
[[ddTypograph? &text=`[*content*]`]]
[[ddTypograph?
&text=`Some text for typography.`
&text_paragraphs=`1`
&text_autoLinks=`1`
]]
[[ddTypograph?
&text=`Some text for "typography".`
&optAlign=`1`
]]
[[ddTypograph?
&text=`Some text. <notg>The snippet will not change this text inside the tag.</notg> It's easy. <span class="notg">Additionally, `span` with the single `notg` class is also supported.</span>`
]]\DDTools\Snippet::runSnippet([
'name' => 'ddTypograph',
'params' => [
'text' => "
There's nothing you can do that can't be done
Nothing you can sing that can't be sung
https://en.wikipedia.org/wiki/The_Beatles
",
'text_paragraphs' => true,
'text_autoLinks' => true,
],
]);Returns:
<p>There’s nothing you can do that can’t be done<br>
Nothing you can sing that can’t be sung</p>
<p><a href="https://en.wikipedia.org/wiki/The_Beatles">en.wikipedia.org/wiki/The_Beatles</a></p>