<commit_before><?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:tei="http://www.tei-c.org/ns/1.0"
                xmlns:rails="http://svario.it/xslt-rails"
                exclude-result-prefixes="tei rails"
                version="1.0">
	<xsl:import href="../shared/_tei_entry.xsl"/>
	<xsl:import href="../shared/_raw_xml.xsl"/>
	<xsl:import href="../shared/_chars.xsl"/>
	<xsl:import href="../shared/_info.xsl"/>

	<xsl:variable name="dict-handle" select="/rails:variables/rails:lemma/rails:dict_handle/text()"/>
	<xsl:variable name="tei-entry" select="/rails:variables/rails:lemma/rails:entry/*[self::tei:entry or self::tei:re]"/>
	<xsl:variable name="preceding-entries" select="/rails:variables/rails:preceding_entries/rails:elem/rails:entry/*[self::tei:entry or self::tei:re]"/>
	<xsl:variable name="following-entries" select="/rails:variables/rails:following_entries/rails:elem/rails:entry/*[self::tei:entry or self::tei:re]"/>

	<xsl:template match="/">
		<rails:wrapper>
			<xsl:apply-templates select="$tei-entry"/>

			<xsl:value-of select="$char-newline"/>
			<xsl:call-template name="raw-tei"/>

			<xsl:value-of select="$char-newline"/>
			<xsl:call-template name="adjacent-entries"/>

			<xsl:value-of select="$char-newline"/>
			<xsl:call-template name="citation-instructions"/>
		</rails:wrapper>
	</xsl:template>

	<xsl:template match="tei:entry | tei:re">
		<h1>
			<xsl:apply-templates select="tei:form" mode="heading"/>
		</h1>

		<dl>
			<xsl:apply-templates select="tei:form" mode="definition"/>
			<xsl:apply-templates select="tei:sense" mode="definition"/>
		</dl>
	</xsl:template>

	<xsl:template name="adjacent-entries">
		<h2>
			<xsl:text>Previous and following entries in</xsl:text>
			<xsl:value-of select="$char-space"/>
			<xsl:value-of select="$dict-handle"/><xsl:text> (FIXME: use proper name)</xsl:text>
		</h2>

		<ol class="results adjacent">
			<xsl:apply-templates select="$preceding-entries" mode="adjacent">
				<xsl:with-param name="class">preceding</xsl:with-param>
			</xsl:apply-templates>
			<xsl:apply-templates select="$tei-entry" mode="adjacent">
				<xsl:with-param name="class">current</xsl:with-param>
			</xsl:apply-templates>
			<xsl:apply-templates select="$following-entries" mode="adjacent">
				<xsl:with-param name="class">following</xsl:with-param>
			</xsl:apply-templates>
		</ol>
	</xsl:template>

	<xsl:template match="tei:entry | tei:re" mode="adjacent">
		<xsl:param name="class"/>

		<xsl:variable name="lemma-url">
			<xsl:call-template name="lemma-url">
				<xsl:with-param name="tei-entry" select="."/>
				<xsl:with-param name="dict-handle" select="$dict-handle"/>
			</xsl:call-template>
		</xsl:variable>

		<li class="{$class}">
			<xsl:apply-templates select="tei:form" mode="listing">
				<xsl:with-param name="linked-url" select="$lemma-url"/>
			</xsl:apply-templates>
		</li>
		<xsl:value-of select="$char-newline"/>
	</xsl:template>

	<xsl:template name="raw-tei">
		<details class="raw-tei">
			<summary>
				<xsl:text>[click to show TEI-XML code…]</xsl:text>
			</summary>
			<pre>
				<code>
					<xsl:call-template name="raw-xml">
						<xsl:with-param name="root" select="$tei-entry"/>
					</xsl:call-template>
				</code>
			</pre>
		</details>
	</xsl:template>

	<xsl:template name="citation-instructions">
		<xsl:variable name="lemma-title">
			<xsl:call-template name="text-and-transliterations">
				<xsl:with-param name="text" select="$tei-entry/tei:form/tei:orth/text()"/>
				<xsl:with-param name="rails-entry" select="$tei-entry/.."/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="lemma-id">
			<xsl:call-template name="lemma-url">
				<xsl:with-param name="dict-handle" select="$dict-handle"/>
				<xsl:with-param name="tei-entry" select="$tei-entry"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="lemma-url" select="/rails:variables/rails:request_url/text()"/>
		<xsl:variable name="author">FIXME: AUTHOR</xsl:variable>
		<xsl:variable name="publication">FIXME: DICTIONARY</xsl:variable>
		<xsl:variable name="publication-url">
			<xsl:call-template name="dict-url">
				<xsl:with-param name="dict-handle" select="$dict-handle"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="project-url" select="/rails:variables/rails:request_base_url/text()"/>
		<xsl:variable name="date" select="substring-before(/rails:variables/rails:date/text(), ' ')"/>

		<details class="citation-instructions">
			<summary>
				<xsl:text>Cite this entry</xsl:text>
			</summary>
			<div>
				<dl>

					<dt><xsl:text>Text</xsl:text></dt>
					<dd>
						<p>
							<xsl:value-of select="$lemma-title"/>
							<xsl:text>.</xsl:text>
							<xsl:value-of select="$char-space"/>

							<xsl:text>In</xsl:text>
							<xsl:value-of select="$char-space"/>
							<xsl:value-of select="$publication"/>
							<xsl:text>.</xsl:text>
							<xsl:value-of select="$char-space"/>

							<xsl:text>Retrieved</xsl:text>
							<xsl:value-of select="$char-space"/>
							<xsl:value-of select="$date"/>
							<xsl:text>,</xsl:text>
							<xsl:value-of select="$char-space"/>

							<xsl:text>from</xsl:text>
							<xsl:value-of select="$char-space"/>
							<xsl:value-of select="$lemma-url"/>
						</p>
					</dd>

					<dt><xsl:text>BibTeX</xsl:text></dt>
					<dd>
						<pre style="white-space: pre-line"><code>
							<xsl:variable name="indent">
								<span style="white-space: pre">
									<xsl:value-of select="$char-space"/>
									<xsl:value-of select="$char-space"/>
									<xsl:value-of select="$char-space"/>
									<xsl:value-of select="$char-space"/>
								</span>
							</xsl:variable>

							<xsl:text>@misc{</xsl:text>
							<xsl:value-of select="$char-newline"/>

							<xsl:copy-of select="$indent"/>
							<xsl:text>csdl:</xsl:text>
							<xsl:value-of select="$lemma-id"/>
							<xsl:text>,</xsl:text>
							<xsl:value-of select="$char-newline"/>

							<xsl:copy-of select="$indent"/>
							<xsl:text>author = "</xsl:text>
							<xsl:value-of select="$author"/>
							<xsl:text>",</xsl:text>
							<xsl:value-of select="$char-newline"/>

							<xsl:copy-of select="$indent"/>
							<xsl:text>title = {{</xsl:text>
							<xsl:value-of select="$lemma-title"/>
							<xsl:value-of select="$char-space"/>
							<xsl:text>---</xsl:text><commit_msg>Fix small problems in the citation templates<commit_after><?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:tei="http://www.tei-c.org/ns/1.0"
                xmlns:rails="http://svario.it/xslt-rails"
                exclude-result-prefixes="tei rails"
                version="1.0">
	<xsl:import href="../shared/_tei_entry.xsl"/>
	<xsl:import href="../shared/_raw_xml.xsl"/>
	<xsl:import href="../shared/_chars.xsl"/>
	<xsl:import href="../shared/_info.xsl"/>

	<xsl:variable name="dict-handle" select="/rails:variables/rails:lemma/rails:dict_handle/text()"/>
	<xsl:variable name="tei-entry" select="/rails:variables/rails:lemma/rails:entry/*[self::tei:entry or self::tei:re]"/>
	<xsl:variable name="preceding-entries" select="/rails:variables/rails:preceding_entries/rails:elem/rails:entry/*[self::tei:entry or self::tei:re]"/>
	<xsl:variable name="following-entries" select="/rails:variables/rails:following_entries/rails:elem/rails:entry/*[self::tei:entry or self::tei:re]"/>

	<xsl:template match="/">
		<rails:wrapper>
			<xsl:apply-templates select="$tei-entry"/>

			<xsl:value-of select="$char-newline"/>
			<xsl:call-template name="raw-tei"/>

			<xsl:value-of select="$char-newline"/>
			<xsl:call-template name="adjacent-entries"/>

			<xsl:value-of select="$char-newline"/>
			<xsl:call-template name="citation-instructions"/>
		</rails:wrapper>
	</xsl:template>

	<xsl:template match="tei:entry | tei:re">
		<h1>
			<xsl:apply-templates select="tei:form" mode="heading"/>
		</h1>

		<dl>
			<xsl:apply-templates select="tei:form" mode="definition"/>
			<xsl:apply-templates select="tei:sense" mode="definition"/>
		</dl>
	</xsl:template>

	<xsl:template name="adjacent-entries">
		<h2>
			<xsl:text>Previous and following entries in</xsl:text>
			<xsl:value-of select="$char-space"/>
			<xsl:value-of select="$dict-handle"/><xsl:text> (FIXME: use proper name)</xsl:text>
		</h2>

		<ol class="results adjacent">
			<xsl:apply-templates select="$preceding-entries" mode="adjacent">
				<xsl:with-param name="class">preceding</xsl:with-param>
			</xsl:apply-templates>
			<xsl:apply-templates select="$tei-entry" mode="adjacent">
				<xsl:with-param name="class">current</xsl:with-param>
			</xsl:apply-templates>
			<xsl:apply-templates select="$following-entries" mode="adjacent">
				<xsl:with-param name="class">following</xsl:with-param>
			</xsl:apply-templates>
		</ol>
	</xsl:template>

	<xsl:template match="tei:entry | tei:re" mode="adjacent">
		<xsl:param name="class"/>

		<xsl:variable name="lemma-url">
			<xsl:call-template name="lemma-url">
				<xsl:with-param name="tei-entry" select="."/>
				<xsl:with-param name="dict-handle" select="$dict-handle"/>
			</xsl:call-template>
		</xsl:variable>

		<li class="{$class}">
			<xsl:apply-templates select="tei:form" mode="listing">
				<xsl:with-param name="linked-url" select="$lemma-url"/>
			</xsl:apply-templates>
		</li>
		<xsl:value-of select="$char-newline"/>
	</xsl:template>

	<xsl:template name="raw-tei">
		<details class="raw-tei">
			<summary>
				<xsl:text>[click to show TEI-XML code…]</xsl:text>
			</summary>
			<pre>
				<code>
					<xsl:call-template name="raw-xml">
						<xsl:with-param name="root" select="$tei-entry"/>
					</xsl:call-template>
				</code>
			</pre>
		</details>
	</xsl:template>

	<xsl:template name="citation-instructions">
		<xsl:variable name="lemma-title">
			<xsl:call-template name="text-and-transliterations">
				<xsl:with-param name="text" select="$tei-entry/tei:form/tei:orth/text()"/>
				<xsl:with-param name="rails-entry" select="$tei-entry/.."/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="lemma-id">
			<xsl:call-template name="lemma-url">
				<xsl:with-param name="dict-handle" select="$dict-handle"/>
				<xsl:with-param name="tei-entry" select="$tei-entry"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="lemma-url" select="/rails:variables/rails:request_url/text()"/>
		<xsl:variable name="author">FIXME: AUTHOR</xsl:variable>
		<xsl:variable name="publication">FIXME: DICTIONARY</xsl:variable>
		<xsl:variable name="publication-url">
			<xsl:value-of select="/rails:variables/rails:request_base_url/text()"/>
			<xsl:call-template name="dict-url">
				<xsl:with-param name="dict-handle" select="$dict-handle"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="project-url" select="/rails:variables/rails:request_base_url/text()"/>
		<xsl:variable name="date" select="substring-before(/rails:variables/rails:date/text(), ' ')"/>

		<details class="citation-instructions">
			<summary>
				<xsl:text>Cite this entry</xsl:text>
			</summary>
			<div>
				<dl>

					<dt><xsl:text>Text (for LibreOffice and Microsoft Word)</xsl:text></dt>
					<dd>
						<p>
							<xsl:value-of select="$lemma-title"/>
							<xsl:text>.</xsl:text>
							<xsl:value-of select="$char-space"/>

							<xsl:text>In</xsl:text>
							<xsl:value-of select="$char-space"/>
							<xsl:value-of select="$publication"/>
							<xsl:text>.</xsl:text>
							<xsl:value-of select="$char-space"/>

							<xsl:text>Retrieved</xsl:text>
							<xsl:value-of select="$char-space"/>
							<xsl:value-of select="$date"/>
							<xsl:text>,</xsl:text>
							<xsl:value-of select="$char-space"/>

							<xsl:text>from</xsl:text>
							<xsl:value-of select="$char-space"/>
							<xsl:value-of select="$lemma-url"/>
						</p>
					</dd>

					<dt><xsl:text>BibTeX</xsl:text></dt>
					<dd>
						<pre style="white-space: pre-line"><code>
							<xsl:variable name="indent">
								<span style="white-space: pre">
									<xsl:value-of select="$char-space"/>
									<xsl:value-of select="$char-space"/>
									<xsl:value-of select="$char-space"/>
									<xsl:value-of select="$char-space"/>
								</span>
							</xsl:variable>

							<xsl:text>@misc{</xsl:text>
							<xsl:value-of select="$char-newline"/>

							<xsl:copy-of select="$indent"/>
							<xsl:text>csl:</xsl:text>
							<xsl:value-of select="$lemma-id"/>
							<xsl:text>,</xsl:text>
							<xsl:value-of select="$char-newline"/>

							<xsl:copy-of select="$indent"/>
							<xsl:text>author = "</xsl:text>
							<xsl:value-of select="$author"/>
							<xsl:text>",</xsl:text>
							<xsl:value-of select="$char-newline"/>

							<xsl:copy-of select="$indent"/>
							<xsl:text>title = {{</xsl:text>
							<xsl:value-of select="$lemma-title"/>
							<xsl:value-of select="$char-space"/>
							<xsl:text>---</xsl:text>
{'fraction_non_alphanumeric': 0.21374458874458874, 'fraction_numerical': 0.0024737167594310453, 'mean_word_length': 3.75625, 'pattern_counts': {'":': 0, '<': 374, '<?xml version=': 2, '>': 374, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 12}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2339083', 'n_tokens_mistral': 5832, 'n_tokens_neox': 4474, 'n_words': 622}