I have been looking for a good editor with syntax highlighting for php code to be used in the drupal 6 node body.
I would like to clear one thing first, I DO NOT need a syntax highligter for a code "posted" or "displayed" in the node. But I need to write php codes for some pages and writing them like a text without any highlighting, is pretty annoying.
As you can see below, I would like the php syntax <?php echo "Hello world"; ?> to be highlighted.
I tried many combinations and not found anything that I really desire.
below are some things that I tried...
I tried TinyMCE with codemagic, codemirror, editarea. But nothing
really works as they should.
adding to the above, trying to write and preserve code in any wysiwyg editor is a real pain in the a**.
Then I tried colorer module but am facing many problems and not
even a single bug report and issue of this module is fixed.
So isn't there a way to write php code as code and not as text inside the drupal nodes..??
Or is it that nobody bothered about it because anyone hardly writes php code inside nodes..?
I hope am not the only one and some solution to it does exist.
The ACE editor works really well as a code editor for <textarea>s, and it has a Drupal module. ACE is well maintained, so I'd check them out as an alternative to colorer, TinyMCE, et al.
Edit: However, it's only for Drupal 7, which won't help...
Related
I'm trying to build a blog using a combination of RStudio/blogdown and using the beautifulhugo theme from halogenica/beautifulhugo. When I create a new website using the stock template from github and the RStudio GUI/serve_site() everything works fine (as far as I can see) except the tags on the main page don't work (when I click them they say my computer isn't connected to the internet). I'd like to find out how to fix this... or learn how to work this properly, before I start changing stuff in the stock setup/building a blog.
This tag issue is repeated on each posts' page and on the dedicated "Tags" page when I click "View all" under each tag.
Am a complete noob here - am likely doing something wrong. I managed to "fix" the "View all" issue using https://github.com/halogenica/beautifulhugo/issues/142, but I'm guessing there is a more general issue with what I'm doing: I need to fix it once centrally, or perhaps perform a similar modification to other parts of the code?
Never mind - I found out what was wrong. The above fix corrects one of the issues in terms.html (layouts/_default). In the same folder there was an "error" (which I'll no doubt find out is correct at some point in the future) where there was an extra "/" being put into the tags link. I had to change
{{ . }}
to
{{ . }}
in both list/single.html in the same folder as above. Note these only differ in the slash before tags.
I need to add a PHP snippet inside a molecule in WP. WP Editor allows to insert <code> </code>
but even if I wrap PHP with that it does not seem to help.
All I want it to insert the current year, so I'm OK with either PHP or JS or whatever else WP supports.
Anyone had experience with that?
There are two plugins that come to mind. One is wp-syntax http://wordpress.org/extend/plugins/wp-syntax/, a rich code display plugin with many features. You'll have to switch to code editing view to insert your <code> or <pre> tag with the PHP snippet.
The other one is a low tech homebrew of mine, "include custom field": http://pp19dd.com/wordpress-plugin-include-custom-field/
The homebrew is a shortcode plugin that lets you place arbitrary code or data inside a custom field, and then inject it into the post with something like [include mycode1]. Note that it'll be up to you to encode it to where it can be shown, or modify it to where it acts like a code highlighter (can be done easily with highlight_string.)
Reason I like my brew version is because it a) separates a blog post from the code, and b) survives numerous editing cycles and/or imports. All other inline solutions annoy me to no end.
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
I'm looking for some tips to clean the code which is generated by WordPress and some plug-ins, because I'm not happy with the code generated by WordPress for two reasons:
The code isn't well formatted. I know, I know... It isn't important since that the browsers don't need to "parse" a well formatted code. However, I like to keep all codes well formatted and it includes HTML code generated by me or third-part systems.
Unfortunately, some parts of the code that WordPress puts on the <head> aren't well formatted and in some cases those parts aren't really necessary. By the way, I have no idea about how to clean-up it or how to hook the function which prints that code.
Is there some way to add tabs / spaces to the code generated by WordPress without change the core files / code?
Thank you!
Overlooking the overall ambiguity of your question, the file you need to edit to fix the <head> element is header.php. You will find it in your theme's folder in wp-contents.
I was experiencing an odd problem where blocks were not showing up on a site. After a lot of spelunking I have found that block.tpl.php is not getting called/discovered.
Looking at the suggestions that the theme engine is trying to find it looks like the most general template it will look for is block-MODULE.tpl.php - ie if I set up symlinks for block-block.tpl.php, block-views.tpl.php etc then the content will show.
It just won't find block.tpl.php
So I can kind of make the problem go away, but I'd feel a lot better if I could fix it properly.
Anyone know why (or where) this would happen?
This is drupal 6, with a zen subtheme. zen is in sites/all/themes/ the subtheme is in sites/example.com/themes/.
(it does seem to be finding page.tpl)
PHPTemplate will find the more general templates (e.g. block.tpl.php): you can confirm this behavior by looking in the themes/garland folder which has its own block.tpl.php.
The most common reason for the template engine ignoring your template overrides is because the theme registry has not been reset. You can reset it by going to Site Configuration -> Performance and clicking Clear cached data at the bottom of the page.
Also make sure you've gone through and followed the instructions for sub-theming exactly: missing a step can produce unexpected results:
How to build your own sub-theme (6.x-2.x)
How to build your own sub-theme (6.x-1.x)
Turns out I had added a to the hook_theme() function in template.php for blocks that was pointing to a different location and confusing everyone.
Why I did that is lost to history, but it seems to server no useful purpose.
there should be a version of block.tpl.php in both the theme and subtheme directories.