Headline Hierarchy
This is an open discussion with 15 replies, filed under XSLT.
Search
Ah, great utility!
I am not sure but are you certain about the match="body//@*"
? Does one have to hardcode their Xpath in your utility in order to use it?
Thanks, phoque. That’s a copy and paste mistake.
Alright :-)
Hm, maybe a special mode
could help the user to know when he’s actually calling the ninjas to work. What do you think?
I thought about that but wanted to keep things similar to Allen’s tutorial. I often use a mode for the Ninja technique called typographic
as I like to change more things than just headlines. It would also be possible to set the hierarchy via with-param
.
Headline Hierarchy
updated to version 1.1
on 7th of May 2010
This wasn't handling ID attributes on my headings. I noticed that ''mode="ninja"'' isn't applied to the template call for attributes (on line 47 or thereabouts) and that adding this fixes the problem for me.
<!-- Change hierarchy --> <xsl:element name="h{substring-after(name(), 'h') + $level}"> <xsl:apply-templates select="* | @* | text()" mode="ninja" /> </xsl:element>
Heisann,
if have a usage-issue with this, guess it’s a simple mistake …
I have a formatted text, when I reference it like this, the headline-hierarchy is not applied:
<xsl:apply-templates select="text/*" mode="ninja" />
If I use the following, it is applied, but remains enveloped by the <text mode="formatted">
xml element:
<xsl:apply-templates select="text" mode="ninja" />
What's inside your text
node?
The formatted text is simply a set of paragraphs and headlines:
<p>…</p> <h2>…</h2> <p>…</p> <p>…</p>
I guess this is a plain selector problem, but how can i tackle it? :(
This might be overkill, but here's how I apply the utility to a node called <content>
. In the main data
template, I call:
<xsl:apply-templates select=".//content" mode="formatted"/>
And that calls this template:
<xsl:template match="//content" mode="formatted"> <xsl:apply-templates select="*" mode="ninja"> <xsl:with-param name="level" select="1"/> </xsl:apply-templates> </xsl:template>
@tachyondecay brill! this works like a charm, thanks a 1000!
@nils have you tried to use this with markdown extra text fields? If I have a headline with a class attribute, the latter is included in the header itself.
# Erfolgsgeheimnis {.einklapp}
becomes
<h4>einklappErfolgsgeheimnis</h4>
but should be
<h4 class="einklapp">Erfolgsgeheimnis</h4>
Looks like headline-hierarchy is not properly reapplying attributes, even though it looks like it should. Any idea how to fix this?
(the same happens if I use an inline-html <h4 class="einklapp">
inside markdown)
The template mode is missing for the attributes, that's why it doesn't work. Checkout the updated template in our kit: https://github.com/hananils/kit/blob/master/ninja.xsl#L87
Puh! What a relief!
Thanks Nils!
Create an account or sign in to comment.
A new XSLT utility, “Headline Hierarchy” is now available for download. Comments and feedback can be left here but if you discover any issues, please post it on the issue tracker.