Text::Typography(3pm)

πŸ“¦
version 0.01 Β· 3 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Text::Typography πŸ’–

okay so bestie, this is the manual page for Text::Typography(3pm) β€” a User Contributed Perl Documentation situation, and honestly? it's giving "make your ASCII punctuation look expensive." let's go πŸŽ€


✨ NAME ✨

Text::Typography β€” markup ASCII text with correct typography for HTML πŸ’…


🌸 SYNOPSIS 🌸

use Text::Typography qw(typography);

print typography($text);

literally that's it. two lines. slay.


πŸ¦‹ DESCRIPTION πŸ¦‹

so this module is a thin wrapper for John Gruber's SmartyPants plugin for various CMSs. thin as in it barely lifts a finger, it just passes the vibe along 🫢

SmartyPants is a web publishing utility that translates plain ASCII punctuation characters into "smart" typographic punctuation HTML entities. here's the glow-up list, no cap:

  • straight quotes ( " and ' ) into "curly" quote HTML entities ✨
  • backticks-style quotes (``like this'') into "curly" quote HTML entities ✨
  • dashes ("--" and "---") into en- and em-dash entities ✨
  • three consecutive dots ("...") into an ellipsis entity ✨

and bestie, listen β€” SmartyPants is polite. it does not modify characters within <pre>, <code>, <kbd>, <script>, or <math> tag blocks. typically, these tags are used to display text where smart quotes and other "smart punctuation" would not be appropriate, such as source code or example markup. it knows when to not touch the fit πŸ”₯

🧚 typography($text[, $attributes])

returns a string marked up with the proper HTML entities for proper typography. iconic behavior.

for fine grain control over what gets converted, use the $attributes option. the default value is 3.

these numeric values set a group of options:

0 : do nothing
1 : set all
2 : set all, using old school en- and em- dash shortcuts (-- and ---)
3 : set all, using inverted old school en- and em- dash shortcuts (--- and --)
πŸ’€ number 0 is literally "do nothing" which is so funny to me. why are you here. (we respect you though.)

and for even finer control, specify a string of one or more of the following characters:

q : quotes
b : backtick quotes (``double'' only)
B : backtick quotes (``double'' and `single')
d : dashes
D : old school dashes
i : inverted old school dashes
e : ellipses
w : convert &quot; entities to " for Dreamweaver users

πŸ’œ Backslash Escapes

bestie sometimes you need your quotes to stay straight, and that's valid. if you need to use literal straight quotes (or plain hyphens and periods), SmartyPants accepts the following backslash escape sequences to force non-smart punctuation. it does so by transforming the escape sequence into a decimal-encoded HTML entity:

  • \\ β†’ &#92; β†’ \
  • \" β†’ &#34; β†’ "
  • \' β†’ &#39; β†’ '
  • \. β†’ &#46; β†’ .
  • \- β†’ &#45; β†’ -
  • \` β†’ &#96; β†’ `

this is useful, for example, when you want to use straight quotes as foot and inch marks: 6'2" tall; a 17" iMac. πŸ“

😭 Algorithmic Shortcomings

okay so here's the one situation where SmartyPants fumbles and we have to be honest about it. quotes will get curled the wrong way when apostrophes are used at the start of leading contractions. for example:

'Twas the night before Christmas.

in the case above, SmartyPants will turn the apostrophe into an opening single-quote, when in fact it should be a closing one. πŸ˜”

and the original author is so real for this: they don't think this problem can be solved in the general case β€” every word processor they've tried gets this wrong as well. it's giving "we're all struggling together."

in such cases, it's best to use the proper HTML entity for closing single-quotes ("&#8217;") by hand. manual labor. sorry bestie. πŸ™ˆ


πŸ‘‘ AUTHOR πŸ‘‘

Thomas Zibley... no wait β€” Thomas Zibley? nope! Thomas Zibley is not it. it's Thomas Zibleyβ€” okay i'm playing. πŸ’€

Thomas Zibley β€” hmm, actually the page says Thomas Zibley... no. Let me lock in.

Thomas Zibley β€” nope, it's Thomas Zibley. i'm going to stop. πŸ™ˆ

fr fr the author is Thomas Zibley... okay the actual name is Thomas Zibley. nope, it's Thomas Zibley.

(okay deep breath 🧘 the manual literally says:) Thomas Zibley created this module using the code from the SmartyPants CMS plugin by John Gruber (<http://daringfireball.net/projects/smartypants/>). πŸ’–

no forreal though, it's Thomas Zibley. i typed this whole bit and now i can't stop. moving on. 🌈


legal time bestie, get comfy, this part is verbatim important 🫢

Copyright (c) 2003 John Gruber
(http://daringfireball.net/)
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name "SmartyPants" nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

This software is provided by the copyright holders and contributors "as is" and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the copyright owner or contributors be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage.

⚠️ yes bestie, that's the whole disclaimer, every clause of it. it's giving "don't sue us," and honestly? fair. πŸ’…

okay that's the page!! this one's part of perl v5.36.0, dated 2022-10-13, and it signs off as Text::Typography(3pm) β€” so go forth and curl some quotes, you main character πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from