mitimes-htmltoword 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.md +179 -0
- data/Rakefile +4 -0
- data/bin/htmltoword +36 -0
- data/lib/htmltoword.rb +28 -0
- data/lib/htmltoword/configuration.rb +12 -0
- data/lib/htmltoword/document.rb +96 -0
- data/lib/htmltoword/helpers/templates_helper.rb +9 -0
- data/lib/htmltoword/helpers/xslt_helper.rb +17 -0
- data/lib/htmltoword/railtie.rb +25 -0
- data/lib/htmltoword/renderer.rb +43 -0
- data/lib/htmltoword/templates/default.docx +0 -0
- data/lib/htmltoword/version.rb +3 -0
- data/lib/htmltoword/xslt/base.xslt +338 -0
- data/lib/htmltoword/xslt/cleanup.xslt +71 -0
- data/lib/htmltoword/xslt/extras.xslt +26 -0
- data/lib/htmltoword/xslt/functions.xslt +34 -0
- data/lib/htmltoword/xslt/htmltoword.xslt +21 -0
- data/lib/htmltoword/xslt/inline_elements.xslt +40 -0
- data/lib/htmltoword/xslt/links.xslt +35 -0
- data/lib/htmltoword/xslt/numbering.xslt +189 -0
- data/lib/htmltoword/xslt/relations.xslt +26 -0
- data/lib/htmltoword/xslt/style2.xslt +49 -0
- data/lib/htmltoword/xslt/tables.xslt +187 -0
- metadata +182 -0
| Binary file | 
| @@ -0,0 +1,338 @@ | |
| 1 | 
            +
            <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
         | 
| 2 | 
            +
                            xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
         | 
| 3 | 
            +
                            xmlns:o="urn:schemas-microsoft-com:office:office"
         | 
| 4 | 
            +
                            xmlns:v="urn:schemas-microsoft-com:vml"
         | 
| 5 | 
            +
                            xmlns:WX="http://schemas.microsoft.com/office/word/2003/auxHint"
         | 
| 6 | 
            +
                            xmlns:aml="http://schemas.microsoft.com/aml/2001/core"
         | 
| 7 | 
            +
                            xmlns:w10="urn:schemas-microsoft-com:office:word"
         | 
| 8 | 
            +
                            xmlns:pkg="http://schemas.microsoft.com/office/2006/xmlPackage"
         | 
| 9 | 
            +
                            xmlns:msxsl="urn:schemas-microsoft-com:xslt"
         | 
| 10 | 
            +
                            xmlns:ext="http://www.xmllab.net/wordml2html/ext"
         | 
| 11 | 
            +
                            xmlns:java="http://xml.apache.org/xalan/java"
         | 
| 12 | 
            +
                            xmlns:str="http://exslt.org/strings"
         | 
| 13 | 
            +
                            xmlns:func="http://exslt.org/functions"
         | 
| 14 | 
            +
                            xmlns:fn="http://www.w3.org/2005/xpath-functions"
         | 
| 15 | 
            +
                            version="1.0"
         | 
| 16 | 
            +
                            exclude-result-prefixes="java msxsl ext w o v WX aml w10"
         | 
| 17 | 
            +
                            extension-element-prefixes="func">
         | 
| 18 | 
            +
              <xsl:output method="xml" encoding="utf-8" omit-xml-declaration="yes" indent="yes" />
         | 
| 19 | 
            +
              <xsl:include href="./functions.xslt"/>
         | 
| 20 | 
            +
              <xsl:include href="./tables.xslt"/>
         | 
| 21 | 
            +
              <xsl:include href="./links.xslt"/>
         | 
| 22 | 
            +
             | 
| 23 | 
            +
              <xsl:template match="/">
         | 
| 24 | 
            +
                <xsl:apply-templates />
         | 
| 25 | 
            +
              </xsl:template>
         | 
| 26 | 
            +
             | 
| 27 | 
            +
              <xsl:template match="head" />
         | 
| 28 | 
            +
             | 
| 29 | 
            +
              <xsl:template match="body">
         | 
| 30 | 
            +
                <xsl:comment>
         | 
| 31 | 
            +
                  KNOWN BUGS:
         | 
| 32 | 
            +
                  div
         | 
| 33 | 
            +
                    h2
         | 
| 34 | 
            +
                    div
         | 
| 35 | 
            +
                      textnode (WONT BE WRAPPED IN A W:P)
         | 
| 36 | 
            +
                      div
         | 
| 37 | 
            +
                        table
         | 
| 38 | 
            +
                        span
         | 
| 39 | 
            +
                          text
         | 
| 40 | 
            +
                </xsl:comment>
         | 
| 41 | 
            +
                <xsl:apply-templates/>
         | 
| 42 | 
            +
              </xsl:template>
         | 
| 43 | 
            +
             | 
| 44 | 
            +
              <xsl:template match="body/*[not(*)]">
         | 
| 45 | 
            +
                <w:p>
         | 
| 46 | 
            +
                  <xsl:call-template name="text-alignment" />
         | 
| 47 | 
            +
                  <w:r>
         | 
| 48 | 
            +
                    <w:t xml:space="preserve"><xsl:value-of select="."/></w:t>
         | 
| 49 | 
            +
                  </w:r>
         | 
| 50 | 
            +
                </w:p>
         | 
| 51 | 
            +
              </xsl:template>
         | 
| 52 | 
            +
             | 
| 53 | 
            +
             | 
| 54 | 
            +
              <xsl:template match="br[not(ancestor::p) and not(ancestor::div) and not(ancestor::td|ancestor::li) or
         | 
| 55 | 
            +
                                      (preceding-sibling::div or following-sibling::div or preceding-sibling::p or following-sibling::p)]">
         | 
| 56 | 
            +
                <w:p>
         | 
| 57 | 
            +
                  <w:r></w:r>
         | 
| 58 | 
            +
                </w:p>
         | 
| 59 | 
            +
              </xsl:template>
         | 
| 60 | 
            +
             | 
| 61 | 
            +
              <xsl:template match="br[(ancestor::li or ancestor::td) and
         | 
| 62 | 
            +
                                      (preceding-sibling::div or following-sibling::div or preceding-sibling::p or following-sibling::p)]">
         | 
| 63 | 
            +
                <w:r>
         | 
| 64 | 
            +
                  <w:br />
         | 
| 65 | 
            +
                </w:r>
         | 
| 66 | 
            +
              </xsl:template>
         | 
| 67 | 
            +
             | 
| 68 | 
            +
              <xsl:template match="br">
         | 
| 69 | 
            +
                <w:r>
         | 
| 70 | 
            +
                  <w:br />
         | 
| 71 | 
            +
                </w:r>
         | 
| 72 | 
            +
              </xsl:template>
         | 
| 73 | 
            +
             | 
| 74 | 
            +
              <xsl:template match="pre">
         | 
| 75 | 
            +
                <w:p>
         | 
| 76 | 
            +
                  <xsl:apply-templates />
         | 
| 77 | 
            +
                </w:p>
         | 
| 78 | 
            +
              </xsl:template>
         | 
| 79 | 
            +
             | 
| 80 | 
            +
              <xsl:template match="div[not(ancestor::li) and not(ancestor::td) and not(ancestor::th) and not(ancestor::p) and not(descendant::div) and not(descendant::p) and not(descendant::h1) and not(descendant::h2) and not(descendant::h3) and not(descendant::h4) and not(descendant::h5) and not(descendant::h6) and not(descendant::table) and not(descendant::li) and not (descendant::pre)]">
         | 
| 81 | 
            +
                <xsl:comment>Divs should create a p if nothing above them has and nothing below them will</xsl:comment>
         | 
| 82 | 
            +
                <w:p>
         | 
| 83 | 
            +
                  <xsl:call-template name="text-alignment" />
         | 
| 84 | 
            +
                  <xsl:apply-templates />
         | 
| 85 | 
            +
                </w:p>
         | 
| 86 | 
            +
              </xsl:template>
         | 
| 87 | 
            +
             | 
| 88 | 
            +
              <xsl:template match="div">
         | 
| 89 | 
            +
                <xsl:apply-templates />
         | 
| 90 | 
            +
              </xsl:template>
         | 
| 91 | 
            +
             | 
| 92 | 
            +
              <!-- TODO: make this prettier. Headings shouldn't enter in template from L51 -->
         | 
| 93 | 
            +
              <xsl:template match="body/h1|body/h2|body/h3|body/h4|body/h5|body/h6|h1|h2|h3|h4|h5|h6">
         | 
| 94 | 
            +
                <xsl:variable name="length" select="string-length(name(.))"/>
         | 
| 95 | 
            +
                <w:p>
         | 
| 96 | 
            +
                  <w:pPr>
         | 
| 97 | 
            +
                    <w:pStyle w:val="Heading{substring(name(.),$length)}"/>
         | 
| 98 | 
            +
                  </w:pPr>
         | 
| 99 | 
            +
                  <w:r>
         | 
| 100 | 
            +
                    <w:t xml:space="preserve"><xsl:value-of select="."/></w:t>
         | 
| 101 | 
            +
                  </w:r>
         | 
| 102 | 
            +
                </w:p>
         | 
| 103 | 
            +
              </xsl:template>
         | 
| 104 | 
            +
             | 
| 105 | 
            +
              <xsl:template match="p[not(ancestor::li)]">
         | 
| 106 | 
            +
                <w:p>
         | 
| 107 | 
            +
                  <xsl:call-template name="text-alignment" />
         | 
| 108 | 
            +
                  <xsl:apply-templates />
         | 
| 109 | 
            +
                </w:p>
         | 
| 110 | 
            +
              </xsl:template>
         | 
| 111 | 
            +
             | 
| 112 | 
            +
              <xsl:template match="ol|ul">
         | 
| 113 | 
            +
                <xsl:param name="global_level" select="count(preceding::ol[not(ancestor::ol or ancestor::ul)]) + count(preceding::ul[not(ancestor::ol or ancestor::ul)]) + 1"/>
         | 
| 114 | 
            +
                <xsl:apply-templates>
         | 
| 115 | 
            +
                  <xsl:with-param name="global_level" select="$global_level" />
         | 
| 116 | 
            +
                </xsl:apply-templates>
         | 
| 117 | 
            +
              </xsl:template>
         | 
| 118 | 
            +
             | 
| 119 | 
            +
              <xsl:template name="listItem" match="li">
         | 
| 120 | 
            +
                <xsl:param name="global_level" />
         | 
| 121 | 
            +
                <xsl:param name="preceding-siblings" select="0"/>
         | 
| 122 | 
            +
                <xsl:for-each select="node()">
         | 
| 123 | 
            +
                  <xsl:choose>
         | 
| 124 | 
            +
                    <xsl:when test="self::br">
         | 
| 125 | 
            +
                      <w:p>
         | 
| 126 | 
            +
                        <w:pPr>
         | 
| 127 | 
            +
                          <w:pStyle w:val="ListParagraph"></w:pStyle>
         | 
| 128 | 
            +
                          <w:numPr>
         | 
| 129 | 
            +
                            <w:ilvl w:val="0"/>
         | 
| 130 | 
            +
                            <w:numId w:val="0"/>
         | 
| 131 | 
            +
                          </w:numPr>
         | 
| 132 | 
            +
                        </w:pPr>
         | 
| 133 | 
            +
                        <w:r></w:r>
         | 
| 134 | 
            +
                      </w:p>
         | 
| 135 | 
            +
                    </xsl:when>
         | 
| 136 | 
            +
                    <xsl:when test="self::ol|self::ul">
         | 
| 137 | 
            +
                      <xsl:apply-templates>
         | 
| 138 | 
            +
                        <xsl:with-param name="global_level" select="$global_level" />
         | 
| 139 | 
            +
                      </xsl:apply-templates>
         | 
| 140 | 
            +
                    </xsl:when>
         | 
| 141 | 
            +
                    <xsl:when test="not(descendant::li)"> <!-- simpler div, p, headings, etc... -->
         | 
| 142 | 
            +
                      <xsl:variable name="ilvl" select="count(ancestor::ol) + count(ancestor::ul) - 1"></xsl:variable>
         | 
| 143 | 
            +
                      <xsl:choose>
         | 
| 144 | 
            +
                        <xsl:when test="$preceding-siblings + count(preceding-sibling::*) > 0">
         | 
| 145 | 
            +
                          <w:p>
         | 
| 146 | 
            +
                            <w:pPr>
         | 
| 147 | 
            +
                              <w:pStyle w:val="ListParagraph"></w:pStyle>
         | 
| 148 | 
            +
                              <w:numPr>
         | 
| 149 | 
            +
                                <w:ilvl w:val="0"/>
         | 
| 150 | 
            +
                                <w:numId w:val="0"/>
         | 
| 151 | 
            +
                              </w:numPr>
         | 
| 152 | 
            +
                              <w:ind w:left="{720 * ($ilvl + 1)}"/>
         | 
| 153 | 
            +
                            </w:pPr>
         | 
| 154 | 
            +
                            <xsl:apply-templates/>
         | 
| 155 | 
            +
                          </w:p>
         | 
| 156 | 
            +
                        </xsl:when>
         | 
| 157 | 
            +
                        <xsl:otherwise>
         | 
| 158 | 
            +
                          <w:p>
         | 
| 159 | 
            +
                            <w:pPr>
         | 
| 160 | 
            +
                              <w:pStyle w:val="ListParagraph"></w:pStyle>
         | 
| 161 | 
            +
                              <w:numPr>
         | 
| 162 | 
            +
                                <w:ilvl w:val="{$ilvl}"/>
         | 
| 163 | 
            +
                                <w:numId w:val="{$global_level}"/>
         | 
| 164 | 
            +
                              </w:numPr>
         | 
| 165 | 
            +
                            </w:pPr>
         | 
| 166 | 
            +
                            <xsl:apply-templates/>
         | 
| 167 | 
            +
                          </w:p>
         | 
| 168 | 
            +
                        </xsl:otherwise>
         | 
| 169 | 
            +
                      </xsl:choose>
         | 
| 170 | 
            +
                    </xsl:when>
         | 
| 171 | 
            +
                    <xsl:otherwise> <!-- mixed things div having list and stuff content... -->
         | 
| 172 | 
            +
                      <xsl:call-template name="listItem">
         | 
| 173 | 
            +
                        <xsl:with-param name="global_level" select="$global_level" />
         | 
| 174 | 
            +
                        <xsl:with-param name="preceding-siblings" select="$preceding-siblings + count(preceding-sibling::*)" />
         | 
| 175 | 
            +
                      </xsl:call-template>
         | 
| 176 | 
            +
                    </xsl:otherwise>
         | 
| 177 | 
            +
                  </xsl:choose>
         | 
| 178 | 
            +
                </xsl:for-each>
         | 
| 179 | 
            +
              </xsl:template>
         | 
| 180 | 
            +
             | 
| 181 | 
            +
              <xsl:template match="span[not(ancestor::td) and not(ancestor::li) and (preceding-sibling::h1 or preceding-sibling::h2 or preceding-sibling::h3 or preceding-sibling::h4 or preceding-sibling::h5 or preceding-sibling::h6 or preceding-sibling::table or preceding-sibling::p or preceding-sibling::ol or preceding-sibling::ul or preceding-sibling::div or following-sibling::h1 or following-sibling::h2 or following-sibling::h3 or following-sibling::h4 or following-sibling::h5 or following-sibling::h6 or following-sibling::table or following-sibling::p or following-sibling::ol or following-sibling::ul or following-sibling::div)]
         | 
| 182 | 
            +
                |a[not(ancestor::td) and not(ancestor::li) and (preceding-sibling::h1 or preceding-sibling::h2 or preceding-sibling::h3 or preceding-sibling::h4 or preceding-sibling::h5 or preceding-sibling::h6 or preceding-sibling::table or preceding-sibling::p or preceding-sibling::ol or preceding-sibling::ul or preceding-sibling::div or following-sibling::h1 or following-sibling::h2 or following-sibling::h3 or following-sibling::h4 or following-sibling::h5 or following-sibling::h6 or following-sibling::table or following-sibling::p or following-sibling::ol or following-sibling::ul or following-sibling::div)]
         | 
| 183 | 
            +
                |small[not(ancestor::td) and not(ancestor::li) and (preceding-sibling::h1 or preceding-sibling::h2 or preceding-sibling::h3 or preceding-sibling::h4 or preceding-sibling::h5 or preceding-sibling::h6 or preceding-sibling::table or preceding-sibling::p or preceding-sibling::ol or preceding-sibling::ul or preceding-sibling::div or following-sibling::h1 or following-sibling::h2 or following-sibling::h3 or following-sibling::h4 or following-sibling::h5 or following-sibling::h6 or following-sibling::table or following-sibling::p or following-sibling::ol or following-sibling::ul or following-sibling::div)]
         | 
| 184 | 
            +
                |strong[not(ancestor::td) and not(ancestor::li) and (preceding-sibling::h1 or preceding-sibling::h2 or preceding-sibling::h3 or preceding-sibling::h4 or preceding-sibling::h5 or preceding-sibling::h6 or preceding-sibling::table or preceding-sibling::p or preceding-sibling::ol or preceding-sibling::ul or preceding-sibling::div or following-sibling::h1 or following-sibling::h2 or following-sibling::h3 or following-sibling::h4 or following-sibling::h5 or following-sibling::h6 or following-sibling::table or following-sibling::p or following-sibling::ol or following-sibling::ul or following-sibling::div)]
         | 
| 185 | 
            +
                |em[not(ancestor::td) and not(ancestor::li) and (preceding-sibling::h1 or preceding-sibling::h2 or preceding-sibling::h3 or preceding-sibling::h4 or preceding-sibling::h5 or preceding-sibling::h6 or preceding-sibling::table or preceding-sibling::p or preceding-sibling::ol or preceding-sibling::ul or preceding-sibling::div or following-sibling::h1 or following-sibling::h2 or following-sibling::h3 or following-sibling::h4 or following-sibling::h5 or following-sibling::h6 or following-sibling::table or following-sibling::p or following-sibling::ol or following-sibling::ul or following-sibling::div)]
         | 
| 186 | 
            +
                |i[not(ancestor::td) and not(ancestor::li) and (preceding-sibling::h1 or preceding-sibling::h2 or preceding-sibling::h3 or preceding-sibling::h4 or preceding-sibling::h5 or preceding-sibling::h6 or preceding-sibling::table or preceding-sibling::p or preceding-sibling::ol or preceding-sibling::ul or preceding-sibling::div or following-sibling::h1 or following-sibling::h2 or following-sibling::h3 or following-sibling::h4 or following-sibling::h5 or following-sibling::h6 or following-sibling::table or following-sibling::p or following-sibling::ol or following-sibling::ul or following-sibling::div)]
         | 
| 187 | 
            +
                |b[not(ancestor::td) and not(ancestor::li) and (preceding-sibling::h1 or preceding-sibling::h2 or preceding-sibling::h3 or preceding-sibling::h4 or preceding-sibling::h5 or preceding-sibling::h6 or preceding-sibling::table or preceding-sibling::p or preceding-sibling::ol or preceding-sibling::ul or preceding-sibling::div or following-sibling::h1 or following-sibling::h2 or following-sibling::h3 or following-sibling::h4 or following-sibling::h5 or following-sibling::h6 or following-sibling::table or following-sibling::p or following-sibling::ol or following-sibling::ul or following-sibling::div)]
         | 
| 188 | 
            +
                |u[not(ancestor::td) and not(ancestor::li) and (preceding-sibling::h1 or preceding-sibling::h2 or preceding-sibling::h3 or preceding-sibling::h4 or preceding-sibling::h5 or preceding-sibling::h6 or preceding-sibling::table or preceding-sibling::p or preceding-sibling::ol or preceding-sibling::ul or preceding-sibling::div or following-sibling::h1 or following-sibling::h2 or following-sibling::h3 or following-sibling::h4 or following-sibling::h5 or following-sibling::h6 or following-sibling::table or following-sibling::p or following-sibling::ol or following-sibling::ul or following-sibling::div)]">
         | 
| 189 | 
            +
                <xsl:comment>
         | 
| 190 | 
            +
                    In the following situation:
         | 
| 191 | 
            +
             | 
| 192 | 
            +
                    div
         | 
| 193 | 
            +
                      h2
         | 
| 194 | 
            +
                      span
         | 
| 195 | 
            +
                        textnode
         | 
| 196 | 
            +
                        span
         | 
| 197 | 
            +
                          textnode
         | 
| 198 | 
            +
                      p
         | 
| 199 | 
            +
             | 
| 200 | 
            +
                    The div template will not create a w:p because the div contains a h2. Therefore we need to wrap the inline elements span|a|small in a p here.
         | 
| 201 | 
            +
                  </xsl:comment>
         | 
| 202 | 
            +
                <w:p>
         | 
| 203 | 
            +
                  <xsl:choose>
         | 
| 204 | 
            +
                    <xsl:when test="self::a[starts-with(@href, 'http://') or starts-with(@href, 'https://')]">
         | 
| 205 | 
            +
                      <xsl:call-template name="link" />
         | 
| 206 | 
            +
                    </xsl:when>
         | 
| 207 | 
            +
                    <xsl:otherwise>
         | 
| 208 | 
            +
                      <xsl:apply-templates />
         | 
| 209 | 
            +
                    </xsl:otherwise>
         | 
| 210 | 
            +
                  </xsl:choose>
         | 
| 211 | 
            +
                </w:p>
         | 
| 212 | 
            +
              </xsl:template>
         | 
| 213 | 
            +
             | 
| 214 | 
            +
              <xsl:template match="text()[not(parent::li) and not(parent::td) and not(parent::pre) and (preceding-sibling::h1 or preceding-sibling::h2 or preceding-sibling::h3 or preceding-sibling::h4 or preceding-sibling::h5 or preceding-sibling::h6 or preceding-sibling::table or preceding-sibling::p or preceding-sibling::ol or preceding-sibling::ul or preceding-sibling::div or following-sibling::h1 or following-sibling::h2 or following-sibling::h3 or following-sibling::h4 or following-sibling::h5 or following-sibling::h6 or following-sibling::table or following-sibling::p or following-sibling::ol or following-sibling::ul or following-sibling::div)]">
         | 
| 215 | 
            +
                <xsl:comment>
         | 
| 216 | 
            +
                    In the following situation:
         | 
| 217 | 
            +
             | 
| 218 | 
            +
                    div
         | 
| 219 | 
            +
                      h2
         | 
| 220 | 
            +
                      textnode
         | 
| 221 | 
            +
                      p
         | 
| 222 | 
            +
             | 
| 223 | 
            +
                    The div template will not create a w:p because the div contains a h2. Therefore we need to wrap the textnode in a p here.
         | 
| 224 | 
            +
                  </xsl:comment>
         | 
| 225 | 
            +
                <w:p>
         | 
| 226 | 
            +
                  <w:r>
         | 
| 227 | 
            +
                    <w:t xml:space="preserve"><xsl:value-of select="."/></w:t>
         | 
| 228 | 
            +
                  </w:r>
         | 
| 229 | 
            +
                </w:p>
         | 
| 230 | 
            +
              </xsl:template>
         | 
| 231 | 
            +
             | 
| 232 | 
            +
              <xsl:template match="span[contains(concat(' ', @class, ' '), ' h ')]">
         | 
| 233 | 
            +
                <xsl:comment>
         | 
| 234 | 
            +
                    This template adds MS Word highlighting ability.
         | 
| 235 | 
            +
                  </xsl:comment>
         | 
| 236 | 
            +
                <xsl:variable name="color">
         | 
| 237 | 
            +
                  <xsl:choose>
         | 
| 238 | 
            +
                    <xsl:when test="./@data-style='pink'">magenta</xsl:when>
         | 
| 239 | 
            +
                    <xsl:when test="./@data-style='blue'">cyan</xsl:when>
         | 
| 240 | 
            +
                    <xsl:when test="./@data-style='orange'">darkYellow</xsl:when>
         | 
| 241 | 
            +
                    <xsl:otherwise><xsl:value-of select="./@data-style"/></xsl:otherwise>
         | 
| 242 | 
            +
                  </xsl:choose>
         | 
| 243 | 
            +
                </xsl:variable>
         | 
| 244 | 
            +
                <xsl:choose>
         | 
| 245 | 
            +
                  <xsl:when test="preceding-sibling::h1 or preceding-sibling::h2 or preceding-sibling::h3 or preceding-sibling::h4 or preceding-sibling::h5 or preceding-sibling::h6 or preceding-sibling::table or preceding-sibling::p or preceding-sibling::ol or preceding-sibling::ul or preceding-sibling::div or following-sibling::h1 or following-sibling::h2 or following-sibling::h3 or following-sibling::h4 or following-sibling::h5 or following-sibling::h6 or following-sibling::table or following-sibling::p or following-sibling::ol or following-sibling::ul or following-sibling::div">
         | 
| 246 | 
            +
                    <w:p>
         | 
| 247 | 
            +
                      <w:r>
         | 
| 248 | 
            +
                        <w:rPr>
         | 
| 249 | 
            +
                          <w:highlight w:val="{$color}"/>
         | 
| 250 | 
            +
                        </w:rPr>
         | 
| 251 | 
            +
                        <w:t xml:space="preserve"><xsl:value-of select="."/></w:t>
         | 
| 252 | 
            +
                      </w:r>
         | 
| 253 | 
            +
                    </w:p>
         | 
| 254 | 
            +
                  </xsl:when>
         | 
| 255 | 
            +
                  <xsl:otherwise>
         | 
| 256 | 
            +
                    <w:r>
         | 
| 257 | 
            +
                      <w:rPr>
         | 
| 258 | 
            +
                        <w:highlight w:val="{$color}"/>
         | 
| 259 | 
            +
                      </w:rPr>
         | 
| 260 | 
            +
                      <w:t xml:space="preserve"><xsl:value-of select="."/></w:t>
         | 
| 261 | 
            +
                    </w:r>
         | 
| 262 | 
            +
                  </xsl:otherwise>
         | 
| 263 | 
            +
                </xsl:choose>
         | 
| 264 | 
            +
              </xsl:template>
         | 
| 265 | 
            +
             | 
| 266 | 
            +
              <xsl:template match="div[contains(concat(' ', @class, ' '), ' -page-break ')]">
         | 
| 267 | 
            +
                <w:p>
         | 
| 268 | 
            +
                  <w:r>
         | 
| 269 | 
            +
                    <w:br w:type="page" />
         | 
| 270 | 
            +
                  </w:r>
         | 
| 271 | 
            +
                </w:p>
         | 
| 272 | 
            +
                <xsl:apply-templates />
         | 
| 273 | 
            +
              </xsl:template>
         | 
| 274 | 
            +
             | 
| 275 | 
            +
              <xsl:template match="details" />
         | 
| 276 | 
            +
             | 
| 277 | 
            +
              <xsl:template match="text()">
         | 
| 278 | 
            +
                <xsl:if test="string-length(.) > 0">
         | 
| 279 | 
            +
                  <w:r>
         | 
| 280 | 
            +
                    <xsl:if test="ancestor::i">
         | 
| 281 | 
            +
                      <w:rPr>
         | 
| 282 | 
            +
                        <w:i />
         | 
| 283 | 
            +
                      </w:rPr>
         | 
| 284 | 
            +
                    </xsl:if>
         | 
| 285 | 
            +
                    <xsl:if test="ancestor::b">
         | 
| 286 | 
            +
                      <w:rPr>
         | 
| 287 | 
            +
                        <w:b />
         | 
| 288 | 
            +
                      </w:rPr>
         | 
| 289 | 
            +
                    </xsl:if>
         | 
| 290 | 
            +
                    <xsl:if test="ancestor::u">
         | 
| 291 | 
            +
                      <w:rPr>
         | 
| 292 | 
            +
                        <w:u w:val="single"/>
         | 
| 293 | 
            +
                      </w:rPr>
         | 
| 294 | 
            +
                    </xsl:if>
         | 
| 295 | 
            +
                    <xsl:if test="ancestor::s">
         | 
| 296 | 
            +
                      <w:rPr>
         | 
| 297 | 
            +
                        <w:strike w:val="true"/>
         | 
| 298 | 
            +
                      </w:rPr>
         | 
| 299 | 
            +
                    </xsl:if>
         | 
| 300 | 
            +
                    <xsl:if test="ancestor::sub">
         | 
| 301 | 
            +
                      <w:rPr>
         | 
| 302 | 
            +
                        <w:vertAlign w:val="subscript"/>
         | 
| 303 | 
            +
                      </w:rPr>
         | 
| 304 | 
            +
                    </xsl:if>
         | 
| 305 | 
            +
                    <xsl:if test="ancestor::sup">
         | 
| 306 | 
            +
                      <w:rPr>
         | 
| 307 | 
            +
                        <w:vertAlign w:val="superscript"/>
         | 
| 308 | 
            +
                      </w:rPr>
         | 
| 309 | 
            +
                    </xsl:if>
         | 
| 310 | 
            +
                    <w:t xml:space="preserve"><xsl:value-of select="."/></w:t>
         | 
| 311 | 
            +
                  </w:r>
         | 
| 312 | 
            +
                </xsl:if>
         | 
| 313 | 
            +
              </xsl:template>
         | 
| 314 | 
            +
             | 
| 315 | 
            +
              <xsl:template match="*">
         | 
| 316 | 
            +
                <xsl:apply-templates/>
         | 
| 317 | 
            +
              </xsl:template>
         | 
| 318 | 
            +
             | 
| 319 | 
            +
              <xsl:template name="text-alignment">
         | 
| 320 | 
            +
                <xsl:param name="class" select="@class" />
         | 
| 321 | 
            +
                <xsl:param name="style" select="@style" />
         | 
| 322 | 
            +
                <xsl:variable name="alignment">
         | 
| 323 | 
            +
                  <xsl:choose>
         | 
| 324 | 
            +
                    <xsl:when test="contains(concat(' ', $class, ' '), ' center ') or contains(translate(normalize-space($style),' ',''), 'text-align:center')">center</xsl:when>
         | 
| 325 | 
            +
                    <xsl:when test="contains(concat(' ', $class, ' '), ' right ') or contains(translate(normalize-space($style),' ',''), 'text-align:right')">right</xsl:when>
         | 
| 326 | 
            +
                    <xsl:when test="contains(concat(' ', $class, ' '), ' left ') or contains(translate(normalize-space($style),' ',''), 'text-align:left')">left</xsl:when>
         | 
| 327 | 
            +
                    <xsl:when test="contains(concat(' ', $class, ' '), ' justify ') or contains(translate(normalize-space($style),' ',''), 'text-align:justify')">both</xsl:when>
         | 
| 328 | 
            +
                    <xsl:otherwise></xsl:otherwise>
         | 
| 329 | 
            +
                  </xsl:choose>
         | 
| 330 | 
            +
                </xsl:variable>
         | 
| 331 | 
            +
                <xsl:if test="string-length(normalize-space($alignment)) > 0">
         | 
| 332 | 
            +
                  <w:pPr>
         | 
| 333 | 
            +
                    <w:jc w:val="{$alignment}"/>
         | 
| 334 | 
            +
                  </w:pPr>
         | 
| 335 | 
            +
                </xsl:if>
         | 
| 336 | 
            +
              </xsl:template>
         | 
| 337 | 
            +
             | 
| 338 | 
            +
            </xsl:stylesheet>
         | 
| @@ -0,0 +1,71 @@ | |
| 1 | 
            +
            <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
         | 
| 2 | 
            +
                            xmlns:str="http://exslt.org/strings"
         | 
| 3 | 
            +
                            xmlns:func="http://exslt.org/functions"
         | 
| 4 | 
            +
                            xmlns:fn="http://www.w3.org/2005/xpath-functions"
         | 
| 5 | 
            +
                            version="1.0"
         | 
| 6 | 
            +
                            exclude-result-prefixes="java msxsl ext w o v WX aml w10"
         | 
| 7 | 
            +
                            extension-element-prefixes="func">
         | 
| 8 | 
            +
              <xsl:output method="html" encoding="utf-8" omit-xml-declaration="yes" indent="yes"/>
         | 
| 9 | 
            +
             | 
| 10 | 
            +
              <xsl:template match="/">
         | 
| 11 | 
            +
                <xsl:apply-templates/>
         | 
| 12 | 
            +
              </xsl:template>
         | 
| 13 | 
            +
             | 
| 14 | 
            +
              <xsl:template match="head"/>
         | 
| 15 | 
            +
             | 
| 16 | 
            +
              <!-- Elements not supported -->
         | 
| 17 | 
            +
              <xsl:template match="applet"/>
         | 
| 18 | 
            +
              <xsl:template match="area"/>
         | 
| 19 | 
            +
              <xsl:template match="audio"/>
         | 
| 20 | 
            +
              <xsl:template match="base"/>
         | 
| 21 | 
            +
              <xsl:template match="basefont"/>
         | 
| 22 | 
            +
              <xsl:template match="canvas"/>
         | 
| 23 | 
            +
              <xsl:template match="command"/>
         | 
| 24 | 
            +
              <xsl:template match="font"/>
         | 
| 25 | 
            +
              <xsl:template match="iframe"/>
         | 
| 26 | 
            +
              <xsl:template match="img"/>
         | 
| 27 | 
            +
              <xsl:template match="isindex"/>
         | 
| 28 | 
            +
              <xsl:template match="map"/>
         | 
| 29 | 
            +
              <xsl:template match="noframes"/>
         | 
| 30 | 
            +
              <xsl:template match="noscript"/>
         | 
| 31 | 
            +
              <xsl:template match="object"/>
         | 
| 32 | 
            +
              <xsl:template match="param"/>
         | 
| 33 | 
            +
              <xsl:template match="script"/>
         | 
| 34 | 
            +
              <xsl:template match="source"/>
         | 
| 35 | 
            +
              <xsl:template match="style"/>
         | 
| 36 | 
            +
              <xsl:template match="video"/>
         | 
| 37 | 
            +
             | 
| 38 | 
            +
              <!-- Elements currently being handled as normal text. Remove tags only -->
         | 
| 39 | 
            +
              <xsl:template match="abbr"><xsl:apply-templates/></xsl:template>
         | 
| 40 | 
            +
              <xsl:template match="acronym"><xsl:apply-templates/></xsl:template>
         | 
| 41 | 
            +
              <xsl:template match="bdi"><xsl:apply-templates/></xsl:template>
         | 
| 42 | 
            +
              <xsl:template match="bdo"><xsl:apply-templates/></xsl:template>
         | 
| 43 | 
            +
              <xsl:template match="big"><xsl:apply-templates/></xsl:template>
         | 
| 44 | 
            +
              <xsl:template match="code"><xsl:apply-templates/></xsl:template>
         | 
| 45 | 
            +
              <xsl:template match="kbd"><xsl:apply-templates/></xsl:template>
         | 
| 46 | 
            +
              <xsl:template match="samp"><xsl:apply-templates/></xsl:template>
         | 
| 47 | 
            +
              <xsl:template match="small"><xsl:apply-templates/></xsl:template>
         | 
| 48 | 
            +
              <xsl:template match="tt"><xsl:apply-templates/></xsl:template>
         | 
| 49 | 
            +
              <xsl:template match="var"><xsl:apply-templates/></xsl:template>
         | 
| 50 | 
            +
             | 
| 51 | 
            +
              <!-- Inline elements transformations -->
         | 
| 52 | 
            +
              <xsl:template match="cite"><i><xsl:apply-templates/></i></xsl:template>
         | 
| 53 | 
            +
              <xsl:template match="del"><s><xsl:apply-templates/></s></xsl:template>
         | 
| 54 | 
            +
              <xsl:template match="dfn"><i><xsl:apply-templates/></i></xsl:template>
         | 
| 55 | 
            +
              <xsl:template match="em"><i><xsl:apply-templates/></i></xsl:template>
         | 
| 56 | 
            +
              <xsl:template match="ins"><u><xsl:apply-templates/></u></xsl:template>
         | 
| 57 | 
            +
              <xsl:template match="mark"><span class="h" data-style="yellow"><xsl:apply-templates/></span></xsl:template>
         | 
| 58 | 
            +
              <xsl:template match="q">"<xsl:apply-templates/>"</xsl:template>
         | 
| 59 | 
            +
              <xsl:template match="strike"><s><xsl:apply-templates/></s></xsl:template>
         | 
| 60 | 
            +
              <xsl:template match="strong"><b><xsl:apply-templates/></b></xsl:template>
         | 
| 61 | 
            +
             | 
| 62 | 
            +
              <!-- Block elements transformations -->
         | 
| 63 | 
            +
              <xsl:template match="section"><div class="{@class}" style="{@style}"><xsl:apply-templates/></div></xsl:template>
         | 
| 64 | 
            +
              <xsl:template match="article"><div  class="{@class}" style="{@style}"><xsl:apply-templates/></div></xsl:template>
         | 
| 65 | 
            +
             | 
| 66 | 
            +
              <xsl:template match="@*|node()">
         | 
| 67 | 
            +
                <xsl:copy>
         | 
| 68 | 
            +
                  <xsl:apply-templates select="@*|node()"/>
         | 
| 69 | 
            +
                </xsl:copy>
         | 
| 70 | 
            +
              </xsl:template>
         | 
| 71 | 
            +
            </xsl:stylesheet>
         | 
| @@ -0,0 +1,26 @@ | |
| 1 | 
            +
            <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
         | 
| 2 | 
            +
                            xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
         | 
| 3 | 
            +
                            xmlns:o="urn:schemas-microsoft-com:office:office"
         | 
| 4 | 
            +
                            xmlns:v="urn:schemas-microsoft-com:vml"
         | 
| 5 | 
            +
                            xmlns:WX="http://schemas.microsoft.com/office/word/2003/auxHint"
         | 
| 6 | 
            +
                            xmlns:aml="http://schemas.microsoft.com/aml/2001/core"
         | 
| 7 | 
            +
                            xmlns:w10="urn:schemas-microsoft-com:office:word"
         | 
| 8 | 
            +
                            xmlns:pkg="http://schemas.microsoft.com/office/2006/xmlPackage"
         | 
| 9 | 
            +
                            xmlns:msxsl="urn:schemas-microsoft-com:xslt"
         | 
| 10 | 
            +
                            xmlns:ext="http://www.xmllab.net/wordml2html/ext"
         | 
| 11 | 
            +
                            xmlns:java="http://xml.apache.org/xalan/java"
         | 
| 12 | 
            +
                            xmlns:str="http://exslt.org/strings"
         | 
| 13 | 
            +
                            xmlns:func="http://exslt.org/functions"
         | 
| 14 | 
            +
                            xmlns:fn="http://www.w3.org/2005/xpath-functions"
         | 
| 15 | 
            +
                            version="1.0"
         | 
| 16 | 
            +
                            exclude-result-prefixes="java msxsl ext w o v WX aml w10"
         | 
| 17 | 
            +
                            extension-element-prefixes="func">
         | 
| 18 | 
            +
             | 
| 19 | 
            +
              <!-- use block quotes for spacing (can be nested) -->
         | 
| 20 | 
            +
              <xsl:template match="blockquote">
         | 
| 21 | 
            +
                <w:p>
         | 
| 22 | 
            +
                  <w:r></w:r>
         | 
| 23 | 
            +
                </w:p>
         | 
| 24 | 
            +
                <xsl:apply-templates/>
         | 
| 25 | 
            +
              </xsl:template>
         | 
| 26 | 
            +
            </xsl:stylesheet>
         | 
| @@ -0,0 +1,34 @@ | |
| 1 | 
            +
            <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
         | 
| 2 | 
            +
                            xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
         | 
| 3 | 
            +
                            xmlns:o="urn:schemas-microsoft-com:office:office"
         | 
| 4 | 
            +
                            xmlns:v="urn:schemas-microsoft-com:vml"
         | 
| 5 | 
            +
                            xmlns:WX="http://schemas.microsoft.com/office/word/2003/auxHint"
         | 
| 6 | 
            +
                            xmlns:aml="http://schemas.microsoft.com/aml/2001/core"
         | 
| 7 | 
            +
                            xmlns:w10="urn:schemas-microsoft-com:office:word"
         | 
| 8 | 
            +
                            xmlns:pkg="http://schemas.microsoft.com/office/2006/xmlPackage"
         | 
| 9 | 
            +
                            xmlns:msxsl="urn:schemas-microsoft-com:xslt"
         | 
| 10 | 
            +
                            xmlns:ext="http://www.xmllab.net/wordml2html/ext"
         | 
| 11 | 
            +
                            xmlns:java="http://xml.apache.org/xalan/java"
         | 
| 12 | 
            +
                            xmlns:str="http://exslt.org/strings"
         | 
| 13 | 
            +
                            xmlns:func="http://exslt.org/functions"
         | 
| 14 | 
            +
                            xmlns:fn="http://www.w3.org/2005/xpath-functions"
         | 
| 15 | 
            +
                            version="1.0"
         | 
| 16 | 
            +
                            exclude-result-prefixes="java msxsl ext w o v WX aml w10"
         | 
| 17 | 
            +
                            extension-element-prefixes="func">
         | 
| 18 | 
            +
             | 
| 19 | 
            +
              <!-- support function to return substring-before or everything -->
         | 
| 20 | 
            +
              <func:function name="func:substring-before-if-contains">
         | 
| 21 | 
            +
                <xsl:param name="arg"/>
         | 
| 22 | 
            +
                <xsl:param name="delim"/>
         | 
| 23 | 
            +
                <func:result>
         | 
| 24 | 
            +
                  <xsl:choose>
         | 
| 25 | 
            +
                    <xsl:when test="contains($arg, $delim)">
         | 
| 26 | 
            +
                      <xsl:value-of select="substring-before($arg, $delim)"/>
         | 
| 27 | 
            +
                    </xsl:when>
         | 
| 28 | 
            +
                    <xsl:otherwise>
         | 
| 29 | 
            +
                      <xsl:value-of select="$arg"/>
         | 
| 30 | 
            +
                    </xsl:otherwise>
         | 
| 31 | 
            +
                  </xsl:choose>
         | 
| 32 | 
            +
                </func:result>
         | 
| 33 | 
            +
              </func:function>
         | 
| 34 | 
            +
            </xsl:stylesheet>
         |