The first sentence of a Content field contains an ampersand (&). When using the special variable FirstSentence ($Content.FirstSentence), I get an XML Parsing error in FireFox at this point:
XML Parsing Error: not well-formed
FirstSentence is not safe to use with XML/HTML-markups, as it just parses for dots, and doesn't respect any opened tags. needs some refactoring (probably by using simplexml and falling back to dot-parsing in case of invalid input-markup) - anybody keen? :)
Thanks for the reply. In this case, the ampersand is used to seperate two peoples names. Just displaying $Content in the code works fine - it's only when I use FirstSentence. Is there a 'quick' fix to make this work for this situation?
you could you Summary() to generate 1 sentence and I believe Summary will render all the html and things like ampersand correctly.
Or you could turn off the Content Negotiator using ContentNegotiator::disable() in the _config.php and remove the XML header at the top of Page.ss and that will stop sending the template as super strict xml (which inforces things like Parsing errors) and instead send the page as normal text/html which will let errors like that through.
I find the summarisation functions are a little funny. Sometimes they add <br /> tags after line breaks. Is this caused by new lines - \n, perhaps?
I think what we need to do is review all these methods, there are a lot of them in there. Some of them do relatively the same thing, and we can combine them into a single method. Having a unified function that does more would probably be nicer.
For example: $Content.Summary(26, false) to limit Content at 26 words, without stripping HTML tags. Not passing true outputs non-stripped out HTML in the summary. This function would also carefully make sure that the returned summary is XML compliant, and doesn't have any strange <br /> line breaks either that some of the current summary methods have.