- Home
- Uncategorized
- Writing About Code: Fix Smart Quote Issue WordPress. Syntax Highlight With “Code Prettify” Plugin
Writing About Code: Fix Smart Quote Issue WordPress. Syntax Highlight With “Code Prettify” Plugin
For people who are sharing code on their wordpress site, there is nothing “smart” about the default feature of wordpress to change stardard double quotes to “smart quotes”. In fact this will often cause the code to not work when the article reader copies the code into their own script. This is easy enough to fix with the “Code Prettify” plugin, plus you get some really awesome syntax highlighting that makes the code look cooler and easier to read.
First make sure you have the “Code Prettify” plugin. Go to “Add Plugin” and search “Code Prettify”. Download and activate the plugin.
To use it in an article. Add a Custom HTML section in the page and include this p tage with the prettyPrint class and optionally specify the language to use for syntax highlighting:
<pre class="prettyPrint"> <script src="js/myScript.js?v=2"></script> </pre>
Since we are dealing in html we need to escape the html characters so we dont break the page and also so all the characters are displayed properly. Just search Google for HTML Escaper on use this one: https://www.freeformatter.com/html-escape.html
The above code will look like this when it’s rendered
<script src="js/myScript.js?v=2"></script>
You can also specify language classes to tell the plugin how to do the syntax highlighting. For example:
<pre class="prettyPrint lang-html"> <script src="js/myScript.js?v=2"></script> </pre>
Note the “lang-html” class which corresponds with HTML language syntax highlighting. Here’s a complete list of the supported language classes:
Bash and other Shell scripting
lang-bash, lang-bsh, lang-csh, lang-sh
C, C++, et al
lang-c, lang-cc, lang-cpp, lang-cxx, lang-cyc, lang-m
C#
lang-cs
Clojure
lang-clj
CoffeeScript
lang-coffee
CSS
lang-css
Dart
lang-dart
Delphi
lang-pascal
Erlang
lang-erl, lang-erlang
Go
lang-go
Haskell
lang-hs
HTML
lang-html
Java
lang-java
JavaScript
lang-js, lang-javascript
JSON
lang-json
LaTeX and TeX
lang-latex, lang-tex
Lisp and Scheme
lang-cl, lang-el, lang-lisp, lang-lsp, lang-scm, lang-ss, lang-rkt
Lua
lang-lua
OCaml, SML, F#, et al
lang-fs, lang-ml
Pascal
lang-pascal
Perl
lang-pl, lang-perl
PHP
lang-php
Protocol buffers
lang-proto
Python
lang-py, lang-python, lang-cv
R and S
lang-r, lang-s
Regex
lang-regex
Ruby
lang-rb, lang-ruby
Rust
lang-rc, lang-rs, lang-rust
Scala
lang-scala
SQL
lang-sql
VHDL
lang-vhdl, lang-vhd
Visual Basic
lang-vb, lang-vbs
XML
lang-xml