gilenson 1.0.5 → 1.1.0

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.
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ === 1.1.0 / 2010-08-15
2
+
3
+ * Модули для интеграции с различными форматтерами теперь живут прямо тут а не в rutils.
4
+
1
5
  === 1.0.5 / 2010-08-15
2
6
 
3
7
  * Гиленсон теперь сервируется отдельным блюдом. История изменений ниже по тексту взята из rutils.
data/Manifest.txt CHANGED
@@ -4,5 +4,14 @@ Manifest.txt
4
4
  README.txt
5
5
  Rakefile
6
6
  bin/gilensize
7
+ lib/extras/bluecloth_extra.rb
8
+ lib/extras/maruku_extra.rb
9
+ lib/extras/rdiscount_extra.rb
10
+ lib/extras/redcloth_extra.rb
7
11
  lib/gilenson.rb
8
12
  test/test_gilenson.rb
13
+ test/test_integration_bluecloth.rb
14
+ test/test_integration_maruku.rb
15
+ test/test_integration_rdiscount.rb
16
+ test/test_integration_redcloth3.rb
17
+ test/test_integration_redcloth4.rb
data/README.txt CHANGED
@@ -8,6 +8,8 @@
8
8
  Посвящается П.Г.Гиленсону[http://www.rudtp.ru/lib.php?book=172], благодаря которому русские правила тех.
9
9
  редактуры еще как минимум 20 лет останутся бессмысленно старомодными.
10
10
 
11
+ Разработчики gilenson - {Julik}[http://julik.nl], {Mash}[http://imfo.ru], {Yaroslav Markin}[http://markin.net/]
12
+
11
13
  == ФУНКЦИИ
12
14
 
13
15
  Gilenson расставит в тексте "умные" правильные кавычки (русские - для кириллицы, английские - для латиницы),
@@ -88,6 +90,19 @@ Gilenson базируется на коде Typografica[http://pixel-apes.com/ty
88
90
 
89
91
  * sudo gem install gilenson
90
92
 
93
+ == ИНТЕГРАЦИЯ С ДРУГИМИ ФОРМАТТЕРАМИ
94
+
95
+ Если вы используете RuTils в одном приложении со стандартными форматтерами (RedCloth, BlueCloth...) воспользуйтесь
96
+ дополнительными модулями которые выводят отформатированный Гиленсоном результат работы форматтеров, но при этом следят
97
+ чтобы эти форматтеры не портили текст неподобающим образом (не расставляли неправильные кавычки и так далее).
98
+
99
+ Gilenson определяет следующие дополнительные форматтеры (они работают так же как и их базовые классы)
100
+
101
+ * Gilenson::RedClothExtra
102
+ * Gilenson::BlueClothExtra
103
+ * Gilenson::RDiscountExtra
104
+ * Gilenson::MarukuExtra
105
+
91
106
  == ЛИЦЕНЗИЯ:
92
107
 
93
108
  (The MIT License)
@@ -0,0 +1,7 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # BlueCloth с поддержкой Gilenson
3
+ class Gilenson::BlueClothExtra < BlueCloth
4
+ def to_html(*opts)
5
+ ::Gilenson.new(super(*opts)).to_html
6
+ end
7
+ end
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # Maruku с поддержкой Gilenson
3
+ class Gilenson::MarukuExtra < Maruku
4
+ def to_html(*anything)
5
+ suspended = super
6
+
7
+ # Return quotes to original state
8
+ [187, 171, 8220, 8221].map do |e|
9
+ suspended.gsub!( /&\##{e};/, '"')
10
+ end
11
+
12
+ # Return spaces to original state
13
+ [160].map do |e|
14
+ suspended.gsub!( /&\##{e};/, ' ')
15
+ end
16
+
17
+ suspended.gilensize
18
+ end
19
+ end
@@ -0,0 +1,7 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # RDiscount с поддержкой Gilenson
3
+ class Gilenson::RDiscountExtra < RDiscount
4
+ def to_html(*opts)
5
+ ::Gilenson.new(super(*opts)).to_html
6
+ end
7
+ end
@@ -0,0 +1,42 @@
1
+ # -*- encoding: utf-8 -*-
2
+ if RedCloth.class == Module
3
+ # RedCloth 4 - частичная поддержка
4
+ class Gilenson::RedClothExtra < RedCloth::TextileDoc
5
+ def to_html(*anything)
6
+ suspended = super(*anything)
7
+
8
+ # Return quotes to original state
9
+ [187, 171, 8220, 8221].map do |e|
10
+ suspended.gsub!(/&\##{e};/, '"')
11
+ end
12
+
13
+ # Return spaces to original state
14
+ [160].map do |e|
15
+ suspended.gsub!(/&\##{e};/, ' ')
16
+ end
17
+
18
+ suspended.gilensize
19
+ end
20
+ end
21
+ else
22
+ # RedCloth 3 - RuTils выполняет перегрузку Textile Glyphs в RedCloth, перенося форматирование спецсимволов на Gilenson.
23
+ # Применять как стандартный RedCloth
24
+ # RuTils::Gilenson::RedClothExtra.new(some_text).to_html
25
+ class Gilenson::RedClothExtra < RedCloth
26
+ # Этот метод в RedCloth при наличии Гиленсона становится заглушкой
27
+ def htmlesc(text, mode=0)
28
+ text
29
+ end
30
+
31
+ # А этот метод обрабатывает Textile Glyphs - ту самую типографицу.
32
+ # Вместо того чтобы влезать в чужие таблицы мы просто заменим Textile Glyphs на Gilenson - и все будут рады.
33
+ def pgl(text) #:nodoc:
34
+ # Подвешиваем пробелы в начале и в конце каждого блока. Тряпка требует чтобы эти пробелы приехали
35
+ # назад нетронутыми.
36
+ spaces = Array.new(2,'')
37
+ text.gsub!(/\A([\s]+)/) { spaces[0] = $1; '' }
38
+ text.gsub!(/(\s+)\Z/) { spaces[1] = $1; '' }
39
+ text.replace(spaces[0].to_s + ::Gilenson.new(text).to_html + spaces[1].to_s)
40
+ end
41
+ end
42
+ end
data/lib/gilenson.rb CHANGED
@@ -1,5 +1,10 @@
1
1
  class Gilenson
2
- VERSION = '1.0.5'
2
+ VERSION = '1.1.0'
3
+ autoload :BlueClothExtra, File.dirname(__FILE__) + '/extras/bluecloth_extra'
4
+ autoload :RedClothExtra, File.dirname(__FILE__) + '/extras/redcloth_extra'
5
+ autoload :RDiscountExtra, File.dirname(__FILE__) + '/extras/rdiscount_extra'
6
+ autoload :MarukuExtra, File.dirname(__FILE__) + '/extras/maruku_extra'
7
+
3
8
  attr_accessor :glyph
4
9
  attr_accessor :settings
5
10
 
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+ begin
3
+ require 'bluecloth'
4
+
5
+ # Интеграция с BlueCloth - Markdown
6
+ # Сам Markdown никакой обработки типографики не производит (это делает RubyPants, но вряд ли его кто-то юзает на практике)
7
+ class BlueclothIntegrationTest < Test::Unit::TestCase
8
+ C = Gilenson::BlueClothExtra
9
+
10
+ def test_integration_markdown
11
+ assert_equal "<p>И вот&#160;&#171;они пошли туда&#187;, и&#160;шли шли&#160;шли</p>",
12
+ C.new('И вот "они пошли туда", и шли шли шли').to_html
13
+ end
14
+ end
15
+ rescue LoadError => boom
16
+ STDERR.puts(boom.message)
17
+ end
@@ -0,0 +1,18 @@
1
+ # -*- encoding: utf-8 -*-
2
+ begin
3
+ require 'maruku'
4
+
5
+ # Интеграция с Maruku - Markdown
6
+ class MarukuIntegrationTest < Test::Unit::TestCase
7
+ C = Gilenson::MarukuExtra
8
+
9
+ def test_integration_maruku
10
+
11
+ assert_equal "<p>И вот&#160;&#171;они пошли туда&#187;, и&#160;шли шли&#160;шли</p>",
12
+ C.new('И вот "они пошли туда", и шли шли шли').to_html
13
+
14
+ end
15
+ end
16
+ rescue LoadError => boom
17
+ STDERR.puts(boom.message)
18
+ end
@@ -0,0 +1,18 @@
1
+ # -*- encoding: utf-8 -*-
2
+ begin
3
+ require 'rdiscount'
4
+
5
+ # Интеграция с Rdiscount - Markdown
6
+ # Сам Markdown никакой обработки типографики не производит (это делает RubyPants, но вряд ли его кто-то юзает на практике)
7
+ class RdiscountIntegrationTest < Test::Unit::TestCase
8
+ C = Gilenson::RDiscountExtra
9
+
10
+ def test_integration_markdown
11
+
12
+ assert_equal "<p>И вот&#160;&#171;они пошли туда&#187;, и&#160;шли шли&#160;шли</p>",
13
+ C.new('И вот "они пошли туда", и шли шли шли').to_html
14
+ end
15
+ end
16
+ rescue LoadError => boom
17
+ STDERR.puts(boom.message)
18
+ end
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ begin
3
+ require 'redcloth'
4
+ raise LoadError, "need RedCloth 3.x" unless RedCloth::VERSION.to_s =~ /^3/
5
+
6
+ # Интеграция с RedCloth - Textile.
7
+ # Нужно иметь в виду что Textile осуществляет свою обработку типографики, которую мы подменяем!
8
+ class Redcloth3IntegrationTest < Test::Unit::TestCase
9
+ C = Gilenson::RedClothExtra
10
+ def test_integration_with_redcloth_3
11
+
12
+ assert_equal "<p>И&#160;вот &#171;они пошли туда&#187;, и&#160;шли шли&#160;шли</p>",
13
+ C.new('И вот "они пошли туда", и шли шли шли').to_html
14
+
15
+ assert_equal '<p><strong>strong text</strong> and <em>emphasized text</em></p>',
16
+ C.new("*strong text* and _emphasized text_").to_html,
17
+ "Spaces should be preserved"
18
+ end
19
+ end
20
+ rescue LoadError => boom
21
+ STDERR.puts(boom.message)
22
+ end
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ begin
3
+ require 'redcloth'
4
+ raise LoadError, "need RedCloth 4.x" unless RedCloth::VERSION.to_s =~ /^4/
5
+
6
+ # Интеграция с RedCloth 4 - Textile.
7
+ class Redcloth4IntegrationTest < Test::Unit::TestCase
8
+ C = Gilenson::RedClothExtra
9
+
10
+ def test_integration_with_redcloth_4
11
+
12
+ assert_equal "<p>И вот&#160;&#171;они пошли туда&#187;, и&#160;шли шли&#160;шли</p>",
13
+ C.new('И вот "они пошли туда", и шли шли шли').to_html
14
+
15
+ assert_equal '<p><strong>strong text</strong> and&#160;<em>emphasized text</em></p>',
16
+ C.new("*strong text* and _emphasized text_").to_html,
17
+ "Spaces should be preserved"
18
+
19
+ end
20
+ end
21
+ rescue LoadError => boom
22
+ STDERR.puts(boom.message)
23
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gilenson
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
+ - 1
8
9
  - 0
9
- - 5
10
- version: 1.0.5
10
+ version: 1.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Julik Tarkhanov
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-15 00:00:00 +02:00
18
+ date: 2010-08-16 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -42,17 +42,18 @@ dependencies:
42
42
  requirements:
43
43
  - - ">="
44
44
  - !ruby/object:Gem::Version
45
- hash: 23
45
+ hash: 21
46
46
  segments:
47
47
  - 2
48
48
  - 6
49
- - 0
50
- version: 2.6.0
49
+ - 1
50
+ version: 2.6.1
51
51
  type: :development
52
52
  version_requirements: *id002
53
53
  description: "\xD0\x9E\xD0\xB1\xD1\x80\xD0\xB0\xD0\xB1\xD0\xBE\xD1\x82\xD1\x87\xD0\xB8\xD0\xBA \xD1\x82\xD0\xB8\xD0\xBF\xD0\xBE\xD0\xB3\xD1\x80\xD0\xB0\xD1\x84\xD1\x81\xD0\xBA\xD0\xB8\xD1\x85 \xD1\x81\xD0\xB8\xD0\xBC\xD0\xB2\xD0\xBE\xD0\xBB\xD0\xBE\xD0\xB2 \xD0\xB2 HTML \xD1\x81\xD0\xBE\xD0\xB3\xD0\xBB\xD0\xB0\xD1\x81\xD0\xBD\xD0\xBE \xD0\xBE\xD0\xB1\xD1\x89\xD0\xB5\xD0\xBF\xD1\x80\xD0\xB8\xD0\xBD\xD1\x8F\xD1\x82\xD1\x8B\xD0\xBC \xD0\xBF\xD1\x80\xD0\xB0\xD0\xB2\xD0\xB8\xD0\xBB\xD0\xB0\xD0\xBC.\n\
54
54
  \xD0\x9F\xD0\xBE\xD1\x81\xD0\xB2\xD1\x8F\xD1\x89\xD0\xB0\xD0\xB5\xD1\x82\xD1\x81\xD1\x8F \xD0\x9F.\xD0\x93.\xD0\x93\xD0\xB8\xD0\xBB\xD0\xB5\xD0\xBD\xD1\x81\xD0\xBE\xD0\xBD\xD1\x83[http://www.rudtp.ru/lib.php?book=172], \xD0\xB1\xD0\xBB\xD0\xB0\xD0\xB3\xD0\xBE\xD0\xB4\xD0\xB0\xD1\x80\xD1\x8F \xD0\xBA\xD0\xBE\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1\x80\xD0\xBE\xD0\xBC\xD0\xBE\xD0\xB4\xD0\xBD\xD1\x8B\xD0\xBC\xD0\xB8.\n\n\
56
+ \xD0\xA0\xD0\xB0\xD0\xB7\xD1\x80\xD0\xB0\xD0\xB1\xD0\xBE\xD1\x82\xD1\x87\xD0\xB8\xD0\xBA\xD0\xB8 gilenson - {Julik}[http://julik.nl], {Mash}[http://imfo.ru], {Yaroslav Markin}[http://markin.net/]"
56
57
  email:
57
58
  - me@julik.nl
58
59
  executables:
@@ -70,8 +71,17 @@ files:
70
71
  - README.txt
71
72
  - Rakefile
72
73
  - bin/gilensize
74
+ - lib/extras/bluecloth_extra.rb
75
+ - lib/extras/maruku_extra.rb
76
+ - lib/extras/rdiscount_extra.rb
77
+ - lib/extras/redcloth_extra.rb
73
78
  - lib/gilenson.rb
74
79
  - test/test_gilenson.rb
80
+ - test/test_integration_bluecloth.rb
81
+ - test/test_integration_maruku.rb
82
+ - test/test_integration_rdiscount.rb
83
+ - test/test_integration_redcloth3.rb
84
+ - test/test_integration_redcloth4.rb
75
85
  has_rdoc: true
76
86
  homepage: http://github.com/julik/gilenson
77
87
  licenses: []
@@ -112,3 +122,8 @@ specification_version: 3
112
122
  summary: "\xD0\x9E\xD0\xB1\xD1\x80\xD0\xB0\xD0\xB1\xD0\xBE\xD1\x82\xD1\x87\xD0\xB8\xD0\xBA \xD1\x82\xD0\xB8\xD0\xBF\xD0\xBE\xD0\xB3\xD1\x80\xD0\xB0\xD1\x84\xD1\x81\xD0\xBA\xD0\xB8\xD1\x85 \xD1\x81\xD0\xB8\xD0\xBC\xD0\xB2\xD0\xBE\xD0\xBB\xD0\xBE\xD0\xB2 \xD0\xB2 HTML \xD1\x81\xD0\xBE\xD0\xB3\xD0\xBB\xD0\xB0\xD1\x81\xD0\xBD\xD0\xBE \xD0\xBE\xD0\xB1\xD1\x89\xD0\xB5\xD0\xBF\xD1\x80\xD0\xB8\xD0\xBD\xD1\x8F\xD1\x82\xD1\x8B\xD0\xBC \xD0\xBF\xD1\x80\xD0\xB0\xD0\xB2\xD0\xB8\xD0\xBB\xD0\xB0\xD0\xBC"
113
123
  test_files:
114
124
  - test/test_gilenson.rb
125
+ - test/test_integration_bluecloth.rb
126
+ - test/test_integration_maruku.rb
127
+ - test/test_integration_rdiscount.rb
128
+ - test/test_integration_redcloth3.rb
129
+ - test/test_integration_redcloth4.rb