<commit_before><?xml version="1.0"?>
<xsl:stylesheet version="1.0"
  xmlns="http://cnx.rice.edu/cnxml"
  xmlns:c="http://cnx.rice.edu/cnxml"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:xi="http://www.w3.org/2001/XInclude"
  
 xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rpt="http://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:rdfa="http://docs.oasis-open.org/opendocument/meta/rdfa#"  xmlns:m="http://www.w3.org/1998/Math/MathML"
  office:class="text" office:version="1.0"
  exclude-result-prefixes="office style text table draw fo xlink number svg chart dr3d math form script c"
  >


  <!-- This is a nasty pile of mess. Most of the styles code resides here
       and I didn't want to yank it from this version.
       Most of my edits can be found by searching for "xsl:processing-instruction"
  -->

  <xsl:output omit-xml-declaration="no" indent="yes" method="xml" />

  <!-- augmented input xml with /office:document-content/office:styles in oo2oo.xsl  -->
  <xsl:variable name="bold"/>

  <xsl:key name="bookmark" match="//text:bookmark" use="@text:name"/>

  <xsl:key name="bookmark-start" match="//text:bookmark-start" use="@text:name"/>
  
  <!-- We no longer need the list styles -->
  <xsl:template match="text:list-style"/>

  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="*">
    <xsl:processing-instruction name="cnx.warning">Could not match Open Office Element <xsl:value-of select="name()"/>. Converting children.</xsl:processing-instruction>
    <xsl:apply-templates select="node()"/>
  </xsl:template>

  <xsl:template match="draw:line|draw:g|draw:rectangle|draw:custom-shape|draw:enhanced-geometry">
    <xsl:processing-instruction name="cnx.warning">This importer does not support importing lines, rectangles, or other shapes</xsl:processing-instruction>
  </xsl:template>
<!-- Discard any ODT attributes -->
<xsl:template match="@text:*|@style:*"/>

<xsl:template match="text:note[text:note-citation]">
  <c:footnote id="import-auto-footnote-{text:note-citation/text()}">
    <xsl:apply-templates select="@*|node()"/>
  </c:footnote>
</xsl:template>
<xsl:template match="text:note/text:note-citation"/>
<xsl:template match="text:note/text:note-body">
  <xsl:apply-templates select="node()"/>
</xsl:template>

  <!-- Discard the :para element when it only contains c: elements -->
  <xsl:template match="text:p[normalize-space(text()) = '' and count(*) = count(c:*) and count(*) &gt;= 1]">
    <xsl:processing-instruction name="cnx.debug">Unwrapping a para around RED elements <xsl:for-each select="*"><xsl:value-of select="name()"/></xsl:for-each></xsl:processing-instruction>
    <xsl:apply-templates select="node()"/>
  </xsl:template>

  <!-- Preserve the @class="cnx.red-text" on a para that contains only 1 span with red text -->
  <xsl:template match="text:p[count(*[@class='cnx.red-text']) &gt; 0 and count(*[not(@class='cnx.red-text')]) = 0]">
    <para>
      <xsl:apply-templates select="*/@*"/>
      <xsl:apply-templates select="node()"/>
    </para>
  </xsl:template>
  
  <xsl:template match="text:span[@class='cnx.red-text']"><commit_msg>Don't strip paras from around inline elements in redtext.<commit_after><?xml version="1.0"?>
<xsl:stylesheet version="1.0"
  xmlns="http://cnx.rice.edu/cnxml"
  xmlns:c="http://cnx.rice.edu/cnxml"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:xi="http://www.w3.org/2001/XInclude"
  
 xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rpt="http://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:rdfa="http://docs.oasis-open.org/opendocument/meta/rdfa#"  xmlns:m="http://www.w3.org/1998/Math/MathML"
  office:class="text" office:version="1.0"
  exclude-result-prefixes="office style text table draw fo xlink number svg chart dr3d math form script c"
  >


  <!-- This is a nasty pile of mess. Most of the styles code resides here
       and I didn't want to yank it from this version.
       Most of my edits can be found by searching for "xsl:processing-instruction"
  -->

  <xsl:output omit-xml-declaration="no" indent="yes" method="xml" />

  <!-- augmented input xml with /office:document-content/office:styles in oo2oo.xsl  -->
  <xsl:variable name="bold"/>

  <xsl:key name="bookmark" match="//text:bookmark" use="@text:name"/>

  <xsl:key name="bookmark-start" match="//text:bookmark-start" use="@text:name"/>
  
  <!-- We no longer need the list styles -->
  <xsl:template match="text:list-style"/>

  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="*">
    <xsl:processing-instruction name="cnx.warning">Could not match Open Office Element <xsl:value-of select="name()"/>. Converting children.</xsl:processing-instruction>
    <xsl:apply-templates select="node()"/>
  </xsl:template>

  <xsl:template match="draw:line|draw:g|draw:rectangle|draw:custom-shape|draw:enhanced-geometry">
    <xsl:processing-instruction name="cnx.warning">This importer does not support importing lines, rectangles, or other shapes</xsl:processing-instruction>
  </xsl:template>
<!-- Discard any ODT attributes -->
<xsl:template match="@text:*|@style:*"/>

<xsl:template match="text:note[text:note-citation]">
  <c:footnote id="import-auto-footnote-{text:note-citation/text()}">
    <xsl:apply-templates select="@*|node()"/>
  </c:footnote>
</xsl:template>
<xsl:template match="text:note/text:note-citation"/>
<xsl:template match="text:note/text:note-body">
  <xsl:apply-templates select="node()"/>
</xsl:template>

  <!-- Discard the :para element when it only contains non-inline c: elements -->
  <xsl:template match="text:p[normalize-space(text()) = '' and
      count(*) = count(c:*) and count(*) &gt;= 1 and not(
        c:text-extras or c:span or c:term or c:cite or c:cite-title or
        c:foreign or c:emphasis or c:sub or c:sup or c:inline-code or
        c:inline-preformat or c:inline-quote or c:inline-note or
        c:inline-list or c:inline-media or c:footnote or c:link or
        c:newline or c:space
      )]">
    <xsl:processing-instruction name="cnx.debug">Unwrapping a para around RED elements <xsl:for-each select="*"><xsl:value-of select="name()"/></xsl:for-each></xsl:processing-instruction>
    <xsl:apply-templates select="node()"/>
  </xsl:template>

  <!-- Preserve the @class="cnx.red-text" on a para that contains only 1 span with red text -->
  <xsl:template match="text:p[count(*[@class='cnx.red-text']) &gt; 0 and count(*[not(@class='cnx.red-text')]) = 0]">
    <para>
      <xsl:apply-templates select="*/@*"/>
      <xsl:apply-templates select="node()"/>
    </para>
  </xsl:template>
  
  <xsl:template match="text:span[@class='cnx.red-text']">
{'fraction_non_alphanumeric': 0.1959863364645602, 'fraction_numerical': 0.02241673783091375, 'mean_word_length': 5.57935393258427, 'pattern_counts': {'":': 0, '<': 109, '<?xml version=': 2, '>': 109, 'https://': 0, 'lorem ipsum': 0, 'www.': 18, 'xml': 104}, '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': '2355514', 'n_tokens_mistral': 3662, 'n_tokens_neox': 3340, 'n_words': 523}