Search

I’m having trouble working out how to integrate syntax-coloured code snippets in my article content.

I’m using Markdown formatter, but I’ve had trouble getting clean output of a pre and code pair with the code content inside. I tried ninja technique to remove unwanted whitespace between pre and code tags but all I managed was to totally remove the code tag.

I am aware that markdown is supposed to leave HTML alone, but of course in order to get such content into XML DS it has to be entity coded by symphony so all the open and close tags and whatnot can be stored.

My question - can I use the ninja technique to enable me to convert HTML entitied tags back into regular HTML on my templates so I can add classes for code type that enable a JavaScript syntax highlighter to work its magic.

For example, I need to add class=”php” to a code tag for a PHP code snippet but I cannot do this in markdown, so I would have to write the code block as HTML and somehow convert this back to HTML in the template.

I hope this makes sense, and thanks in advance.

My question - can I use the ninja technique to enable me to convert HTML entitied tags back into regular HTML on my templates

Try changing disable-output-escaping on your value-of when you write the node value.

There’s also the CSS fix that Alistair pointed out a while back. See handling whitespace.

There’s also the CSS fix that Alistair pointed out a while back. See handling whitespace.

Thanks Steven, that CSS did the trick regarding the whitespace.

@Nick - thanks for the pointer but no joy I’m afraid. The content being generated by the markdown formatter seems to be entity converting any HTML I put in, at least that’s what seems to be the case when I view the XML in the debug page. It seems I can’t therefore put HTML into the content.

I know you use a script on your site that works for XML-like languages, and I tried it, but I want a solution for other languages. Having looked around a bit, it seems to be a sticking point for a lot of developers.

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