Search

Hi,

I'm trying to take text from a markdown textarea and put it on screen as part of a numbered list (so the list exists, then there is further formatting, such as bullet points, within each list item). I was using value-of, which lost all the formatting in markdown, then found a reference to use copy-of instead.

This sort of worked, but I needed to be able to strip out the paragraph markers from the start and end of the textarea, as there were extra newlines turning up, which looked weird.

I found references to the Ninja technique being better than copy-of, so tried that- but I don't understand what it's doing, so I've been poking at it and looking at the docs, then repeat for a day now.

The XSLT code is at: <script src='http://pastie.org/4914655.js'></script>. See xsl:template match="policy/entry/policy-statement-text" at the bottom for the bit I've been fiddling with. The very bottom template (which has the word attribute in it) doesn't seem to do anything - I added it in as it was in the example code.

I tried putting //* at the end of the match statement, but it then produced extra bullet points, although at least the bullet points inside the list items then appeared. The current code as you see it does not pass through any formatting from markdown.

I'd be very grateful for any pointers. Let me know if you need more files.

Full disclosure: I'm new to this, and am mainly making random changes till something works. The whole "template" thing is not making much sense as yet (despite reading everything I can about it)- I'll get there eventually!

It would be useful if you could post your XML source too.

OK- here it is.

Attachments:
xml.txt

@abeta - would you mind posting your xslt as well? Actually, you should try posting your xml and xslt at xpathr.com. Then post a link to your unique xpathr link here.

This way, we can easily see what you are doing and how we can help.

in your case you could either do a copy-of p/* which means would match all children of p. Markdown by default encloses your text within a <p> tag. If you have more then one paragraph you could split it up.

Ninja technique you would have to find the standard default version and edit it. basically make a check if it is a first/last paragraph and remove the p tag in that case. First case would be easier for you to understand / implement.

If you find problems or something is unclear ask will try to figure out in more detail

@bzerangue - can I check that this isn't what I already posted (in the pastie link)?

@gunglien - Thanks, I'll give this a try. There could theoretically be more than one paragraph in the text field, but I'll start with the copy-of idea and see how it goes.

Hi,

Just to update this: we have decided to side-step the issue by using <xsl:value-of select="position()"/> to generate an index number for each policy statement, thus making the extra <p> actually look quite nice ;).

The copy-of p/* option did work, but since it limited the way paragraphs could be used, and overwrote Markdown (thus changing the default behaviour of Symphony, which I really don't want to do for a system which is to be supplied to customers, and which I therefore want to keep as vanilla as possible), I decided not to use it. The Ninja technique is definitely overkill for our needs, but I'm actually starting to understand how it works!

Thanks again for your suggestions.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details