AoBane 0.1.11 → 0.1.12

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/README.md CHANGED
@@ -139,6 +139,38 @@ the first line [foo]{#bar} and this table, expands HTML as below:<br>
139
139
  The "#bar" is adapted to table id, and "foo" is surrounded by &lt;captin&gt; and &lt;/caption&gt; as elements in following table. When you put caption to a table, you should write `[Table 1](#Table1)` somewhere in your Markdown. So, you can jump to a table from the link. <br>
140
140
  Of course, you can omit this.
141
141
 
142
+ <h2> 2.7 Abbreviation </h2>
143
+ Especially for not ASCII languagers, I need to study some more, perhaps about morphorogical analysis. So, if you use this function, you have to be careful.
144
+
145
+ This function is implementation of [Abbreviations](http://michelf.ca/projects/php-markdown/extra/#abbr) specifies in PHP Markdown Extra. And my some Idea which can make a UTF-8 textfile as other file definitions of abbreviation is implemented. In this case, Markdown is wrote like this:
146
+ <pre><code>
147
+ {abbrnote:./dicSample.txt}
148
+ ......
149
+ </code></pre>
150
+ And dicSample.txt in same directory with Markdown&mdash;you can name as you like&mdash;is like below:
151
+ <pre><code>
152
+ *[foo1]:bar
153
+ *[foo2]:barbar
154
+ *[foo3]:barbarbar
155
+ ......
156
+ </code></pre>
157
+ Because I set as this, you can create individual word set about your each Markdown files.And you may write like as:
158
+ <pre><code>
159
+ {abbrnote:../share/dicSample.txt}
160
+ ......
161
+ *[foo0]:foo
162
+ </code></pre>
163
+ And ../share/dicSample.txt is
164
+ <pre><code>
165
+ *[foo1]:bar
166
+ *[foo2]:barbar
167
+ *[foo3]:barbarbar
168
+ ......
169
+ </code></pre>
170
+ If You created files like this, you can controll a word set. For instance, foo0 is adapted only the above Markdown file, and foo1, foo2, foo3,...is adopted all Markdown files which is wrote <code>{abbrnote:../share/dicSample.txt}</code>.
171
+
172
+ Of course, you can use like PHP Markdown Extra. Incidentally,this function is not implemented on BlueFeather.
173
+
142
174
  ##How to Install
143
175
  Just try
144
176
  `sudo gem install AoBane`
@@ -14,7 +14,55 @@ module Utilities
14
14
  $MAX_H = 6
15
15
  @@log = Logger.new(STDOUT)
16
16
  @@log.level = Logger::WARN
17
+ ###Abbreviation proccessing##########################################################
18
+ AbbrHashTable = Hash::new
19
+ AbbrPattern = '\*\[(.+?)\]:(.*)\s*$'
20
+ def abbrPreProcess(text)
21
+ output = ''
22
+ if text.nil? then return '' end
23
+ text.lines{ |line|
24
+ if line =~ /\{abbrnote:(.+?)\}/i then #1
25
+ p "*****"
26
+ if $1.nil? then '' #1.5
27
+ else
28
+ File::open($1){|file| #2
29
+ file.each{|line| #3
30
+ if /^#.*\n/ =~ line then
31
+ next
32
+ elsif /#{AbbrPattern}/ =~ line
33
+ storeAbbr($1,$2)
34
+ end
35
+ } #3
36
+ }
37
+
38
+ end #1.5
39
+ elsif line =~ /#{AbbrPattern}/ then
40
+ @@log.debug $~
41
+ storeAbbr($1,$2)
42
+ else output << line
43
+ end #
44
+ }
45
+
46
+ @@log.debug AbbrHashTable
47
+ return output
48
+ end #def
49
+
50
+ def storeAbbr(key,val)
51
+ val = if val.nil? then '' else val end
52
+ AbbrHashTable.store(key,val)
53
+ end
17
54
 
55
+ def abbrPostProcess(text)
56
+ if AbbrHashTable.size == 0 then return text
57
+ else
58
+ keywords = AbbrHashTable.keys.join('|')
59
+ text.gsub!(/(#{keywords})/){
60
+ word = if $1.nil? then '' else $1 end
61
+ '<abbr title="' + AbbrHashTable[word] +'">' + word + '</abbr>'
62
+ }
63
+ return text
64
+ end
65
+ end
18
66
  ###paling proccessing##########################################################
19
67
  StartDivMark =
20
68
  '\|\-:b=(\d+?)\s(\w+?\s\w+?\s)' +
@@ -125,7 +173,10 @@ end #def postPailing
125
173
  times = startNo.to_i + size.to_i - 1
126
174
  return h*times + number + str
127
175
  end #def
128
-
176
+
177
+ module_function :abbrPreProcess
178
+ module_function :abbrPostProcess
179
+ module_function :storeAbbr
129
180
  module_function :calcSectionNo
130
181
  module_function :prePaling
131
182
  module_function :isDigit
@@ -1,3 +1,3 @@
1
1
  module AoBane
2
- VERSION = "0.1.11"
2
+ VERSION = "0.1.12"
3
3
  end
data/lib/AoBane.rb CHANGED
@@ -51,9 +51,9 @@ require 'AoBane/utilities'
51
51
  require 'math_ml/string'
52
52
 
53
53
  module AoBane
54
- VERSION = '0.1.11'
55
- VERSION_NUMBER = 0.0111
56
- RELEASE_DATE = '2013-04-20'
54
+ VERSION = '0.1.12'
55
+ VERSION_NUMBER = 0.0112
56
+ RELEASE_DATE = '2013-04-21'
57
57
  VERSION_LABEL = "#{VERSION} (#{RELEASE_DATE})"
58
58
 
59
59
  UTF8_BOM = "\xef\xbb\xbf"
@@ -534,7 +534,8 @@ module AoBane
534
534
  }
535
535
  #Insert by set.minami 2013-04-13
536
536
  text = Utilities::prePaling(text)
537
-
537
+ #Insert by set.minami 2013-04-21
538
+ text = Utilities::abbrPreProcess(text)
538
539
  #Insert by set.minami 2013-04-01
539
540
  text.gsub!(/\\TeX\{(.+?)\\TeX\}/){
540
541
  begin
@@ -657,7 +658,8 @@ module AoBane
657
658
 
658
659
  #Insert by Set.Minami 2013-04-13
659
660
  text = Utilities::postPaling(text)
660
-
661
+ #Insert by set.minami 2013-04-21
662
+ text = Utilities::abbrPostProcess(text)
661
663
  #Insert by set.minami 2013-03-30
662
664
  #output = text.split("\n")
663
665
  specialChar = {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: AoBane
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.11
4
+ version: 0.1.12
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-20 00:00:00.000000000 Z
12
+ date: 2013-04-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: math_ml