diff options
Diffstat (limited to 'ekdosis.dtx')
-rw-r--r-- | ekdosis.dtx | 63 |
1 files changed, 41 insertions, 22 deletions
diff --git a/ekdosis.dtx b/ekdosis.dtx index d6a328e..9bc6304 100644 --- a/ekdosis.dtx +++ b/ekdosis.dtx | |||
@@ -1401,6 +1401,7 @@ local cmdtotags = { | |||
1401 | } | 1401 | } |
1402 | 1402 | ||
1403 | local texpatttotags = { | 1403 | local texpatttotags = { |
1404 | {a="\\icite%s?%[(.-)%]%[(.-)%]{(.-)}", b="%1 <ref target=\"#%3\">%2</ref>"}, | ||
1404 | {a="\\icite%s?%[(.-)%]{(.-)}", b="<ref target=\"#%2\">%1</ref>"}, | 1405 | {a="\\icite%s?%[(.-)%]{(.-)}", b="<ref target=\"#%2\">%1</ref>"}, |
1405 | {a="\\icite%s?{(.-)}", b="<ptr target=\"#%1\"/>"} | 1406 | {a="\\icite%s?{(.-)}", b="<ptr target=\"#%1\"/>"} |
1406 | } | 1407 | } |
@@ -1628,16 +1629,24 @@ local function envtotei(str) | |||
1628 | do | 1629 | do |
1629 | if envtotags[i].b ~= "" | 1630 | if envtotags[i].b ~= "" |
1630 | then | 1631 | then |
1631 | -- if tei_p_open and envtotags[i].b == "p" or envtotags[i].b == "lg" | 1632 | -- -- if tei_p_open and envtotags[i].b == "p" or envtotags[i].b == "lg" |
1632 | if tei_p_open and isfound(close_p, envtotags[i].b) | 1633 | -- if tei_p_open and isfound(close_p, envtotags[i].b) |
1634 | if isfound(close_p, envtotags[i].b) | ||
1633 | then | 1635 | then |
1636 | str = gsub(str, lpeg.P("\\par") * spcenc^-1 * lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{") | ||
1637 | * lpeg.Cs(envtotags[i].a) * lpeg.P("}") | ||
1638 | * bsqbracketsii * bcbracesii * spcenc^-1, | ||
1639 | "</p>\n<"..envtotags[i].b..envtotags[i].c..">") | ||
1634 | str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{") | 1640 | str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{") |
1635 | * lpeg.Cs(envtotags[i].a) * lpeg.P("}") | 1641 | * lpeg.Cs(envtotags[i].a) * lpeg.P("}") |
1636 | * bsqbracketsii * bcbracesii * spcenc^-1, | 1642 | * bsqbracketsii * bcbracesii * spcenc^-1, |
1637 | "</p>\n<"..envtotags[i].b..envtotags[i].c..">") | 1643 | "<"..envtotags[i].b..envtotags[i].c..">") |
1638 | str = gsub(str, spcenc^-1 * lpeg.P("\\end") * spcenc^-1 * lpeg.P("{") | 1644 | str = gsub(str, spcenc^-1 * lpeg.P("\\end") * spcenc^-1 * lpeg.P("{") |
1639 | * lpeg.Cs(envtotags[i].a) * lpeg.P("}"), | 1645 | * lpeg.Cs(envtotags[i].a) * lpeg.P("}" * spcenc^-1 * lpeg.P("\\par")), |
1640 | "</"..envtotags[i].b..">\n<p>") | 1646 | "</"..envtotags[i].b..">\n<p>") |
1647 | str = gsub(str, spcenc^-1 * lpeg.P("\\end") * spcenc^-1 * lpeg.P("{") | ||
1648 | * lpeg.Cs(envtotags[i].a) * lpeg.P("}"), | ||
1649 | "</"..envtotags[i].b..">") | ||
1641 | else | 1650 | else |
1642 | str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{") | 1651 | str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{") |
1643 | * lpeg.Cs(envtotags[i].a) * lpeg.P("}") | 1652 | * lpeg.Cs(envtotags[i].a) * lpeg.P("}") |
@@ -1723,22 +1732,32 @@ local function cmdtotei(str) | |||
1723 | return str | 1732 | return str |
1724 | end | 1733 | end |
1725 | 1734 | ||
1735 | local function partotei(str) | ||
1736 | str = string.gsub(str, "\\par%s-", "<p>", 1) | ||
1737 | str = string.gsub(str, "\\par%s-", "</p><p>") | ||
1738 | str = string.gsub(str, "<p>%s-</p>", "") | ||
1739 | str = string.gsub(str, "(%<p%>)%s-(%</div%>)$", "%2") | ||
1740 | str = string.gsub(str, "(%<p%>)%s-$", "") | ||
1741 | return str | ||
1742 | end | ||
1743 | |||
1726 | local function textotei(str) | 1744 | local function textotei(str) |
1727 | str = xml_entities(str) | 1745 | str = xml_entities(str) |
1728 | str = texpatttotei(str) | 1746 | str = texpatttotei(str) |
1729 | if tei_p_open | 1747 | -- if tei_p_open |
1730 | then | 1748 | -- then |
1731 | str = string.gsub(str, "%s?\\par%s?", "</p>\n<p>") | 1749 | -- str = string.gsub(str, "%s?\\par%s?", "</p>\n<p>") |
1732 | else | 1750 | -- else |
1733 | str = string.gsub(str, "%s?\\par%s?", "\n<p>") | 1751 | -- str = string.gsub(str, "%s?\\par%s?", "\n<p>") |
1734 | tei_p_open = true | 1752 | -- tei_p_open = true |
1735 | end | 1753 | -- end |
1736 | str = note_totei(str) | 1754 | str = note_totei(str) |
1737 | str = app_totei(str) | 1755 | str = app_totei(str) |
1738 | str = lem_rdg_totei(str) | 1756 | str = lem_rdg_totei(str) |
1739 | str = versetotei(str) | 1757 | str = versetotei(str) |
1740 | str = envtotei(str) | 1758 | str = envtotei(str) |
1741 | str = cmdtotei(str) | 1759 | str = cmdtotei(str) |
1760 | str = partotei(str) | ||
1742 | return str | 1761 | return str |
1743 | end | 1762 | end |
1744 | 1763 | ||
@@ -1879,16 +1898,16 @@ end | |||
1879 | 1898 | ||
1880 | function ekdosis.exporttei(str) | 1899 | function ekdosis.exporttei(str) |
1881 | local f = io.open(teifilename.."_tmp.xml", "a+") | 1900 | local f = io.open(teifilename.."_tmp.xml", "a+") |
1882 | f:write("\n<p>") | 1901 | -- f:write("\n<p>") |
1883 | tei_p_open = true | 1902 | -- tei_p_open = true |
1884 | str = textotei(str) | 1903 | str = textotei(str) |
1885 | f:write(str) | 1904 | f:write(str) |
1886 | if tei_p_open | 1905 | -- if tei_p_open |
1887 | then | 1906 | -- then |
1888 | f:write("</p>") | 1907 | -- f:write("</p>") |
1889 | tei_p_open = false | 1908 | -- tei_p_open = false |
1890 | else | 1909 | -- else |
1891 | end | 1910 | -- end |
1892 | f:close() | 1911 | f:close() |
1893 | return true | 1912 | return true |
1894 | end | 1913 | end |