aboutsummaryrefslogtreecommitdiff
path: root/arabluatex_voc.lua
AgeCommit message (Collapse)Author
2016-03-26small bugfix regarding madda; still documentingRobert Alessi
2016-03-25improved quoting feature in all modes; still documentingRobert Alessi
2016-03-24bugfix: wrong 'lla_dI with bi-; still documentingRobert Alessi
2016-03-23additional rules for the name of Allah; still documentingRobert Alessi
2016-03-21long vowels, diphthongs and consonants with ǧazmah before ʾalif conjunctionisRobert Alessi
2016-03-20assimilations [Wright i §14 (b)]; no more euphonic tašdīd in novoc modeRobert Alessi
2016-03-20some bugfixes in the tables; still writing the documentationRobert Alessi
2016-03-15added final hamza + sukūnRobert Alessi
2016-03-15bugfix: final hamza was wrongRobert Alessi
2016-03-15some corrections in the tables + writing the documentationRobert Alessi
2016-03-14some corrections in the tables as |BaN|; still writing the documentationRobert Alessi
2016-03-11bugfix: quoting sukūn in fullvoc modeRobert Alessi
2016-03-10writing documentation (continued) + added quoting u|a|iRobert Alessi
2016-03-09bugfix: wrong decimal separator in arabic modeRobert Alessi
2016-03-09corrected clean-up function for hyphenRobert Alessi
2016-03-04implementation of basic Arabic punctuationRobert Alessi
2016-03-04silent wāw and yāʾ in words such as ḥayāt and tawrātRobert Alessi
2016-03-03ʿamr + u a iRobert Alessi
2016-03-03misplaced alif maqṣūraRobert Alessi
2016-03-03ʿamr + tanwīnRobert Alessi
2016-03-03šadda over hamza + improved maddaRobert Alessi
2016-03-03" as sukūn needed to be escapedRobert Alessi
2016-03-03corrected final hamza; added quoting before hamzaRobert Alessi
2016-03-02corrected typosRobert Alessi
2016-02-26implementation of fullvoc tablesRobert Alessi
2016-02-25fix hamza: ^say'aN, xa.tI'aTuN; fix maddaRobert Alessi
2016-02-24first implementation of fullvoc tablesRobert Alessi
2016-02-22'llatI 'lla_dIRobert Alessi
2016-02-22initial project versionRobert Alessi
349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567
--[[
This file is part of the `arabluatex' package

ArabLuaTeX -- Processing ArabTeX notation under LuaLaTeX
Copyright (C) 2016  Robert Alessi

Please send error reports and suggestions for improvements to Robert
Alessi <alessi@robertalessi.net>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see
<http://www.gnu.org/licenses/>.
--]]

require("arabluatex_voc")
require("arabluatex_fullvoc")
require("arabluatex_novoc")
require("arabluatex_trans")

local function protectarb(str)
   str = string.gsub(str, "(\\arb.?)(%[.-%])(%b{})", "\\@arb%2%3")
   str = string.gsub(str, "\\par", "\\p@r{}")
   str = string.gsub(str, "\\@@par", "\\p@r{}")
return str
end

local function unprotectarb(str)
   str = string.gsub(str, "(\\@arb)(%[.-%])(%b{})", "\\arb%2%3")
   str = string.gsub(str, "\\p@r{}", "\\par")
return str
end

local function breakcmd(str)
   -- \edtext
   str = string.gsub(str, "\\(edtext.-)(%b{})(%b{})",
	function(tag, bodylem, bodyvar)
	bodylem = string.sub(bodylem, 2, -2)
	bodyvar = string.sub(bodyvar, 2, -2)
	return string.format("\\LR{\\%s{%s}{%s}}", tag, bodylem, bodyvar)
	end)
   -- \RL
   str = string.gsub(str, "\\(RL.-)(%b{})",
		function(tag, body)
		body = string.sub(body, 2, -2)
		return string.format("}\\%s{%s}\\arb{", tag, body)
		end)
   -- \LR
   str = string.gsub(str, "\\(LR.-)(%b{})",
		function(tag, body)
		body = string.sub(body, 2, -2)
		return string.format("}\\%s{%s}\\arb{", tag, body)
		end)
   -- Footnote
   str = string.gsub(str, "\\(Footnote.-)(%b{})",
		function(tag, body)
		body = string.sub(body, 2, -2)
		return string.format("}\\%s{%s}\\arb{", tag, body)
		end)
   -- Marginpar
   str = string.gsub(str, "\\(Marginpar.-)(%b{})",
		function(tag, body)
		body = string.sub(body, 2, -2)
		return string.format("}\\%s{%s}\\arb{", tag, body)
		end)
   -- Abjad
   str = string.gsub(str, "\\(abjad.-)(%b{})",
	function(tag, body)
	body = string.sub(body, 2, -2)
	return string.format("}\\aemph{\\%s{%s}}\\arb{", tag, body)
	end)
   return str
end

local function holdcmd(str)
	str = string.gsub(str, "\\(arb)(%b{})", function(tag, body)
	body = string.sub(body, 2, -2)
	body = string.gsub(body, "\\(.-)(%b{})", function(btag, bbody)
	bbody = string.sub(bbody, 2, -2)
	if string.find(btag, "@") then
	return holdcmd(string.format("}\\%s{%s}\\arb{", btag, bbody))	
	else
	return holdcmd(string.format("}\\%s{\\arb{%s}}\\arb{", btag, bbody))
	end
	end)
	return string.format("\\%s{%s}", tag, body)
	end)
	str = string.gsub(str, "\\arb{}", "")
return str
end

local function arbnum(str)
   str = string.gsub(str, "([0-9%,%-%/]+)", function(num)
	return string.reverse(num)
   end)
   return str
end

local function indnum(str)
   str = string.gsub(str, "([0-9%,%-%/]+)", function(num)
	return string.reverse(num)
   end)
   for i = 1,#numbers do
      str = string.gsub(str, numbers[i].a, numbers[i].b)
   end
   return str
end

local function takeoutabjad(str)
   str = string.gsub(str, "(\\abjad.?)(%b{})", function(tag, body)
			body = string.sub(body, 2, -2)
			return string.format("%s", body)
   end)
   return str
end

local function takeoutcapetc(str)
   str = string.gsub(str, "(\\cap.?)(%b{})", function(tag, body)
			body = string.sub(body, 2, -2)
			return string.format("%s", body)
   end)
   str = string.gsub(str, "\\linebreak", "")
   return str
end

local function voc(str)
   str = string.gsub(str, "\\arb(%b{})", function(inside)
   inside = string.sub(inside, 2, -2)
   for i = 1,#hamza do
      inside = string.gsub(inside, hamza[i].a, hamza[i].b)
   end
   for i = 1,#tanwin do
      inside  = string.gsub(inside, tanwin[i].a, tanwin[i].b)
   end
   for i = 1,#trigraphs do
      inside = string.gsub(inside, trigraphs[i].a, trigraphs[i].b)
   end
   for i = 1,#digraphs do
      inside = string.gsub(inside, digraphs[i].a, digraphs[i].b)
   end
   for i = 1,#single do
      inside = string.gsub(inside, single[i].a, single[i].b)
   end
   for i = 1,#longv do
      inside = string.gsub(inside, longv[i].a, longv[i].b)
   end
   for i = 1,#shortv do
      inside = string.gsub(inside, shortv[i].a, shortv[i].b)
   end
   for i = 1,#punctuation do
      inside = string.gsub(inside, punctuation[i].a, punctuation[i].b)
   end
   for i = 1,#null do
      inside = string.gsub(inside, null[i].a, null[i].b)
   end
   inside = indnum(inside)
   return string.format("\\txarb{%s}", inside)
   end)
return str
end

local function voceasy(str)
   str = string.gsub(str, "\\arb(%b{})", function(inside)
   inside = string.sub(inside, 2, -2)
   for i = 1,#hamzaeasy do
      inside = string.gsub(inside, hamzaeasy[i].a, hamzaeasy[i].b)
   end
   for i = 1,#tanwineasy do
      inside  = string.gsub(inside, tanwineasy[i].a, tanwineasy[i].b)
   end
   for i = 1,#trigraphseasy do
      inside = string.gsub(inside, trigraphseasy[i].a, trigraphseasy[i].b)
   end
   for i = 1,#digraphs do
      inside = string.gsub(inside, digraphs[i].a, digraphs[i].b)
   end
   for i = 1,#single do
      inside = string.gsub(inside, single[i].a, single[i].b)
   end
   for i = 1,#longv do
      inside = string.gsub(inside, longv[i].a, longv[i].b)
   end
   for i = 1,#shortv do
      inside = string.gsub(inside, shortv[i].a, shortv[i].b)
   end
   for i = 1,#punctuation do
      inside = string.gsub(inside, punctuation[i].a, punctuation[i].b)
   end
   for i = 1,#null do
      inside = string.gsub(inside, null[i].a, null[i].b)
   end
   inside = indnum(inside)
   return string.format("\\txarb{%s}", inside)
   end)
return str
end

local function fullvoc(str)