Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ uv run python -m opensiddur.importer.jps1917.convert_wikisource \
--project-dir ~/src/opensiddur-repos/opensiddur-projects/project/jps1917
```

Example: download Miqra al pi ha-Masorah from Google Sheets into sourcetexts:

```bash
uv run python -m opensiddur.importer.miqra_al_pi_hamasorah.download \
--sourcetexts-root ~/src/opensiddur-repos/sourcetexts/sources
```

## JLPTEI sources

JLPTEI sources are compiled into the `project` directory.
Expand Down
11 changes: 11 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# https://docs.codecov.com/docs/commit-status
coverage:
status:
project:
default:
target: 85%
informational: false
patch:
default:
target: 85%
informational: false
2 changes: 1 addition & 1 deletion opensiddur/exporter/pdf/pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,5 +392,5 @@ def main(): # pragma: no cover
sys.exit(1)


if __name__ == "__main__":
if __name__ == "__main__": # pragma: no cover
main()
24 changes: 23 additions & 1 deletion opensiddur/exporter/tex/bibtex.xslt
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,34 @@
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:tei="http://www.tei-c.org/ns/1.0"
xmlns:j="http://jewishliturgy.org/ns/jlptei/2"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="tei j">

<xsl:output method="text" encoding="UTF-8" indent="no"/>

<xsl:strip-space elements="*"/>

<xsl:variable name="xml-ns" select="'http://www.w3.org/XML/1998/namespace'"/>

<xsl:function name="j:in-scope-lang" as="xs:string">
<xsl:param name="node" as="node()"/>
<xsl:sequence select="string(($node/ancestor-or-self::*[@xml:lang][1]/@xml:lang)[1])"/>
</xsl:function>

<xsl:function name="j:bibtex-field-value" as="xs:string">
<xsl:param name="node" as="element()"/>
<xsl:variable name="lang" select="j:in-scope-lang($node)"/>
<xsl:variable name="v" select="normalize-space(string($node))"/>
<xsl:choose>
<xsl:when test="$lang = 'he' or starts-with($lang, 'he-')">
<xsl:sequence select="concat('\texthebrew{', $v, '}')"/>
</xsl:when>
<xsl:otherwise>
<xsl:sequence select="$v"/>
</xsl:otherwise>
</xsl:choose>
</xsl:function>

<!-- Root template -->
<xsl:template match="/">
<xsl:apply-templates select="//tei:bibl"/>
Expand Down Expand Up @@ -215,7 +237,7 @@
<xsl:text> </xsl:text>
<xsl:value-of select="$field-name"/>
<xsl:text> = {</xsl:text>
<xsl:value-of select="normalize-space(.)"/>
<xsl:value-of select="j:bibtex-field-value(.)"/>
<xsl:text>},&#10;</xsl:text>
</xsl:if>
</xsl:template>
Expand Down
2 changes: 1 addition & 1 deletion opensiddur/exporter/tex/latex.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,5 +464,5 @@ def main(): # pragma: no cover
)


if __name__ == "__main__":
if __name__ == "__main__": # pragma: no cover
main()
42 changes: 37 additions & 5 deletions opensiddur/exporter/tex/reledmac.xslt
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@
<xsl:text>\pend&#10;</xsl:text>
</xsl:if>
<xsl:text>\eledchapter{</xsl:text>
<xsl:value-of select="f:escape-tex(string(@title))"/>
<xsl:value-of select="f:format-section-title(string(@title), string(@xml:lang))"/>
<xsl:text>}&#10;</xsl:text>
<xsl:next-iteration>
<xsl:with-param name="in-pstart" select="false()"/>
Expand All @@ -550,7 +550,7 @@
<xsl:text>\pend&#10;</xsl:text>
</xsl:if>
<xsl:text>\eledsubsection{</xsl:text>
<xsl:value-of select="f:escape-tex(string(@title))"/>
<xsl:value-of select="f:format-section-title(string(@title), string(@xml:lang))"/>
<xsl:text>}&#10;</xsl:text>
<xsl:next-iteration>
<xsl:with-param name="in-pstart" select="false()"/>
Expand Down Expand Up @@ -659,17 +659,21 @@

<xsl:template match="tei:body/tei:div" mode="leaves">
<xsl:if test="tei:head">
<xsl:variable name="head" select="tei:head[1]"/>
<xsl:element name="f:eledpart" namespace="urn:opensiddur:reledmac">
<xsl:attribute name="title" select="normalize-space(string-join(tei:head//text(), ''))"/>
<xsl:attribute name="title" select="normalize-space(string-join($head//text(), ''))"/>
<xsl:attribute name="xml:lang" select="f:section-title-lang($head)"/>
</xsl:element>
</xsl:if>
<xsl:apply-templates select="node()[not(self::tei:head)]" mode="leaves"/>
</xsl:template>

<xsl:template match="tei:div" mode="leaves" priority="-1">
<xsl:if test="tei:head">
<xsl:variable name="head" select="tei:head[1]"/>
<xsl:element name="f:eledsubsection" namespace="urn:opensiddur:reledmac">
<xsl:attribute name="title" select="normalize-space(string-join(tei:head//text(), ''))"/>
<xsl:attribute name="title" select="normalize-space(string-join($head//text(), ''))"/>
<xsl:attribute name="xml:lang" select="f:section-title-lang($head)"/>
</xsl:element>
</xsl:if>
<xsl:apply-templates select="node()[not(self::tei:head)]" mode="leaves"/>
Expand Down Expand Up @@ -725,7 +729,9 @@
<!-- Ensure we're in horizontal mode before forcing a linebreak.
This avoids \"There's no line here to end\" when lb occurs at the
start of a paragraph/block. -->
<xsl:text>\leavevmode\\&#10;</xsl:text>
<!-- Add an empty brace group so a following `[` at the start of the next
line is not parsed as the optional length argument to `\\`. -->
<xsl:text>\leavevmode\\{}&#10;</xsl:text>
</xsl:template>

<!-- tei:anchor: linkage ids only; editorial notes are already inlined in the body. -->
Expand Down Expand Up @@ -893,6 +899,32 @@
<xsl:sequence select="count($ctx/preceding::tei:note[not(@type='instruction') and not(ancestor::tei:standOff)])"/>
</xsl:function>

<!-- Language for tei:head used in \eledchapter/\eledsubsection titles. -->
<xsl:function name="f:section-title-lang" as="xs:string">
<xsl:param name="head" as="element(tei:head)"/>
<xsl:sequence select="string((
$head/@xml:lang,
$head/ancestor::tei:div[@xml:lang][1]/@xml:lang,
$head/ancestor::tei:TEI[@xml:lang][1]/@xml:lang
)[1])"/>
</xsl:function>

<!-- Hebrew titles stay in the stream direction; other languages need an
explicit LTR wrapper so Latin text is not reversed in RTL blocks. -->
<xsl:function name="f:format-section-title" as="xs:string">
<xsl:param name="title" as="xs:string"/>
<xsl:param name="lang" as="xs:string"/>
<xsl:variable name="escaped" select="f:escape-tex($title)"/>
<xsl:choose>
<xsl:when test="$lang = 'he' or starts-with($lang, 'he-')">
<xsl:sequence select="$escaped"/>
</xsl:when>
<xsl:otherwise>
<xsl:sequence select="concat('{\textdir TLT\selectlanguage{english}', $escaped, '}')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:function>

<xsl:function name="f:escape-tex" as="xs:string">
<xsl:param name="s" as="xs:string"/>
<!-- Escape characters that have special meaning in LaTeX. Order matters:
Expand Down
2 changes: 1 addition & 1 deletion opensiddur/exporter/validate_urn_references.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,6 @@ def main(argv: Optional[list[str]] = None) -> int:
return 0


if __name__ == "__main__":
if __name__ == "__main__": # pragma: no cover
raise SystemExit(main())

9 changes: 5 additions & 4 deletions opensiddur/importer/agent/checkpoint_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,10 @@ def demo_interrupted_session():
print(f"\n🧹 Cleaned up {checkpoint_file}")


if __name__ == "__main__":
# Run the checkpointing demo
def _run_cli() -> None: # pragma: no cover
demo_checkpointing()

# Run the interrupted session demo
demo_interrupted_session()


if __name__ == "__main__": # pragma: no cover
_run_cli()
2 changes: 1 addition & 1 deletion opensiddur/importer/agent/example_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,5 @@ def main():
print(f" [{role}]: {message[:100]}{'...' if len(message) > 100 else ''}")


if __name__ == "__main__":
if __name__ == "__main__": # pragma: no cover
main()
Loading