SmartyPants  -  Movable Type的智能报价插件

下载

SmartyPants 1.5.1(20 KB) - 2004年3月12日星期五

什么是新的?

描述

SmartyPants is a free web publishing plug-in for Movable Type, Blosxom, and BBEdit that easily translates plain ASCII punctuation characters into “smart” typographic punctuation HTML entities.

SmartyPants可以执行以下转换:

  • 直引号(“和')成”卷曲“引用HTML实体
  • 反引号式报价(“喜欢这个”)成“卷曲”引用HTML实体
  • 破折号(“-“和”---“)进入en-em-dash实体
  • 连续三个点(“...“)进入省略号实体

This means you can write, edit, and save your posts using plain old ASCII straight quotes, plain dashes, and plain dots, but your published posts (and final HTML output) will appear with smart quotes, em-dashes, and proper ellipses.

SmartyPants是一个组合插件 - 一个与Movable Type,Blosxom和BBEdit配合使用的插件文件它也可以在Unix风格的命令行中使用。

SmartyPants不会修改其中的字符<PRE><代码><KBD>, 要么<SCRIPT>标记块通常,这些标签用于显示智能引号和其他“智能标点符号”不合适的文本,例如源代码或示例标记。

版本要求

  • 可移动类型:2.5或更高版本(包括Movable Type 3.0)
  • Blosxom:2.0或更高版本
  • BBEdit:5.1或更高版本
  • Perl:5.005或更高版本

MT-纺织品整合

Movable Type users should also note that SmartyPants can work in conjunction withBrad Choate的MT-Textile插件

MT-Textile is a port of Dean Allen’s original Textile project to Perl and Movable TypeMT-Textile by itself only translates Textile markup to HTMLHowever, if SmartyPants is also installed, MT-Textile will call on SmartyPants to educate quotes, dashes, and ellipses, automaticallyUsing SmartyPants in conjunction with MT-Textile requires no modifications to your Movable Type templates.

Textile is Dean Allen’s “humane web text generator”, an easy-to-write and easy-to-read shorthand for writing text for the web一个online Textile web application先生可以在艾伦的网站。

安装

下载包中提供了安装说明和文档。

升级

从以前版本的SmartyPants升级很容易Just replace your old “SmartyPants.pl” plug-in file with the new one您无需更改任何模板即可获得众多错误修复的好处(但是,如果您希望使用新的en-em-dash快捷方式,则需要更改模板。)

Why?

因为正确的印刷标点看起来很尖锐。

为什么不?

首先,你可能不在乎。

Most normal, mentally stable individuals do not take notice of proper typographic punctuationMany design and typography nerds, however, break out in a nasty rash when they encounter, say, a restaurant sign that uses a straight apostrophe to spell “Joe’s”.

If you’re the sort of person who just doesn’t care, you might well want to continue not caringUsing straight quotes — and sticking to the 7-bit ASCII character set in general — is certainly a simpler way to live.

即使你care about accurate typography, you still might want to think twice before educating the quote characters in your weblogOne side effect of publishing curly quote HTML entities is that it makes your weblog a bit harder for others to quote from using copy-and-paste. What happens is that when they copy text from your blog, they copy the 8-bit curly quote characters (as well as the 8-bit characters for em-dashes and ellipses, if you use these options)These characters are not standard across different text encoding methods, which is why they need to be encoded as HTML entities.

People copying text from your weblog, however, may not notice that you’re using curly quotes, and they’ll go ahead and paste the unencoded 8-bit characters copied from their browser into an email message or their own weblogWhen pasted as raw “smart quotes”, these characters are likely to get mangled beyond recognition.

That said, my own opinion is that any decent text editor or email client should be able to stupefy smart quote characters into their 7-bit equivalents, and I don’t consider it my problem if you’re using an indecent text editor or email client.

算法缺点

One situation in which quotes will get curled the wrong way is when apostrophes are used at the start of leading contractions例如:

'圣诞节前一天晚上。

In the case above, SmartyPants will turn the apostrophe into an opening single-quote, when in fact it should be a closing oneI don’t think this problem can be solved in the general case — every word processor I’ve tried gets this wrong as wellIn such cases, it’s best to use the proper HTML entity for closing single-quotes (&#8217;要么&rsquo的;) by hand, or to use the raw UTF-8 quote character ( ’ ).

错误

If the bug involves quotes being curled the wrong way, please send example text to illustrate.

也可以看看

该插件有效地废弃了记录的技术这里

However, the above instructions may still be of interest if for some reason you are still running an older version of Movable Type.

版本历史

1。5。1:2004年3月12日星期五

  • Fixed a goof where if you had SmartyPants 1.5.0 installed, but didn’t have Markdown installed, when SmartyPants checked for Markdown’s presence, it created a blank entry in MT’s global hash of installed text filtersThis showed up in MT’s Text Formatting pop-up menu as a blank entry.

1。5:2004年3月9日星期二

  • SmartyPants现在具有自动集成功能降价, my new text formatting plug-inIf Markdown and SmartyPants are both installed as Movable Type plug-ins, SmartyPants will add a new global text filter, “Markdown With Smartypants”.

  • 初步命令行选项解析See the POD documentation for details, if you're into this sort of thing.

  • dot-space-dot-space-dot now counts as an ellipsis. This is the style used by Project Gutenberg:http://www.gutenberg.net/faq/index.shtml#V.110
    (感谢Fred Condo的补丁。)

  • 添加<数学>到要跳过的标签列表(前置,代码等)。

1.4.1:2003年11月8日星期六

  • The bug fix from 1.4 for dashes followed by quotes with no intervening spaces now actually works.

  • “&nbsp;”现在在必要时计为空格(Thanks to Greg Knauss for the patch.)

1.4:2003年6月30日星期一

  • Improved the HTML tokenizer so that it will parse nested <> pairs up to five levels deepPreviously, it only parsed up to two levelsWhat we *should* do is allow for any arbitrary level of nesting, but to do so, we would need to use Perl’s ?? construct (see Fried’s “Mastering Regular Expressions”, 2nd Ed., pp. 328-331), and sadly, this would only work in Perl 5.6 or later. SmartyPants still supports Perl 5.00503I suppose we could test for the version and build a regex accordingly, but I don’t think I want to maintain two separate patterns.

  • 感谢Stepan Riha,tokenizer现在处理HTML注释:

    <! - 评论 - >

    和PHP风格的处理器指令:

    <?php code?>
  • The quote educator now handles situations where dashes are used without whitespace, e.g.:

    "dashes"--without spaces--"are tricky"
  • Special case for decade abbreviations like this: the ’80s. This only works for the sequence apostrophe-digit-digit-s.

1。3:2003年5月14日星期三

  • Plugged the biggest hole in SmartyPants’s smart quotes algorithm. Previous versions were hopelessly confused by single-character quote tokens, such as:

    <P> “的<i>棘手!</ I>”</ P>

    The problem was that the EducateQuotes() function works on each token separately, with no means of getting surrounding context from the previous or next tokensThe solution is to curl these single-character quote tokens as a special case,之前calling EducateQuotes().

  • 新的单引号反引模式聪明小子attribute. The only way to turn it on is to include “B” in the configuration string, e.g翻译反引号,短划线和省略号:

    smarty_pants = “BDE”
  • Fixed a bug where an opening quote would get curled the wrong way if the quote started with three dots, e.g.:

    <P> “......同时”</ P>
  • Fixed a bug where opening quotes would get curled the wrong way if there were double sets of quotes within each other, e.g.:

    <p>“'有些'人。”</ p>
  • Due to popular demand, four consecutive dots (....) will now be turned into an ellipsis followed by a periodPrevious versions would turn this into a period followed by an ellipsisIf you really want a period-then-ellipsis sequence, escape the first period with a backslash:\ ....

  • Removed “&” from our home-grown punctuation class, since it denotes an entity, not a literal ampersand punctuation characterThis fixes a bug where SmartyPants would mis-curl the opening quote in something like this:

    "&#8230;whatever"
  • SmartyPants has always had a special case where it looks for ““在这种情况下:

    卡斯特</ i>的最后一战

    这种特殊情况现在不区分大小写。

1.2.2:2003年3月13日星期四

  • 1.2.1 contained a boneheaded addition which prevented SmartyPants from compiling under Perl 5.005This has been remedied, and is the only change from 1.2.1.

1.2.1:2003年3月11日星期二

  • smarty_pants属性的新“stupefy模式”如果你设置

    smarty_pants = “ - 1”

    SmartyPants will perform reverse transformations, turning HTML entities into plain ASCII equivalents例如curly quotes are turned into a simple double-quote ("), “—” is turned into two dashes, etcThis is useful if you are using SmartyPants from Brad Choate’s MT-Textile text filter, but wish to suppress smart punctuation in specific MT templates, such as RSS feedsText filters do their work before templates are processed; but you can usesmarty_pants = “ - 1”to reverse the transformations in specific templates.

  • 替换了POSIX样式的正则表达式字符类[:PUNCT:]with an ugly hard-coded normal character class of all punctuation; POSIX classes require Perl 5.6 or later, but SmartyPants still supports back to 5.005.

  • Several small changes to allow SmartyPants to work when Blosxom is running in static mode.

1.2:2003年2月27日星期四

  • SmartyPants is now a combination plug-in, supporting both Movable Type (2.5 or later) and Blosxom (2.0 or later). It also works as a BBEdit text filter and standalone command-line Perl programThanks to Rael Dornfest for the initial Blosxom port (and for the excellent Blosxom plug-in API).

  • SmartyPants now accepts the following backslash escapes, to force non-smart punctuationIt does so by transforming the escape sequence into a decimal-encoded HTML entity:

    Escape  Value  Character
    ------  -----  ---------
      \\    \    \
      \"    "    "
      \'    '    '
      \.
      \-    -    -
      \`    `    `

    Note that this could produce different results than previous versions of SmartyPants, if for some reason you have an entry containing one or more of these sequences(Thanks to Charles Wiltgen for the suggestion.)

  • Added a new option to support inverted en- and em-dash notation: “-“对于em-dashes,”---“对于en-dashesThis is compatible with SmartyPants’ original “-” syntax for em-dashes, but also allows you to specify en-dashesIt can be invoked by usingsmart_dashes = “3”smarty_pants = “3”, 要么smarty_pants = “i” 的(Aaron Swartz建议。)

  • 添加了一个自动转换的新选项&QUOT;entities into regular double-quotes before educating quotesThis is mainly for the benefit of people who write posts using Dreamweaver, which substitutes this entity for any literal quote charThe one and only way to invoke this option is to use the letter shortcuts for the聪明小子attribute; the shortcut for this option is “w” (for Dream_w_eaver)(Suggested by Jonathon Delacour.)

  • 添加<SCRIPT>到SmartyPants不接触内容的标签列表。

  • Fixed a very subtle bug that would occur if a quote was the very last character in a body of text, preceded immediately by a tag. Lacking any context, previous versions of SmartyPants would turn this into an opening quote markIt’s now correctly turned into a closing one.

  • Opening quotes were being curled the wrong way when the subsequent character was punctuation例如:“一个'.foo'文件”. Fixed.

  • 新MT全局模板标记:<$ MTSmartyPantsVersion $>. Prints the version number of SmartyPants, e.g“1.2”。

1.1:2003年2月5日星期三

  • smart_dashestemplate属性现在提供了一个使用“ - ”的选项破折号,和“---”代表EM破折号。

  • 默认值smart_dashesbehavior now simply translates “—” (dash dash) into an em-dash以前,它会寻找“ - ”(空间破折号空间),这是愚蠢的,因为许多人不会在他们的破折号周围使用空格。

  • 使用聪明小子值为“2”的属性将执行相同的操作smarty_pants = “1”,有一点不同:它将使用新的快捷方式用于en-em和em-dashes。

  • 在这样的情况下,关闭引号(单引号和双引号)被错误地卷曲:

    “<A> FOO </A>”

    逗号可以是任何标点符号固定。

  • 添加<KBD>到不应该教育文本的标签列表。

1。0:2002年11月13日星期三

初始发行。

额外的积分

Portions of this plug-in are based on Brad Choate’s nifty MTRegex plug-inBrad Choate also contributed a few bits of source code to this plug-in.布拉德乔特确实是一个优秀的黑客。

杰里米·赫德利查尔斯威尔特根值得一提的是模范beta测试。

Rael Dornfest将SmartyPants移植到Blosxom。

Don Haring,Jr。画了SmartyPants吉祥物。

版权所有©2003约翰格鲁伯
版权所有。

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 disclaimedIn 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.

版权所有©2004 John Gruber。