typohero 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +1 -0
- data/README.md +36 -11
- data/latex.pl +11 -4
- data/lib/typohero/latex.rb +538 -533
- data/lib/typohero/version.rb +1 -1
- data/lib/typohero.rb +180 -64
- data/test/typohero_test.rb +171 -128
- data/typohero.gemspec +1 -1
- metadata +2 -3
- data/bench/bench.txt +0 -16413
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e1601fa507395ff5380983659eb920e745028be
|
4
|
+
data.tar.gz: 9d4b8a981513c84ed843cdacc24956839ca18959
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bcb638d198532592fafe7dede571f585c70d430b64a2a5814bcddadddda4955943c3db9f83caf216b4bfcb692d9c0c1109098b00c9085138c24de773e3d97b8a
|
7
|
+
data.tar.gz: c1e3e1f076b1cf66c12c6263de789c2d0ab755a020f436fb5b282205aab1773f6832f98ce8bea8541f0f6f90be15533f301b13e06b418f40a290d1c60b8d69a4
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,26 +1,35 @@
|
|
1
1
|
# TypoHero
|
2
2
|
|
3
|
-
TypoHero
|
3
|
+
TypoHero has come to enhance your typography. There are no options, there is no documentation. He knows what you need.
|
4
4
|
|
5
5
|
~~~ ruby
|
6
6
|
require 'typohero'
|
7
7
|
TypoHero.enhance('Some text...')
|
8
|
+
TypoHero.truncate('Long text with tags...', max_words_or_separator)
|
9
|
+
TypoHero.strip_tags('Text with tags...')
|
8
10
|
~~~
|
9
11
|
|
10
12
|

|
11
13
|
|
12
14
|
## Features
|
13
15
|
|
14
|
-
*
|
15
|
-
*
|
16
|
-
*
|
17
|
-
*
|
18
|
-
*
|
19
|
-
|
20
|
-
|
21
|
-
*
|
22
|
-
|
23
|
-
|
16
|
+
* `TypoHero.enhance` - Typography enhancer
|
17
|
+
* Special character treatment for quotes, dashes and ellipsis
|
18
|
+
* Widon't with Unicode non-breaking space
|
19
|
+
* Skips special tags like `<script>`
|
20
|
+
* Styling enhancements
|
21
|
+
* Captial letters are wrapped in `<span class="caps">`
|
22
|
+
* Initial quotes are wrapped in `<span class="quo">`
|
23
|
+
* Ampersands are wrapped in `<span class="amp">`
|
24
|
+
* Ordinals are wrapped in `<span class="ord">`
|
25
|
+
* Hyphenated words are wrapped in `<span class="nobr">`
|
26
|
+
* LaTeX support
|
27
|
+
* Some LaTeX commands are replaced by their Unicode counterpart
|
28
|
+
* Mathjax code is skipped
|
29
|
+
* `TypoHero.truncate` - Truncate which ensures that all tags are closed correctly
|
30
|
+
* Supports maximum number of words and/or separator `String`/`Regexp`
|
31
|
+
* `TypoHero.strip_tags` - Strip tags from content, keep only text
|
32
|
+
* All methods keeps the string `html_safe?`
|
24
33
|
|
25
34
|
## Why?
|
26
35
|
|
@@ -38,6 +47,22 @@ But why not improve the existing libraries?
|
|
38
47
|
* Typogrify is Python
|
39
48
|
* Fast-Aleck is C, but I don't want to use C since Ruby is already a perfect text processing language!
|
40
49
|
|
50
|
+
## Similar libraries
|
51
|
+
|
52
|
+
[Smartypants (Perl)](http://daringfireball.net/projects/smartypants/),
|
53
|
+
[Typogrify (Python)](https://github.com/mintchaos/typogrify),
|
54
|
+
[Typography-Helper (Ruby)](https://code.google.com/p/typography-helper/),
|
55
|
+
[RubyPants (Ruby)](http://chneukirchen.org/repos/rubypants/),
|
56
|
+
[Tyogruby (Ruby)](http://avdgaag.github.io/typogruby/),
|
57
|
+
[Typography (Ruby)](https://github.com/fxposter/typography),
|
58
|
+
[Typographer (Ruby)](https://github.com/Slotos/typographer),
|
59
|
+
[Typogrify (Ruby)](http://rubygems.org/gems/typogrify),
|
60
|
+
[Typogrowth (Ruby)](https://github.com/mudasobwa/typogrowth),
|
61
|
+
[Typogr.js (Javascript)](https://github.com/ekalinin/typogr.js/blob/master/typogr.js),
|
62
|
+
[Richtypo.js (Javascript)](https://github.com/sapegin/richtypo.js),
|
63
|
+
[List of javascript typography libraries](https://github.com/yumyo/js-type-master)
|
64
|
+
...
|
65
|
+
|
41
66
|
## License
|
42
67
|
|
43
68
|
~~~
|
data/latex.pl
CHANGED
@@ -5,12 +5,19 @@ my %WORDMAC = ( %WORDMACROS, %WORDMACROSEXTRA, %PUNCTUATION, %SYMBOLS,
|
|
5
5
|
%GREEK );
|
6
6
|
|
7
7
|
print "module TypoHero\n LATEX = {\n";
|
8
|
-
foreach (keys(%WORDMAC)) {
|
8
|
+
foreach (sort(keys(%WORDMAC))) {
|
9
|
+
# Hack: Don't distinguish variants
|
10
|
+
if (/^var/) {
|
11
|
+
my $x = $';
|
12
|
+
my $v = sprintf('\\u%04x', ord($WORDMAC{$_}));
|
13
|
+
print " '\\$x' => \"$v\",\n";
|
14
|
+
}
|
9
15
|
my $v = sprintf('\\u%04x', ord($WORDMAC{$_}));
|
10
|
-
print "
|
16
|
+
print " '\\$_' => \"$v\",\n";
|
11
17
|
}
|
12
|
-
foreach (keys(%NEGATEDSYMBOLS)) {
|
18
|
+
foreach (sort(keys(%NEGATEDSYMBOLS))) {
|
13
19
|
my $v = sprintf('\\u%04x', ord($NEGATEDSYMBOLS{$_}));
|
14
|
-
print "
|
20
|
+
print " '\\not\\$_' => \"$v\",\n";
|
15
21
|
}
|
22
|
+
|
16
23
|
print " }\nend\n";
|