This repository was archived by the owner on Oct 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
97 lines (84 loc) · 5.68 KB
/
index.html
File metadata and controls
97 lines (84 loc) · 5.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<meta http-equiv="X-UA-Compatible" content="chrome=1" />
<meta name="description" content="Prettify-wrapper : Wraps Google Prettify into a nice little bow for easy inclusion into any website or blog" />
<link rel="stylesheet" type="text/css" media="screen" href="stylesheets/stylesheet.css">
<title>Prettify-wrapper</title>
</head>
<body>
<!-- HEADER -->
<div id="header_wrap" class="outer">
<header class="inner">
<a id="forkme_banner" href="https://github.com/mnewt/prettify-wrapper">View on GitHub</a>
<h1 id="project_title">Prettify-wrapper</h1>
<h2 id="project_tagline">Wraps Google Prettify into a nice little bow for easy inclusion into any website or blog</h2>
</header>
</div>
<!-- MAIN CONTENT -->
<div id="main_content_wrap" class="outer">
<section id="main_content" class="inner">
<h1>google-code-prettify wrapper</h1>
<p>This repository provides a quick and clean way to add code syntax highlighting to any web page. You do not need to host any files to do so. It has no external dependencies and is written in pure javascript. It should work on any blog platform, such as WordPress, Tumblr, or Blogger.</p>
<h1>Problem</h1>
<p>What problem are we trying to fix exactly? </p>
<p>We want to color highlight the syntax of any text in a code block without modifying our html. Google Code Prettify does a great job of highlighting any syntax enclosed in a block with the "prettyprint"
class (i.e. <span class="backtick"><pre class="prettyprint"></span>). However, we want it to highlight syntax in ANY <span class="backtick"><pre></span> block. That way you don't have to mess with updating your html every time you make a new code block.</p>
<p>Furthermore, since this needs to drop into an html document that presumably already has CSS defined for <span class="backtick"><pre></span> and/or <span class="backtick"><code></span> elements, we need to take special care to override such code, lest we do all this work for naught or--worse--use some CSS styles from the parent document and some defined here. To be honest though, I'm sure you will still have that problem on some sites. If you encounter such issues and manage to solve them, please send me a pull request and I'll add your new or modified theme.</p>
<h1>Solution</h1>
<p>While we could modify Google Code Prettify, this is not a clean and maintainable solution. So instead, we have a small wrapper javascript that you can include in your html (probably in your blog's template) that automatically adds the "prettyprint" class to all <span class="backtick"><pre></span> and <span class="backtick"><code></span> tags.</p>
<h1>Directions</h1>
<h3>STEP ONE:</h3>
<p>Copy the code in below into your web page, at the end of the file right before <span class="backtick"></body></span>.
The end of your html template should look like this:</p>
<pre><code><!-- ======================= Begin Prettify ============================-->
<link rel="stylesheet" type="text/css"
href="http://github.mnewton.com/prettify-wrapper/themes/prettify.css">
<script type="text/javascript"
src="http://github.mnewton.com/prettify-wrapper/wrapper.min.js"></script>
<!-- ======================== End Prettify =============================-->
</body>
</html>
</code></pre>
<h3>STEP TWO (optional:)</h3>
<p>Customize the theme by pointing the first line to a different CSS file, such as this one:
<a href="http://github.mnewton.com/prettify-wrapper/themes/prettify.css">http://github.mnewton.com/prettify-wrapper/themes/prettify.css</a></p>
<h1>Themes</h1>
<p>There are a few themes included in the google-code-prettify package itself:</p>
<ul>
<li><a href="http://google-code-prettify.googlecode.com/svn/trunk/styles/index.html">http://google-code-prettify.googlecode.com/svn/trunk/styles/index.html</a></li>
</ul>
<p><a href="https://github.com/jmblog">jmblog</a> maintains some nice themes:</p>
<ul>
<li><a href="http://jmblog.github.com/color-themes-for-google-code-prettify/">http://jmblog.github.com/color-themes-for-google-code-prettify/</a></li>
</ul>
<p>Lastly, there are some themes hosted here. They are mostly slightly modified versions of the ones found above. Check them out at:</p>
<ul>
<li><a href="https://github.com/mnewt/prettify-wrapper/tree/master/themes">https://github.com/mnewt/prettify-wrapper/tree/master/themes</a></li>
</ul>
</section>
</div>
<!-- FOOTER -->
<div id="footer_wrap" class="outer">
<footer class="inner">
<p class="copyright">Prettify-wrapper maintained by <a href="https://github.com/mnewt">mnewt</a></p>
<p>Published with <a href="http://pages.github.com">GitHub Pages</a></p>
</footer>
</div>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-33958216-1");
pageTracker._trackPageview();
} catch(err) {}
</script>
<!-- ======================= Begin Prettify ============================-->
<link rel="stylesheet" type="text/css" rel="stylesheet" href="themes/tomorrow-night-eighties.css">
<script type="text/javascript" src="wrapper.min.js"></script>
<!-- ======================== End Prettify =============================-->
</body>
</html>