<commit_before><?xml version='1.0' encoding='UTF-8'?><!-- -*- indent-tabs-mode: nil -*- -->
<!--
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free
Software Foundation; either version 2 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 Lesser General Public License for more
details.

You should have received a copy of the GNU Lesser General Public License
along with this program; see the file COPYING.LGPL.  If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:mal="http://projectmallard.org/1.0/"
                xmlns:tt="http://www.w3.org/ns/ttml"
                xmlns:ttp="http://www.w3.org/ns/ttml#parameter"
                xmlns="http://www.w3.org/1999/xhtml"
                exclude-result-prefixes="mal tt ttp"
                version="1.0">

<!--!!==========================================================================
Mallard to HTML - Media Elements
Handle Mallard media elements.
:Revision:version="3.8" date="2012-11-05" status="final"

This stylesheet contains templates for handling Mallard #{media} elements.
It also handles TTML inside block audio and video #{media} elements.
-->


<!--**==========================================================================
mal2html.media.image
Output an #{img} element for an image.
:Revision:version="3.8" date="2012-11-05" status="final"
$node: The Mallard #{media} element.
$inline: Whether ${node} is inline.

This template outputs an HTML #{img} element for a Mallard #{media} element
with the #{type} attribute set to #{"image"} (or with no #{type} attribute).
If ${node} has fallback content, it is used for the #{alt} attribute.
-->
<xsl:template name="mal2html.media.image">
  <xsl:param name="node" select="."/>
  <xsl:param name="inline" select="false()"/>
  <img src="{$node/@src}">
    <xsl:copy-of select="@height"/>
    <xsl:copy-of select="@width"/>
    <xsl:attribute name="class">
      <xsl:text>media </xsl:text>
      <xsl:choose>
        <xsl:when test="$inline">
          <xsl:text>media-inline</xsl:text>
        </xsl:when>
        <xsl:otherwise>
          <xsl:text>media-block</xsl:text>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:attribute>
    <xsl:attribute name="alt">
      <xsl:choose>
        <xsl:when test="$inline">
          <xsl:value-of select="$node"/>
        </xsl:when>
        <xsl:otherwise>
          <!-- FIXME: This is not ideal.  Nested block container elements
               will introduce lots of garbage whitespace.  But then, XML
               processors are supposed to normalize whitespace in attribute
               values anyway.  Ideally, we'd have a set of modes for text
               conversion.  That'd probably be best handled in a set of
               mal2text stylesheets.
          -->
          <xsl:for-each select="$node/mal:*">
            <xsl:if test="position() &gt; 1">
              <xsl:text>&#x000A;</xsl:text>
            </xsl:if>
            <xsl:value-of select="string(.)"/>
          </xsl:for-each>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:attribute>
  </img>
</xsl:template>

<!--**==========================================================================
mal2html.media.video
Output a #{video} element for a video.
:Revision:version="3.8" date="2012-11-05" status="final"
$node: The Mallard #{media} element.
$inline: Whether ${node} is inline.

This template outputs an HTML #{video} element for a Mallard #{media} element
with the #{type} attribute set to #{"video"}. It converts any fallback content
in the source to the #{video} element's fallback content. If ${inline} is
#{false}, this template will process TTML child content.
-->
<xsl:template name="mal2html.media.video">
  <xsl:param name="node" select="."/>
  <xsl:param name="inline" select="false()"/>
  <video src="{$node/@src}" preload="auto" controls="controls">
    <xsl:attribute name="class">
      <xsl:text>media </xsl:text>
      <xsl:choose>
        <xsl:when test="$inline">
          <xsl:text>media-inline</xsl:text>
        </xsl:when>
        <xsl:otherwise>
          <xsl:text>media-block</xsl:text>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:attribute>
    <xsl:copy-of select="$node/@height"/>
    <xsl:copy-of select="$node/@width"/>
    <xsl:attribute name="data-play-label">
      <xsl:call-template name="l10n.gettext">
        <xsl:with-param name="msgid" select="'Play'"/>
      </xsl:call-template>
    </xsl:attribute>
    <xsl:attribute name="data-pause-label">
      <xsl:call-template name="l10n.gettext">
        <xsl:with-param name="msgid" select="'Pause'"/>
      </xsl:call-template>
    </xsl:attribute>
    <xsl:choose>
      <xsl:when test="$inline">
        <xsl:apply-templates mode="mal2html.inline.mode" select="$node/node()"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:apply-templates mode="mal2html.block.mode" select="$node/node()"/>
      </xsl:otherwise>
    </xsl:choose>
  </video><commit_msg>mal2html-media: poster attribute for HTML video<commit_after><?xml version='1.0' encoding='UTF-8'?><!-- -*- indent-tabs-mode: nil -*- -->
<!--
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free
Software Foundation; either version 2 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 Lesser General Public License for more
details.

You should have received a copy of the GNU Lesser General Public License
along with this program; see the file COPYING.LGPL.  If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:mal="http://projectmallard.org/1.0/"
                xmlns:tt="http://www.w3.org/ns/ttml"
                xmlns:ttp="http://www.w3.org/ns/ttml#parameter"
                xmlns="http://www.w3.org/1999/xhtml"
                exclude-result-prefixes="mal tt ttp"
                version="1.0">

<!--!!==========================================================================
Mallard to HTML - Media Elements
Handle Mallard media elements.
:Revision:version="3.8" date="2012-11-05" status="final"

This stylesheet contains templates for handling Mallard #{media} elements.
It also handles TTML inside block audio and video #{media} elements.
-->


<!--**==========================================================================
mal2html.media.image
Output an #{img} element for an image.
:Revision:version="3.8" date="2012-11-05" status="final"
$node: The Mallard #{media} element.
$inline: Whether ${node} is inline.

This template outputs an HTML #{img} element for a Mallard #{media} element
with the #{type} attribute set to #{"image"} (or with no #{type} attribute).
If ${node} has fallback content, it is used for the #{alt} attribute.
-->
<xsl:template name="mal2html.media.image">
  <xsl:param name="node" select="."/>
  <xsl:param name="inline" select="false()"/>
  <img src="{$node/@src}">
    <xsl:copy-of select="@height"/>
    <xsl:copy-of select="@width"/>
    <xsl:attribute name="class">
      <xsl:text>media </xsl:text>
      <xsl:choose>
        <xsl:when test="$inline">
          <xsl:text>media-inline</xsl:text>
        </xsl:when>
        <xsl:otherwise>
          <xsl:text>media-block</xsl:text>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:attribute>
    <xsl:attribute name="alt">
      <xsl:choose>
        <xsl:when test="$inline">
          <xsl:value-of select="$node"/>
        </xsl:when>
        <xsl:otherwise>
          <!-- FIXME: This is not ideal.  Nested block container elements
               will introduce lots of garbage whitespace.  But then, XML
               processors are supposed to normalize whitespace in attribute
               values anyway.  Ideally, we'd have a set of modes for text
               conversion.  That'd probably be best handled in a set of
               mal2text stylesheets.
          -->
          <xsl:for-each select="$node/mal:*">
            <xsl:if test="position() &gt; 1">
              <xsl:text>&#x000A;</xsl:text>
            </xsl:if>
            <xsl:value-of select="string(.)"/>
          </xsl:for-each>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:attribute>
  </img>
</xsl:template>

<!--**==========================================================================
mal2html.media.video
Output a #{video} element for a video.
:Revision:version="3.8" date="2012-11-05" status="final"
$node: The Mallard #{media} element.
$inline: Whether ${node} is inline.

This template outputs an HTML #{video} element for a Mallard #{media} element
with the #{type} attribute set to #{"video"}. It converts any fallback content
in the source to the #{video} element's fallback content. If ${inline} is
#{false}, this template will process TTML child content.

If ${node} has a child image #{media} element with the #{style} attribute set
to #{"poster"}, that image will be used for the #{poster} attribute on the
HTML #{video} element.
-->
<xsl:template name="mal2html.media.video">
  <xsl:param name="node" select="."/>
  <xsl:param name="inline" select="false()"/>
  <video src="{$node/@src}" preload="auto" controls="controls">
    <xsl:attribute name="class">
      <xsl:text>media </xsl:text>
      <xsl:choose>
        <xsl:when test="$inline">
          <xsl:text>media-inline</xsl:text>
        </xsl:when>
        <xsl:otherwise>
          <xsl:text>media-block</xsl:text>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:attribute>
    <xsl:copy-of select="$node/@height"/>
    <xsl:copy-of select="$node/@width"/>
    <xsl:variable name="poster"
                  select="$node/mal:media[not(@type) or @type = 'image'][@style = 'poster']"/>
    <xsl:if test="$poster">
      <xsl:attribute name="poster">
        <xsl:value-of select="$poster[1]/@src"/>
      </xsl:attribute>
    </xsl:if>
    <xsl:attribute name="data-play-label">
      <xsl:call-template name="l10n.gettext">
        <xsl:with-param name="msgid" select="'Play'"/>
      </xsl:call-template>
    </xsl:attribute>
    <xsl:attribute name="data-pause-label">
      <xsl:call-template name="l10n.gettext">
        <xsl:with-param name="msgid" select="'Pause'"/>
      </xsl:call-template>
    </xsl:attribute>
    <xsl:choose>
      <xsl:when test="$inline">
        <xsl:apply-templates mode="mal2html.inline.mode" select="$node/node()"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:apply-templates mode="mal2html.block.mode" select="$node/node()"/>
      </xsl:otherwise>
    </xsl:choose>
  </video>
{'fraction_non_alphanumeric': 0.19019607843137254, 'fraction_numerical': 0.0142602495543672, 'mean_word_length': 3.1528497409326426, 'pattern_counts': {'":': 0, '<': 179, '<?xml version=': 2, '>': 179, 'https://': 0, 'lorem ipsum': 0, 'www.': 8, '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': '1542159', 'n_tokens_mistral': 3602, 'n_tokens_neox': 3248, 'n_words': 954}