glaemscribe 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,234 @@
1
+ \**
2
+
3
+ Glǽmscribe (also written Glaemscribe) is a software dedicated to
4
+ the transcription of texts between writing systems, and more
5
+ specifically dedicated to the transcription of J.R.R. Tolkien's
6
+ invented languages to some of his devised writing systems.
7
+
8
+ Copyright (C) 2015 Benjamin Babut (Talagan).
9
+
10
+ This program is free software: you can redistribute it and/or modify
11
+ it under the terms of the GNU Affero General Public License as published by
12
+ the Free Software Foundation, either version 3 of the License, or
13
+ any later version.
14
+
15
+ This program is distributed in the hope that it will be useful,
16
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ GNU Affero General Public License for more details.
19
+
20
+ You should have received a copy of the GNU Affero General Public License
21
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
22
+
23
+ **\
24
+
25
+ \beg changelog
26
+ \entry "0.0.1" "Initial version."
27
+ \end
28
+
29
+ \language "Raw Tengwar"
30
+ \writing "Tengwar"
31
+ \mode "Raw"
32
+ \version "0.0.1"
33
+ \authors "Talagan (Benjamin Babut)"
34
+
35
+ \metamode true
36
+
37
+ \charset tengwar_ds_sindarin true
38
+ \charset tengwar_ds_parmaite false
39
+ \charset tengwar_ds_eldamar false
40
+ \charset tengwar_ds_annatar false
41
+ \charset tengwar_ds_elfica false
42
+ \charset tengwar_freemono false
43
+
44
+
45
+ \beg options
46
+ \beg option consonant_modification_style CONSONANT_MODIFICATION_STYLE_BAR
47
+ \value CONSONANT_MODIFICATION_STYLE_WAVE 0
48
+ \value CONSONANT_MODIFICATION_STYLE_BAR 1
49
+ \end
50
+ \end
51
+
52
+ \beg preprocessor
53
+ \** Work exclusively downcase **\
54
+ \downcase
55
+ \end
56
+
57
+
58
+ \beg processor
59
+
60
+ \beg rules litteral
61
+
62
+ \if "consonant_modification_style == CONSONANT_MODIFICATION_STYLE_WAVE"
63
+ {GEMINATE} === GEMINATE_SIGN_TILD
64
+ {NASAL} === NASALIZE_SIGN_TILD
65
+ \else
66
+ {GEMINATE} === GEMINATE_SIGN
67
+ {NASAL} === NASALIZE_SIGN
68
+ \endif
69
+
70
+ _a_ --> A_TEHTA
71
+ _acirc_ --> A_TEHTA_CIRCUM
72
+ _arev_ --> A_TEHTA_REVERSED
73
+
74
+ _e_ --> E_TEHTA
75
+ _i_ --> I_TEHTA
76
+ _o_ --> O_TEHTA
77
+ _u_ --> U_TEHTA
78
+
79
+ _a<_ --> A_TEHTA_INF
80
+ _e<_ --> E_TEHTA_INF
81
+ _i<_ --> I_TEHTA_INF
82
+ _o<_ --> O_TEHTA_INF
83
+ _u<_ --> U_TEHTA_INF
84
+
85
+ _unutixe_ --> I_TEHTA_INF
86
+
87
+ _ee_ --> E_TEHTA_DOUBLE
88
+ _ii_ --> I_TEHTA_DOUBLE
89
+ _oo_ --> O_TEHTA_DOUBLE
90
+ _uu_ --> U_TEHTA_DOUBLE
91
+
92
+ _ee<_ --> E_TEHTA_DOUBLE_INF
93
+ _ii<_ --> I_TEHTA_DOUBLE_INF
94
+
95
+ _(tinco,tw11)_ --> TINCO
96
+ _(parma,tw12)_ --> PARMA
97
+ _(calma,tw13)_ --> CALMA
98
+ _(quesse,tw14)_ --> QUESSE
99
+
100
+ _(ando,tw21)_ --> ANDO
101
+ _(umbar,tw22)_ --> UMBAR
102
+ _(anga,tw23)_ --> ANGA
103
+ _(ungwe,tw24)_ --> UNGWE
104
+
105
+ _(sule,súle,thule,thúle,tw31)_ --> SULE
106
+ _(formen,tw32)_ --> FORMEN
107
+ _(aha,harma,tw33)_ --> AHA
108
+ _(hwesta,tw34)_ --> HWESTA
109
+
110
+ _(anto,tw41)_ --> ANTO
111
+ _(ampa,tw42)_ --> AMPA
112
+ _(anca,tw43)_ --> ANCA
113
+ _(unque,tw44)_ --> UNQUE
114
+
115
+ _(numen,númen,tw51)_ --> NUMEN
116
+ _(malta,tw52)_ --> MALTA
117
+ _(noldo,ñoldo,tw53)_ --> NOLDO
118
+ _(nwalme,ñwalme,tw54)_ --> NWALME
119
+
120
+ _(ore,óre,tw61)_ --> ORE
121
+ _(vala,tw62)_ --> VALA
122
+ _(anna,tw63)_ --> ANNA
123
+ _(vilya,wilya,tw64)_ --> VILYA
124
+
125
+ _(romen,rómen,tw71)_ --> ROMEN
126
+ _(arda,tw72)_ --> ARDA
127
+ _(lambe,tw73)_ --> LAMBE
128
+ _(alda,tw74)_ --> ALDA
129
+
130
+ _(silme,tw81)_ --> SILME
131
+ _(silmenuquerna,silmen,tw82)_ --> SILME_NUQUERNA
132
+ _(esse,tw83)_ --> ESSE
133
+ _(essenuquerna,essen,tw84)_ --> ESSE_NUQUERNA
134
+
135
+ _(hyarmen,tw91)_ --> HYARMEN
136
+ _(hwestasindarinwa,hwestas,tw92)_ --> HWESTA_SINDARINWA
137
+ _(yanta,tw93)_ --> YANTA
138
+ _(ure,úre,tw94)_ --> URE
139
+
140
+
141
+ _(osse)_ --> OSSE
142
+ _(halla)_ --> HALLA
143
+ _(vaia,vaiya)_ --> VAIA
144
+
145
+
146
+ _(mh)_ --> TW_MH
147
+ _(mhbeleriandic,mhb)_ --> TW_MH_BELERIANDIC
148
+ _(hwlowdham,hwl)_ --> TW_HW_LOWDHAM
149
+
150
+
151
+ \** ligatures **\
152
+ _(harmasilme,ahasilme,silmeharma,silmeaha)_ --> ANCA_CLOSED
153
+ _(hwestatinco,tincohwesta)_ --> HWESTA_TINCO
154
+ _(harmatinco,ahatinco,tincoharma,tincoaha)_ --> AHA_TINCO
155
+
156
+ _(telco)_ --> TELCO
157
+ _(ara,ára)_ --> ARA
158
+
159
+ _(geminate)_ --> {GEMINATE}
160
+ _(nasal)_ --> {NASAL}
161
+ _(palatal)_ --> PALATAL_SIGN
162
+
163
+ _0_ --> NUM_0
164
+ _1_ --> NUM_1
165
+ _2_ --> NUM_2
166
+ _3_ --> NUM_3
167
+ _4_ --> NUM_4
168
+ _5_ --> NUM_5
169
+ _6_ --> NUM_6
170
+ _7_ --> NUM_7
171
+ _8_ --> NUM_8
172
+ _9_ --> NUM_9
173
+ _10_ --> NUM_10
174
+ _11_ --> NUM_11
175
+
176
+ \end
177
+
178
+ \beg rules punctuation
179
+ / --> {NULL}
180
+
181
+ . --> PUNCT_DDOT
182
+ .. --> PUNCT_DOT PUNCT_DDOT PUNCT_DOT
183
+ … --> PUNCT_TILD
184
+ ... --> PUNCT_TILD
185
+ .... --> PUNCT_TILD
186
+ ..... --> PUNCT_TILD
187
+ ...... --> PUNCT_TILD
188
+ ....... --> PUNCT_TILD
189
+
190
+ , --> PUNCT_DOT
191
+ : --> PUNCT_DOT
192
+ ; --> PUNCT_DOT
193
+ ! --> PUNCT_EXCLAM
194
+ ? --> PUNCT_INTERR
195
+ · --> PUNCT_DOT
196
+
197
+ \** Apostrophe **\
198
+
199
+ ' --> {NULL}
200
+ ’ --> {NULL}
201
+
202
+ \** Quotes **\
203
+
204
+ “ --> DQUOT_OPEN
205
+ ” --> DQUOT_CLOSE
206
+ « --> DQUOT_OPEN
207
+ » --> DQUOT_CLOSE
208
+
209
+ - --> {NULL}
210
+ – --> PUNCT_TILD
211
+ — --> PUNCT_TILD
212
+
213
+ [ --> PUNCT_PAREN_L
214
+ ] --> PUNCT_PAREN_R
215
+ ( --> PUNCT_PAREN_L
216
+ ) --> PUNCT_PAREN_R
217
+ { --> PUNCT_PAREN_L
218
+ } --> PUNCT_PAREN_R
219
+ \** < --> PUNCT_PAREN_L : cannot be used since it is already used as a letter in group litteral **\
220
+ \** > --> PUNCT_PAREN_R : cannot be used since it is already used as a letter in group litteral **\
221
+
222
+ \** Not universal between fonts ... **\
223
+ $ --> BOOKMARK_SIGN
224
+ ≤ --> RING_MARK_L \** Ring inscription left beautiful stuff **\
225
+ ≥ --> RING_MARK_R \** Ring inscription right beautiful stuff **\
226
+
227
+ \end
228
+
229
+ \end
230
+
231
+ \beg postprocessor
232
+ \resolve_virtuals
233
+ \end
234
+
@@ -30,18 +30,22 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
30
30
 
31
31
  \** R'lyehian mode for glaemscribe : a non-euclidian joke, muhahahaha **\
32
32
 
33
- \language "R'lyehian"
34
- \writing Tengwar
35
- \mode Glaemscrafu
36
- \version 0.0.3
37
- \authors "H.P.Lovecraft & The Great Ancient Gods, impl. Fthalagn"
38
-
39
33
  \beg changelog
40
34
  \entry "0.0.1" "First version"
41
- \entry 0.0.2 "Ported to virtual chars"
42
- \entry 0.0.3 "Ported to various charsets"
35
+ \entry "0.0.2" "Ported to virtual chars"
36
+ \entry "0.0.3" "Ported to various charsets"
37
+ \entry "0.1.1" "Added support for inlined raw tengwar"
43
38
  \end
44
39
 
40
+
41
+ \language "R'lyehian"
42
+ \writing "Tengwar"
43
+ \mode "Glaemscrafu"
44
+ \version "0.1.1"
45
+ \authors "H.P.Lovecraft & The Great Ancient Gods, impl. Fthalagn"
46
+
47
+ \raw_mode "raw-tengwar"
48
+
45
49
  \charset tengwar_ds_sindarin true
46
50
  \charset tengwar_ds_parmaite false
47
51
  \charset tengwar_ds_eldamar false
@@ -30,14 +30,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
30
30
  \entry "0.0.5" "Added charset support for Annatar"
31
31
  \entry "0.0.6" "Added support for the FreeMonoTengwar font"
32
32
  \entry "0.1.0" "Added support for the Tengwar Elfica font"
33
+ \entry "0.1.1" "Added support for inlined raw tengwar"
33
34
  \end
34
35
 
35
36
  \language "Sindarin"
36
37
  \writing "Tengwar"
37
38
  \mode "Beleriand"
38
- \version "0.1.0"
39
+ \version "0.1.1"
39
40
  \authors "J.R.R. Tolkien, impl. Talagan (Benjamin Babut)"
40
41
 
42
+ \raw_mode "raw-tengwar"
43
+
41
44
  \charset tengwar_ds_sindarin true
42
45
  \charset tengwar_ds_parmaite false
43
46
  \charset tengwar_ds_eldamar false
@@ -33,15 +33,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
33
33
  \entry "0.0.7" "Added charset support for Annatar"
34
34
  \entry "0.0.8" "Added support for the FreeMonoTengwar font"
35
35
  \entry "0.1.0" "Added support for the Tengwar Elfica font"
36
+ \entry "0.1.1" "Added support for inlined raw tengwar"
36
37
  \end
37
38
 
38
-
39
39
  \language "Sindarin"
40
40
  \writing "Tengwar"
41
41
  \mode "General Use"
42
- \version "0.1.0"
42
+ \version "0.1.1"
43
43
  \authors "J.R.R. Tolkien, impl. Talagan (Benjamin Babut)"
44
44
 
45
+ \raw_mode "raw-tengwar"
46
+
45
47
  \charset tengwar_ds_sindarin true
46
48
  \charset tengwar_ds_parmaite false
47
49
  \charset tengwar_ds_eldamar false
@@ -31,14 +31,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
31
31
  \entry "0.0.5" "Added support for the FreeMonoTengwar font"
32
32
  \entry "0.0.6" "Ported some options from the quenya mode"
33
33
  \entry "0.1.0" "Added support for the Tengwar Elfica font"
34
+ \entry "0.1.1" "Added support for inlined raw tengwar"
34
35
  \end
35
36
 
36
37
  \language "Telerin"
37
38
  \writing "Tengwar"
38
39
  \mode "Glaemscrafu"
39
- \version "0.1.0"
40
+ \version "0.1.1"
40
41
  \authors "Talagan (Benjamin Babut), based on J.R.R Tolkien"
41
42
 
43
+ \raw_mode "raw-tengwar"
44
+
42
45
  \charset tengwar_ds_sindarin true
43
46
  \charset tengwar_ds_parmaite false
44
47
  \charset tengwar_ds_eldamar false
@@ -28,15 +28,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
28
28
  \entry "0.0.4" "Added charset support for Annatar"
29
29
  \entry "0.0.5" "Added support for the FreeMonoTengwar font"
30
30
  \entry "0.1.0" "Added support for the Tengwar Elfica font"
31
+ \entry "0.1.1" "Added support for inlined raw tengwar"
31
32
  \end
32
33
 
33
34
  \** Westron mode for glaemscribe (MAY BE INCOMPLETE) **\
34
35
  \language Westron
35
36
  \writing Tengwar
36
37
  \mode Glaemscrafu
37
- \version "0.1.0"
38
+ \version "0.1.1"
38
39
  \authors "Talagan (Benjamin Babut), based on J.R.R. Tolkien"
39
40
 
41
+ \raw_mode "raw-tengwar"
42
+
40
43
  \charset tengwar_ds_sindarin true
41
44
  \charset tengwar_ds_parmaite false
42
45
  \charset tengwar_ds_eldamar false
@@ -23,15 +23,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
23
23
  **\
24
24
 
25
25
  \beg changelog
26
- \entry 0.0.2 "Porting to virtual chars"
26
+ \entry "0.0.2" "Porting to virtual chars"
27
+ \entry "0.1.1" "Added support for inlined raw tengwar"
27
28
  \end
28
29
 
29
30
  \language "Old English"
30
31
  \writing "Tengwar"
31
32
  \mode "West Saxon"
32
- \version "0.1.0"
33
+ \version "0.1.1"
33
34
  \authors "J.R.R. Tolkien, impl. Talagan (Benjamin Babut)"
34
35
 
36
+ \raw_mode "raw-tengwar"
37
+
35
38
  \charset tengwar_ds_eldamar true
36
39
  \** Other charsets cannot handle all diacritics we are using here ... **\
37
40
 
@@ -238,10 +241,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
238
241
  \** ## Liquids **\
239
242
  \** ## **\
240
243
 
241
- {S_VOWELS_WN}w{S_VOWELS_WN} --> 2,1,3 --> ROMEN {_S_VOWELS_UP_WN_}{_S_VOWELS_DN_WN_}
242
- {S_VOWELS_WN}ww --> 2,1 --> ROMEN GEMINATE_DOUBLE {_S_VOWELS_UP_WN_}
243
- {S_VOWELS_WN}[l * ll] --> 2,1 --> [LAMBE * LAMBE GEMINATE_DOUBLE]{_S_VOWELS_UP_WN_}
244
- {S_VOWELS_WN}ld --> 2,1 --> ALDA {_S_VOWELS_UP_WN_}
244
+ {S_VOWELS_WN}w{S_VOWELS_WN} --> ROMEN {_S_VOWELS_UP_WN_}{_S_VOWELS_DN_WN_}
245
+ {S_VOWELS_WN}ww --> ROMEN GEMINATE_DOUBLE {_S_VOWELS_UP_WN_}
246
+ {S_VOWELS_WN}[l * ll] --> 2,1 --> [LAMBE * LAMBE GEMINATE_DOUBLE]{_S_VOWELS_UP_WN_}
247
+ {S_VOWELS_WN}ld --> ALDA {_S_VOWELS_UP_WN_}
245
248
 
246
249
 
247
250
  \** ## Alveolar (sifflantes) **\
@@ -252,40 +255,36 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
252
255
  {L8_IMG_GEMS} === SILME_NUQUERNA GEMINATE_DOUBLE * ESSE_NUQUERNA GEMINATE_DOUBLE
253
256
 
254
257
  {S_VOWELS_WN}[{L8_KER}]{S_VOWELS_WN} --> 2,1,3 --> [{L8_IMG}]{_S_VOWELS_UP_WN_}{_S_VOWELS_DN_WN_}
255
- {S_VOWELS_WN}[{L8_KER_GEMS}] --> 2,1 --> [{L8_IMG_GEMS}]{_S_VOWELS_UP_WN_}
258
+ {S_VOWELS_WN}[{L8_KER_GEMS}] --> 2,1 --> [{L8_IMG_GEMS}]{_S_VOWELS_UP_WN_}
256
259
 
257
260
 
258
261
  \** ## FINAL S (Challenging!) **\
259
262
  {S_VOWELS_WN}s_ --> SHOOK_BEAUTIFUL {_S_VOWELS_UP_WN_} \** # Final rule for s **\
260
263
  _{S_VOWELS_WN}s_ --> SILME_NUQUERNA {_S_VOWELS_UP_WN_} \** # Rule _es_ **\
261
- [{L_VOWELS} * _ ]{S_VOWELS_WN}s_ --> 2,1,3 --> [{L_TEHTAR} * {NULL} ] SILME_NUQUERNA {_S_VOWELS_UP_WN_} \** # Rule for éis_, és_ **\
262
- {NULL}[ {S_VOWELS_NP_KERNEL} ]{S_VOWELS}s_ --> 1,3,2,4 --> TELCO [ {TEHTAR_UP_NP} ] SILME_NUQUERNA {_S_VOWELS_UP_} \** # Rule for ies_ **\
264
+ [{L_VOWELS} * _ ]{S_VOWELS_WN}s_ --> [{L_TEHTAR} * {NULL} ] SILME_NUQUERNA {_S_VOWELS_UP_WN_} \** # Rule for éis_, és_ **\
265
+ {NULL}[ {S_VOWELS_NP_KERNEL} ]{S_VOWELS}s_ --> TELCO [ {TEHTAR_UP_NP} ] SILME_NUQUERNA {_S_VOWELS_UP_} \** # Rule for ies_ **\
263
266
 
264
267
  s --> SILME \** # Overload lonely s **\
265
268
  z --> ESSE \** # Overload lonely z **\
266
269
 
267
270
  \** ## Ligatures **\
268
271
  \** ## **\
269
- {LINE_VARIOUS_1_KER} === sċ
270
- {LINE_VARIOUS_1_IMG} === ANCA_CLOSED
271
- {LINE_VARIOUS_2_KER} === hw * çt * (χt,ħt)
272
- {LINE_VARIOUS_2_IMG} === HARP_SHAPED * AHA_TINCO * HWESTA_TINCO
273
-
274
- {S_VOWELS_WN}[{LINE_VARIOUS_1_KER}]{S_VOWELS_WN} --> 2,1,3 --> [{LINE_VARIOUS_1_IMG}]{_S_VOWELS_UP_WN_}{_S_VOWELS_DN_WN_}
275
- {S_VOWELS_WN}[{LINE_VARIOUS_2_KER}]{S_VOWELS_WN} --> 2,1,3 --> [{LINE_VARIOUS_2_IMG}]{_S_VOWELS_UP_WN_}{_S_VOWELS_DN_WN_}
276
-
277
-
272
+ {LINE_VARIOUS_KER} === sċ * hw * çt * (χt,ħt)
273
+ {LINE_VARIOUS_IMG} === ANCA_CLOSED * HARP_SHAPED * AHA_TINCO * HWESTA_TINCO
274
+
275
+ {S_VOWELS_WN}[{LINE_VARIOUS_KER}]{S_VOWELS_WN} --> 2,1,3 --> [{LINE_VARIOUS_IMG}]{_S_VOWELS_UP_WN_}{_S_VOWELS_DN_WN_}
276
+
278
277
  \** ## Various **\
279
278
  \** ## **\
280
- {S_VOWELS_WN}h{S_VOWELS_WN} --> 2,1,3 --> HYARMEN {_S_VOWELS_UP_WN_}{_S_VOWELS_DN_WN_}
281
- {S_VOWELS_WN}hh --> 2,1 --> HYARMEN GEMINATE_DOUBLE {_S_VOWELS_UP_WN_}
279
+ {S_VOWELS_WN}h{S_VOWELS_WN} --> HYARMEN {_S_VOWELS_UP_WN_}{_S_VOWELS_DN_WN_}
280
+ {S_VOWELS_WN}hh --> HYARMEN GEMINATE_DOUBLE {_S_VOWELS_UP_WN_}
282
281
 
283
282
 
284
283
  \** ## X **\
285
284
  \** ## For x, due to the cedilla, we cannot put tehtas under the tengwa. **\
286
- {S_VOWELS_WN}x --> 2,1 --> QUESSE SHOOK_LEFT_L {_S_VOWELS_UP_WN_}
287
- {S_VOWELS_WN}xx --> 2,1 --> QUESSE SHOOK_LEFT_L GEMINATE_DOUBLE {_S_VOWELS_UP_WN_}
288
- {S_VOWELS_WN}nx --> 2,1 --> QUESSE SHOOK_LEFT_L TILD_SUP_S {_S_VOWELS_UP_WN_}
285
+ {S_VOWELS_WN}x --> QUESSE SHOOK_LEFT_L {_S_VOWELS_UP_WN_}
286
+ {S_VOWELS_WN}xx --> QUESSE SHOOK_LEFT_L GEMINATE_DOUBLE {_S_VOWELS_UP_WN_}
287
+ {S_VOWELS_WN}nx --> QUESSE SHOOK_LEFT_L TILD_SUP_S {_S_VOWELS_UP_WN_}
289
288
  \end
290
289
 
291
290
  \beg rules punctuation
data/lib/api/mode.rb CHANGED
@@ -37,6 +37,8 @@ module Glaemscribe
37
37
  attr_accessor :supported_charsets
38
38
  attr_accessor :default_charset
39
39
 
40
+ attr_accessor :raw_mode_name # Read from glaeml
41
+
40
42
  attr_reader :latest_option_values
41
43
 
42
44
  def initialize(name)
@@ -111,24 +113,61 @@ module Glaemscribe
111
113
  @pre_processor.finalize(@latest_option_values)
112
114
  @post_processor.finalize(@latest_option_values)
113
115
  @processor.finalize(@latest_option_values)
114
-
116
+
117
+ raw_mode.finalize options if raw_mode
118
+
115
119
  self
116
120
  end
117
121
 
118
- def transcribe(content, charset = nil)
122
+ def raw_mode
123
+ return @raw_mode if @raw_mode
124
+ loaded_raw_mode = (@raw_mode_name && Glaemscribe::API::ResourceManager.loaded_modes[@raw_mode_name])
125
+ return nil if !loaded_raw_mode
126
+ @raw_mode = loaded_raw_mode.deep_clone
127
+ end
128
+
129
+ def strict_transcribe(content, charset = nil)
119
130
  charset = default_charset if !charset
120
131
  return false, "*** No charset usable for transcription. Failed!" if !charset
121
132
 
133
+ # Parser works line by line
122
134
  ret = content.lines.map{ |l|
123
- l = l.strip # Clean the lines
135
+ restore_lf = false
136
+ if l[-1] == "\n"
137
+ l[-1] = ""
138
+ restore_lf = true
139
+ end
124
140
  l = @pre_processor.apply(l)
125
141
  l = @processor.apply(l)
126
142
  l = @post_processor.apply(l, charset)
127
- }.join("\n")
128
-
143
+ l += "\n" if restore_lf
144
+ l
145
+ }.join
129
146
  return true, ret
130
147
  end
131
148
 
149
+ def transcribe(content, charset = nil)
150
+ if raw_mode
151
+ chunks = content.split(/({{.*?}})/m)
152
+ ret = ''
153
+ res = true
154
+ chunks.each{ |c|
155
+ if c =~ /{{(.*?)}}/m
156
+ succ, r = raw_mode.strict_transcribe($1,charset)
157
+ res = res && succ
158
+ ret += r if succ
159
+ else
160
+ succ, r = strict_transcribe(c,charset)
161
+ res = res && succ
162
+ ret += r if succ
163
+ end
164
+ }
165
+ return res,ret
166
+ else
167
+ strict_transcribe(content,charset)
168
+ end
169
+ end
170
+
132
171
  end
133
172
  end
134
173
  end