Skip to content

An example of running prism alongside code-prettify #127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion _includes/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,15 @@
{% endif %}
{% if include.prettyprint %}
<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js" defer></script>
<script src="{{ site.baseurl }}/js/vendor/prism.js" defer></script>
<link rel="stylesheet" href="{{ site.baseurl }}/css/prism.css">
<script>
[].forEach.call(document.getElementsByTagName("pre"), function(el) {
el.classList.add("prettyprint");
var prism = false;
el.classList.forEach(function(i) {
prism = /language-/.test(i) ? true : false;
})
if (!prism) el.classList.add("prettyprint");
});
</script>
{% endif %}
Expand Down
10 changes: 6 additions & 4 deletions _posts/2016-08-04-testing-redux-containers.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,12 @@ So we can include two types of `name` prop in our Route components in `routes.js
1. Functions, that pull it out of state.
2. Strings, that are directly formatted.

{% highlight html %}
<Route name={state => state.locations.name} path={'locations/:id'} component={Locations}/>
<Route name={'locations'} path={'locations/:id'} component={Locations}/>
{% endhighlight %}
<pre class="language-jsx">
<code class="language-jsx">
<Route name={state => state.locations.name} path={'locations/:id'} component={Locations}/>
<Route name={'locations'} path={'locations/:id'} component={Locations}/>
</code>
</pre>

Then, finally, we can do a bit of further mapping and reducing in the Breadcrumb container component to concatenate the paths correctly and evaluate the params.

Expand Down
142 changes: 142 additions & 0 deletions css/prism.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
/* http://prismjs.com/download.html?themes=prism&languages=markup+css+clike+javascript+bash+jsx+scss */
/**
* prism.js default theme for JavaScript, CSS and HTML
* Based on dabblet (http://dabblet.com)
* @author Lea Verou
*/

code[class*="language-"],
pre[class*="language-"] {
color: black;
background: none;
text-shadow: 0 1px white;
font-family: monospace;
text-align: left;
white-space: pre;
word-spacing: normal;
word-break: normal;
word-wrap: normal;

-moz-tab-size: 4;
-o-tab-size: 4;
tab-size: 4;

-webkit-hyphens: none;
-moz-hyphens: none;
-ms-hyphens: none;
hyphens: none;
}

pre[class*="language-"]::-moz-selection, pre[class*="language-"] ::-moz-selection,
code[class*="language-"]::-moz-selection, code[class*="language-"] ::-moz-selection {
text-shadow: none;
background: #b3d4fc;
}

pre[class*="language-"]::selection, pre[class*="language-"] ::selection,
code[class*="language-"]::selection, code[class*="language-"] ::selection {
text-shadow: none;
background: #b3d4fc;
}

@media print {
code[class*="language-"],
pre[class*="language-"] {
text-shadow: none;
}
}

/* Code blocks */
pre[class*="language-"] {
margin: .5em 0;
overflow: auto;
}

:not(pre) > code[class*="language-"],
pre[class*="language-"] {
background: #f0f1f2;
}

/* Inline code */
:not(pre) > code[class*="language-"] {
padding: .1em;
border-radius: .3em;
white-space: normal;
}

.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
color: slategray;
}

.token.punctuation {
color: #999;
}

.namespace {
opacity: .7;
}

.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol,
.token.deleted {
/*purple*/
color: #550078;
}

.token.string,
.token.char {
/*green*/
color: #2c9798;
}

.token.selector,
.token.attr-name,
.token.builtin,
.token.inserted {
/*blue*/
color: #0b7fac;
}

.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
color: #a67f59;
background: hsla(0, 0%, 100%, .5);
}

.token.atrule,
.token.attr-value,
.token.keyword {
color: #07a;
}

.token.function {
color: #DD4A68;
}

.token.regex,
.token.important,
.token.variable {
color: #e90;
}

.token.important,
.token.bold {
font-weight: bold;
}
.token.italic {
font-style: italic;
}

.token.entity {
cursor: help;
}
9 changes: 9 additions & 0 deletions js/vendor/prism.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.