Jump to content

Archived

This topic is now archived and is closed to further replies.

Willem-Siebe Spoelstra

How to add code snippets in post

Recommended Posts

Willem-Siebe Spoelstra    0
Willem-Siebe Spoelstra

Hi,

 

I want to add code snippets in my posts and pages, like this.

<p>This is a paragraph</p>

What I do is this:

<code><p>This is a paragraph</p></code>

But is only outputs the text 'this is a paragraph.

 

What should I do? 

 

Kind regards,

 

Willem


I write about internet marketing, WordPress and Pagelines on my Dutch blog spoelstra.ws

Share this post


Link to post
Share on other sites
Danny    1,327
Danny

Hi Willem,

 

Is this not convered in our shortcodes doc ? Hmm must of missed that, ill make a note now and add it later.

 

Basically, we have implemented Google Prettyprint.

 

So first things first, go to DMS ToolBar > Global Options > Advanced  and enable Goolge PrettyPrint. Once enabled, add the following shortcode to your actually code.

 

For example.

 

[pl_codebox]
<div class="example">
<h1 class="example">Hello World!</h1>
</div>
[/pl_codebox]
 
This will make your code look pretty :D Like this:

http://cl.ly/image/0435310Z1O0y

Please search our forums, before posting!

Share this post


Link to post
Share on other sites
Willem-Siebe Spoelstra    0
Willem-Siebe Spoelstra

It's documented! Thanks.


I write about internet marketing, WordPress and Pagelines on my Dutch blog spoelstra.ws

Share this post


Link to post
Share on other sites
Willem-Siebe Spoelstra    0
Willem-Siebe Spoelstra

One question left, why is DMS only using 'pre' for the output. When I look at this doc: http://www.w3.org/html/wg/drafts/html/master/grouping-content.html#the-pre-element

 

I see they do it like this, so pre + code.

<pre><code>function Panel(element, canClose, closeHandler) {
  this.element = element;
  this.canClose = canClose;
  this.closeHandler = function () { if (closeHandler) closeHandler() };
}</code></pre>

About the language being used, this page is telling me: http://www.w3.org/html/wg/drafts/html/master/text-level-semantics.html#the-code-element

 

There is no formal way to indicate the language of computer code being marked up. Authors who wish to mark code elements with the language used, e.g. so that syntax highlighting scripts can use the right rules, can use the class attribute, e.g. by adding a class prefixed with "language-" to the element.

 

 

This is now being add to the 'pre' with the output of DMS.

 

So is DMS following the correct html rules here?

 

Hope to hear from you.

 

Kind regards,

 

Willem


I write about internet marketing, WordPress and Pagelines on my Dutch blog spoelstra.ws

Share this post


Link to post
Share on other sites
Rob    547
Rob

Willem, 

 

As you're aware, the moderators (Danny, James, Martin and myself) are not developers.  The only way to know for sure is to test it out.  We cannot ask the developers questions at this time, nor distract them from their round-the-clock work to restore things.  Apologies.

 

A simple test of that method shouldn't be difficult. 

 

Let us know the results of your test.


Former PageLines Moderator, Food Expert and Raconteur

Share this post


Link to post
Share on other sites
Willem-Siebe Spoelstra    0
Willem-Siebe Spoelstra

The only way to output code using the Google Prettify function of Pagelines is with the shortcode. And like I told in the previous post, the HTML output from the shortcode is not following the recommendations from HTML5.

The output isn't wrong, let me make that clear, but it's just a recommendation I'm talking about. 

 

Google prettify does not work with when I just use the 'pre' and 'code' tags in my posts, and that I regret. The reason why I find that a pity is because I don't want to use shortcodes to much. When I ever change to a system that's not working with these shortcodes, I have a problem ;-).

 

I found an simple plugin that makes the Google Prettify work when I use the normal 'pre' and 'code' tags. But I would have loved it if this was also the case with Pagelines DMS, and not that it only works using the shortcode. 


I write about internet marketing, WordPress and Pagelines on my Dutch blog spoelstra.ws

Share this post


Link to post
Share on other sites
Rob    547
Rob

We'll tell our developers.  That's all we can do.  Thank you for the information.

  • Like 1

Former PageLines Moderator, Food Expert and Raconteur

Share this post


Link to post
Share on other sites
Willem-Siebe Spoelstra    0
Willem-Siebe Spoelstra

You are more then welcome.


I write about internet marketing, WordPress and Pagelines on my Dutch blog spoelstra.ws

Share this post


Link to post
Share on other sites
Rob    547
Rob

:D


Former PageLines Moderator, Food Expert and Raconteur

Share this post


Link to post
Share on other sites
Willem-Siebe Spoelstra    0
Willem-Siebe Spoelstra

Hi Rob, can you explain me why CSS is being added for <pre> and <code> in utilities.less and typography.less?


I write about internet marketing, WordPress and Pagelines on my Dutch blog spoelstra.ws

Share this post


Link to post
Share on other sites
Rob    547
Rob

Absolutely no idea Willem.  I'm sorry. 


Former PageLines Moderator, Food Expert and Raconteur

Share this post


Link to post
Share on other sites

×