Search

I'll be the first one to admit I don't know a lot about symphony or XSLT, but I'm learning thanks to those of you that are gracious enough to lend a moment!

I have a textarea field that I am trying to transform on my HTML page to a formatted output. The trouble is that this textarea has multiple paragraphs, with hard returns in it. As you might know, when you use a simple "value-of" the field in a template, the paragraph gets transformed, minus any whitespace (i.e. blank lines between paragraphs).

Understanding that I'm new, is there a really easy way to exactly replicate what was in the field (i.e. the paragraph breaks)? Going one step further, is it possible to incorporate markup language in the field so that it gets replicated as such? So. for instance, could you put in This is going to be bolded in the textarea and then have the transformation took format it with the bolding?

Thanks for your help, in advance! Korky

The simplest solution is to utilize <xsl:copy-of select="path/to/field/*"/> which will copy all of the elements(i.e. HTML) inside the field.

Also, you need to make sure that the textarea field in your section has a text formatter applied (I use Markdown), otherwise you will need to use HTML in the textarea field.

Hi Lewis,

Well, I have tried just about everything. I'm wondering if I need to go back and re-enter all the text since I changed the formatter (I had used Markdown with HTML purifier). Using the copy-of syntax, seems to strip out blank lines, though it DOES keep the "CR/LF". Getting very frustrated!

Usually when I want to display the value of, say, a textarea named content (I'm so original), I do something like <xsl:copy-of select="content/node()"/>.

I'm wondering if I need to go back and re-enter all the text since I changed the formatter (I had used Markdown with HTML purifier).

Changing the formatter on a field requires you to re-save each entry before the formatting updates, I believe. Marco's resave entries extension saves entries and time in such situations.

Thanks tachyondecay -

I tried this and it did restore a single CRLF but not the blank line.

I'm wondered if it was acting funny because I copied and pasted this from a web site. But I tried with just a straight typed entry and I still get the paragraphs run together with a LF between then, but no CR (blank line). I am including my code below:

<xsl:template match="entries/entry">
<li>
    <h3><xsl:value-of select="title"/></h3>
    <ul>
        <li><xsl:value-of select="author"/></li>
        <li>
           <xsl:call-template name="format-date">
             <xsl:with-param name="date" select="blog-date"/>
             <xsl:with-param name="format" select="'x M Y'"/>
           </xsl:call-template>
        </li>
        <br/>
    </ul>
    <xsl:copy-of select="body/node()"/><br/><br/>
</li>

Just in case someone wants to achieve proper HTML paragraphs without unleashing the full (horrible, deadly, sin-eating, goddamn motherfucking, chuck norris' ass-kicking) power of markdown, I've put together a small XSLT Utility called Plaintext Paragraphs that does exactly that.

Jensscherbl - that apparently didn't help either. I'm not sure why the blank line between two paragraphs is being suppressed, but it's pretty stubborn!

i don't know if stating the obvious helps, but i only get blank lines between my paragraphs because all of my <p> tags have margin-bottom: 1em; in the css.

without that, you'll get breaks between the paragraphs, but not what appears to be a blank line.

is your formatter actually outputting <p> tags?

Are you outputting the formatted element in the data source? You need to do this if you are using a text formatter like Markdown. If you do not want to utilize a text formatter, you must include HTML in your textarea...

<p>Hi <strong>there</strong>!</p>

Then in your XSLT use:

<xsl:copy-of select="path/to/field/*" />

If you're still not getting it to work, please post your XML so that we can help you further.

Fawx - not at all obvious, and that certainly is an option since the XML IS outputting paragraph tags.

The way I am filling up the "body" field in the entry screen is through a copy and paste method. I did it that way, because I expect that my SEO team will create entries in Word or some such WP, then cut and paste into several blog sites. As such I don't want to embed any HTML in the actual input field itself (hence my use of Markdown). So what should be going into the field is straight text with carriage returns and line feeds (CRLF). So far, attempts to render that back on to a display through XSLT has proved frustrating, in that it seems that the Markdown storage is stripping just the blank line between paragraphs (not the CRLF). However, if I change the entries to NONE (i.e. No markdown), then this removes all the CRLF so that the text looks like one large paragraph.

Hopefully this is clear.

Lewis, in answer to your question, yes the data source has "body: Formatted" selected for it's output.

For the time being, I think I'll just put an artificial pad on the p-tag which should be fine.

would it be possible to pastie us an example of the content input and the subsequent xml output?

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