~jonsterling/bike-convertors

e3d2675dac072cfd84f379937e15cbad5c021274 — Keagan Scott 1 year, 1 month ago 567b970 main
bike-to-html.xsl now converts links into <a> tags with hrefs. example2.bike has been added to test all row types and rich text formatting
2 files changed, 163 insertions(+), 0 deletions(-)

M bike-to-html.xsl
A example2.bike
M bike-to-html.xsl => bike-to-html.xsl +15 -0
@@ 28,6 28,15 @@
    <xsl:apply-templates />
  </xsl:template>

  <xsl:template match="xhtml:a">
    <a>
      <xsl:attribute name="href">
        <xsl:value-of select="@href"/>
      </xsl:attribute>
      <xsl:apply-templates select="node()"/>
    </a>
  </xsl:template>

  <!-- 
  Bike uses <ul> for all lists; the list type is determined not at this level, but rather by each
  individual item's @data-type attribute. To get this data into the HTML list model, we must group


@@ 104,6 113,12 @@
    </p>
  </xsl:template>

  <xsl:template match="xhtml:li[@data-type='code']/xhtml:p">
      <code>
        <xsl:apply-templates />
      </code>
  </xsl:template>

  <xsl:template match="xhtml:li[not(@data-type)]/xhtml:p">
    <p>
      <xsl:apply-templates />

A example2.bike => example2.bike +148 -0
@@ 0,0 1,148 @@
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta charset="utf-8"/>
  </head>
  <body>
    <ul id="YjzUt35_">
      <li id="ou" data-type="heading">
        <p>Heading One</p>
        <ul>
          <li id="M2" data-type="heading">
            <p>Heading Two</p>
            <ul>
              <li id="Ep" data-type="heading">
                <p>Heading Three</p>
                <ul>
                  <li id="S9" data-type="heading">
                    <p>Heading Four</p>
                    <ul>
                      <li id="Wz" data-type="heading">
                        <p>Heading Five</p>
                        <ul>
                          <li id="dL" data-type="heading">
                            <p>Heading Six</p>
                          </li>
                        </ul>
                      </li>
                    </ul>
                  </li>
                </ul>
              </li>
            </ul>
          </li>
        </ul>
      </li>
      <li id="hq" data-type="heading">
        <p>Rich Text</p>
        <ul>
          <li id="8K">
            <p><strong>bold</strong></p>
          </li>
          <li id="ygW">
            <p><em>italic</em></p>
          </li>
          <li id="ig">
            <p><s>strikethrough</s></p>
          </li>
          <li id="39">
            <p><code>monospaced</code></p>
          </li>
          <li id="sJk">
            <p><mark>highlights</mark></p>
          </li>
          <li id="09C">
            <p><a href="https://en.wikipedia.org/wiki/List_of_Formula_One_World_Drivers%27_Champions">links work too</a></p>
          </li>
        </ul>
      </li>
      <li id="Xh" data-type="heading">
        <p>Row Types</p>
        <ul>
          <li id="gJY" data-type="heading">
            <p>Block Quotes</p>
            <ul>
              <li id="xl" data-type="quote">
                <p>The struggle itself towards the heights is enough to fill a man's heart. One must imagine Sisyphus happy.</p>
              </li>
            </ul>
          </li>
          <li id="DOR" data-type="heading">
            <p>Code Blocks</p>
            <ul>
              <li id="g38" data-type="code">
                <p>die usage() unless $ARGV[0] =~/\d/ and $ARGV[1] =~ /\D/;</p>
              </li>
            </ul>
          </li>
          <li id="SWR" data-type="heading">
            <p>Notes</p>
            <ul>
              <li id="9hB" data-type="note">
                <p>This paragraph works well, but it could be made even better by doing …</p>
              </li>
            </ul>
          </li>
          <li id="Nvj" data-type="heading">
            <p>Tasks</p>
            <ul>
              <li id="KZ6" data-type="task">
                <p>milk</p>
              </li>
              <li id="wRE" data-type="task">
                <p>eggs</p>
              </li>
              <li id="J37" data-done="2023-10-23T00:38:55Z" data-type="task">
                <p>bread</p>
              </li>
            </ul>
          </li>
          <li id="vKm" data-type="heading">
            <p>Unordered Lists</p>
            <ul>
              <li id="VL0" data-type="heading">
                <p>Musicians</p>
                <ul>
                  <li id="V9v" data-type="unordered">
                    <p>Black Sabbath</p>
                  </li>
                  <li id="98k" data-type="unordered">
                    <p>The Beatles</p>
                  </li>
                  <li id="P5l" data-type="unordered">
                    <p>Ovlov</p>
                  </li>
                </ul>
              </li>
            </ul>
          </li>
          <li id="ay-" data-type="heading">
            <p>Ordered Lists</p>
            <ul>
              <li id="_oC" data-type="heading">
                <p>Notable F1 World Champions</p>
                <ul>
                  <li id="hSZ" data-type="ordered">
                    <p>Michael Schumacher</p>
                  </li>
                  <li id="OKO" data-type="ordered">
                    <p>Lewis Hamilton</p>
                  </li>
                  <li id="w8Q" data-type="ordered">
                    <p>Sebastian Vettel</p>
                  </li>
                  <li id="yrP" data-type="ordered">
                    <p>Max Verstappen</p>
                  </li>
                </ul>
              </li>
            </ul>
          </li>
          <li id="XGP">
            <p/>
          </li>
        </ul>
      </li>
    </ul>
  </body>
</html>