Skip to content

Instantly share code, notes, and snippets.

@goozbach
Created February 1, 2011 20:49
Show Gist options
  • Save goozbach/806636 to your computer and use it in GitHub Desktop.
Save goozbach/806636 to your computer and use it in GitHub Desktop.
Working with mmd 2 twiki xslt stylesheet
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN"
"http://www.w3.org/TR/2001/REC-MathML2-20010221/dtd/xhtml-math11-f.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!-- Processed by MultiMarkdown -->
<meta name="Author" content="Derek Carter" />
<meta name="Email" content="[email protected]" />
<meta name="Format" content="Complete" />
</head>
<body>
<h1 id="headingone">Heading one</h1>
<h2 id="headertwo">header two</h2>
<h3 id="headerthree">header three</h3>
<h4 id="headerfour">header four</h4>
<h1 id="links">links</h1>
<p><a href="http://google.com">google</a></p>
<h1 id="lists">lists</h1>
<ul>
<li><p>list one</p></li>
<li><p>List item one</p></li>
</ul>
<h1 id="textstuff">text stuff</h1>
<p><em>strong me</em></p>
<p><em>em me</em></p>
<p><code>code me</code></p>
<p><strong>strong em</strong></p>
<p><strong>em strong</strong></p>
<h1 id="preformat">preformat</h1>
<pre><code>Mauris mattis commodo malesuada. Donec convallis, diam in feugiat malesuada, velit diam sodales mauris, ac tempor lectus tortor sed odio. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam eget mollis turpis. Donec vehicula lorem at elit ultricies volutpat.</code></pre>
</body>
</html>

Format: Complete
Author: Derek Carter
Email: [email protected]

Heading one

header two

header three

header four

links

google

lists

  • list one
  1. List item one

text stuff

strong me

em me

code me

strong em

em strong

preformat

Mauris mattis commodo malesuada. Donec convallis, diam in feugiat malesuada, velit diam sodales mauris, ac tempor lectus tortor sed odio. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam eget mollis turpis. Donec vehicula lorem at elit ultricies volutpat.
all: html view
@echo "Dude!"
view: source/foo.html xslt/stylesheet.xslt
xsltproc xslt/stylesheet.xslt source/foo.html | less -E
sjansen: source/foo.html xslt/sjansen.xslt
xsltproc xslt/sjansen.xslt source/foo.html | less -E
source/foo.html: source/foo.markdown
/Users/dcarter/projects/MultiMarkdown/bin/mmd2XHTML.pl source/foo.markdown
html: source/foo.html
@echo "html generated"
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="//*">
<xsl:choose>
<xsl:when test="local-name() = 'a'">
<xsl:call-template name="copy-all"/>
</xsl:when>
<xsl:when test="local-name() = 'meta'">
<xsl:call-template name="copy-all"/>
</xsl:when>
<xsl:when test="local-name()">
<xsl:call-template name="copy-subtree"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="copy-all">
<xsl:element name="{local-name()}">
<xsl:for-each select="@*">
<xsl:copy/>
</xsl:for-each>
<xsl:apply-templates select="*|node()"/>
</xsl:element>
</xsl:template>
<xsl:template name="copy-subtree">
<xsl:element name="{local-name()}">
<xsl:apply-templates select="*|node()"/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
<?xml version = "1.0"?>
<xsl:stylesheet version="1.0" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="@*|node()">
<!--<xsl:template match="/xhtml:html//*">-->
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment