Drupal module to format code - drupal

Can anyone recommend a module or other Drupal add-on that can be used to format code nicely like I see on a lot of blogs and websites? Ideally something that would integrate with CKeditor, but that's not critical, I can make do with HTML tags if need be. Thanks.

The two most popular Drupal modules seem to be Code Filter and GeSHi Filter for syntax highlighting. For getting GeSHi to work with CKeditor, check out the WYSIWYG - GeSHi bridge module.

Well, there's http://alexgorbatchev.com/SyntaxHighlighter/ which is javascript. It gets applied at view time.
To see your code highlighted in the actual editor, you're probably going to have to work a bit harder. If it were me, I'd start with http://ace.ajax.org/ , which is an editor that grew out of Mozilla's constantly-renamed in-browser IDE project.

Maybe it's to much but check this
http://drupal.org/project/grammar_parser_ui

Quick follow up: as per this post, the WYSIWYG-GeSHi bridge development has been put on hold because of some problems integrating GeSHi buttons into CKeditor's toolbar (they make all the other buttons disappear). I can confirm that this is the case.
However, if I use GeSHi tags in HTML source, they do format things correctly. The really key thing left out of the GeSHi module documentation is that you need to enable it as an input format in Drupal.
Next I'm going to try this method for integrating GeSHi formatting directly into CKeditor without using the WISYWIG module or any bridges. Thanks again for everyone's help.

There's the Prettify module that implements Google Code Prettify as JS library. It works out of the box but it appears to duplicate the pre tags, that is, one pre tag appears as container for the other one:
<pre class="prettyprint prettyprinted">
<pre class="prettyprint">
<code>
.myClass {
<br>
float: left;
<br>
}
</code>
</pre>
</pre>
That's only annoying because you can't really style the pre tag if there's two of them because all your styles are duplicated leading to double margins, padding, borders. etc.
Still, it works out of the box if you can deal with using the default styles provided with the module, and there are a number of them, i.e. Google Code, Stackoverflow etc.enter link description here

Related

2sxc: Adding more content templates in the same page does replicate link tags for css and js

I'm new to dnn and 2sxc.
Just wondering if I'm adding for example a card template (image,some text, a link), adding in the html template link tag to css/js, when adding that content more times in the page obviously the link tags are replicate in page source and it isn't so nice.
For example:
<script src="[App:Path]/script.js" type="text/javascript" data-enableoptimizations="100"></script>
it is going to be replicate in page.
Maybe I'm missing something, there is a better way to do it?
Thanks you :)
If you tried it, you should see that it will only be included once, IF you have the data-enableoptimizations included :)
So allready taken care of
Maybe i found the issue...
When I edit a template, selecting Html snippets in the combo to the right, then click on css, style-sheet it is writing a demo link tag, but it is not adding the type (type="text/css"), without it seems not work..
Maybe it could be fixed in a next release :)

Syntax highlighting in jekyll using redcarpet

I'm trying to get code highlighting to work for a simple blog built with jekyll. I want to be able to do code highlighting within posts written in markdown so I enabled redcarpet as markup language. This works all fine, the code gets formatted in <pre></pre> tags and all the various elements of the code get corresponding classes. e.g.
<span class="n">function</span>
<span class="n">saySomething</span>
<span class="p">()</span>
<span class="p">{</span>
etc.
This is awesome but this doesn't give us of the actual highlighting (color) yet. So I suppose there must be some css ready to copy and paste which actually does the styling of the different code elements. Or am I missing something completely?
I looked into some code highlighting libraries like prettify or prism but these do their own formatting with javascript in the browser. But since redcarpet already does the heavy lifting work of formatting the code it is not necessary doing it again.
Any hints?
You need some CSS magic. Use this one or pick one from here.
You can create the CSS with the highlighter itself
rougify style > rouge.css
Or
coderay stylesheet > coderay.css
I like to share the solution as I faced and it took much time to get rid of this issue. Default syntax highlighting is very poor in Jekyll. Like David said, You really need some CSS magic. Check this gist to solve the syntax highlighting problem.

Add html to drupal 6 page

I am trying to add html to the bottom of all the pages of a drupal 6 site.
I tried following Adding HTML to Drupal closure? but I'm not familiar enough with drupal to follow it.
The code is a google remarketing code, so I can't use drupal_add_js because the code I have already has script tags and , and the drupal_add_js wraps everything in tags.
hook_footer seems to be the best solution but I can't figure out how to use it.
Thanks
The best solution is to use hook_footer().
You have to create a Drupal module. I think this link might help you: https://drupal.org/developing/modules/7
Basically you have to create a module an implementes hook_footer(). In here you can add your custom html.
But there are another ways to do it. For example you can edit your theme. Find the page.tpl.php file in your theme and add, in the footer, the content. It's appears in all pages.
Another option is to create a block with full html filter, and add your html.
Regards.
I ended up putting the html i needed in $vars["closure"]

Django CMS Deleting HTML5 Tags and Attributes

I am having a big time issue with solving a problem. I have a placeholder called main for the content region of the page. I was building that region in the cms. Everything was going great until I attempted to add an embedded video contained in an iframe. When I save django cms completely removed the iframe and left an empty div. So I attempted to use prettyphoto light box to open the video by clicking on an image. The code I added to the page through the cms is:
<a rel='prettyPhoto[youtube]' href="https://www.youtube.com/embed/mqVZF_yb8C0?autoplay=1&start=1765&iframe=true" data-rel="prettyPhoto">Click Image</a>
When I saved, django cms completely removed the data-rel attribute from the link which is obviously needed for the js. So I went a step further and adapted the code of the data attribute to:
rel="prettyPhoto"
and the cms also removed that attribute! Also anytime I add an html5 tag like article of section it hates that too! What gives here? Am I doing something wrong? Any advice would be appreciated. 
Aaron,
Thanks.
Please see the discussion at https://github.com/divio/django-cms/issues/1529. We use html5lib to clean the contents of the text plugin (this cannot be turned off for security reasons).
What you'll want to do is write a custom plugin (possibly one that can be embedded inside text plugins).

Twitter Bootstrap - Explanation of the Customization Page

If you go to http://twitter.github.com/bootstrap/customize.html you can customize Twitter-Bootstrap's css & js files to only include what you need.
However, I don't really understand things like "Code and pre" and have no idea if I need it or not. Is there a resource that goes over the properties of each checkbox option so I have a better idea if I should include it or not?
I'm not sure if there is a resource for that, try downloading only the sections that you have concerns about and inspect them.
about CODE and PRE:
<code> vs <pre> vs <samp> for inline and block code snippets
So that check box is for specific styles for these text elements.
have no idea? you can download all component! http://twitter.github.com/bootstrap/assets/bootstrap.zip

Resources