aboutsummaryrefslogtreecommitdiff
path: root/arabluatex.lua
diff options
context:
space:
mode:
Diffstat (limited to 'arabluatex.lua')
-rw-r--r--arabluatex.lua56
1 files changed, 50 insertions, 6 deletions
diff --git a/arabluatex.lua b/arabluatex.lua
index 087ee82..76d61b3 100644
--- a/arabluatex.lua
+++ b/arabluatex.lua
@@ -23,6 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
23--]] 23--]]
24 24
25require("arabluatex_voc") 25require("arabluatex_voc")
26require("arabluatex_fullvoc")
26require("arabluatex_novoc") 27require("arabluatex_novoc")
27 28
28local function protectarb(str) 29local function protectarb(str)
@@ -133,14 +134,47 @@ local function voc(str)
133return str 134return str
134end 135end
135 136
137local function fullvoc(str)
138 str = string.gsub(str, "\\arb(%b{})", function(inside)
139 inside = string.sub(inside, 2, -2)
140 for i = 1,#hamzafv do
141 inside = string.gsub(inside, hamzafv[i].a, hamzafv[i].b)
142 end
143 for i = 1,#tanwin do
144 inside = string.gsub(inside, tanwin[i].a, tanwin[i].b)
145 end
146 for i = 1,#trigraphs do
147 inside = string.gsub(inside, trigraphs[i].a, trigraphs[i].b)
148 end
149 for i = 1,#digraphsfv do
150 inside = string.gsub(inside, digraphsfv[i].a, digraphsfv[i].b)
151 end
152 for i = 1,#single do
153 inside = string.gsub(inside, single[i].a, single[i].b)
154 end
155 for i = 1,#longv do
156 inside = string.gsub(inside, longv[i].a, longv[i].b)
157 end
158 for i = 1,#shortv do
159 inside = string.gsub(inside, shortv[i].a, shortv[i].b)
160 end
161 for i = 1,#null do
162 inside = string.gsub(inside, null[i].a, null[i].b)
163 end
164 inside = indnum(inside)
165 return string.format("\\txarb{%s}", inside)
166 end)
167return str
168end
169
136local function novoc(str) 170local function novoc(str)
137 str = string.gsub(str, "\\arb(%b{})", function(inside) 171 str = string.gsub(str, "\\arb(%b{})", function(inside)
138 inside = string.sub(inside, 2, -2) 172 inside = string.sub(inside, 2, -2)
139 for i = 1,#hamza do 173 for i = 1,#hamza do
140 inside = string.gsub(inside, hamza[i].a, hamza[i].b) 174 inside = string.gsub(inside, hamza[i].a, hamza[i].b)
141 end 175 end
142 for i = 1,#tanwinnovoc do 176 for i = 1,#tanwinnv do
143 inside = string.gsub(inside, tanwinnovoc[i].a, tanwinnovoc[i].b) 177 inside = string.gsub(inside, tanwinnv[i].a, tanwinnv[i].b)
144 end 178 end
145 for i = 1,#trigraphs do 179 for i = 1,#trigraphs do
146 inside = string.gsub(inside, trigraphs[i].a, trigraphs[i].b) 180 inside = string.gsub(inside, trigraphs[i].a, trigraphs[i].b)
@@ -151,11 +185,11 @@ local function novoc(str)
151 for i = 1,#single do 185 for i = 1,#single do
152 inside = string.gsub(inside, single[i].a, single[i].b) 186 inside = string.gsub(inside, single[i].a, single[i].b)
153 end 187 end
154 for i = 1,#longvnovoc do 188 for i = 1,#longvnv do
155 inside = string.gsub(inside, longvnovoc[i].a, longvnovoc[i].b) 189 inside = string.gsub(inside, longvnv[i].a, longvnv[i].b)
156 end 190 end
157 for i = 1,#shortvnovoc do 191 for i = 1,#shortvnv do
158 inside = string.gsub(inside, shortvnovoc[i].a, shortvnovoc[i].b) 192 inside = string.gsub(inside, shortvnv[i].a, shortvnv[i].b)
159 end 193 end
160 for i = 1,#null do 194 for i = 1,#null do
161 inside = string.gsub(inside, null[i].a, null[i].b) 195 inside = string.gsub(inside, null[i].a, null[i].b)
@@ -176,6 +210,16 @@ function processvoc(str)
176return str 210return str
177end 211end
178 212
213function processfullvoc(str)
214 str = "\\arb{".. str.."}"
215 str = protectarb(str)
216 str = breakcmd(str)
217 str = holdcmd(str)
218 str = fullvoc(str)
219 str = unprotectarb(str)
220return str
221end
222
179function processnovoc(str) 223function processnovoc(str)
180 str = "\\arb{".. str.."}" 224 str = "\\arb{".. str.."}"
181 str = protectarb(str) 225 str = protectarb(str)