Fix Jekyll escaping.

This commit is contained in:
Rico Sta. Cruz 2014-06-16 00:03:39 +08:00
parent 277effd6dd
commit b79dc1712b
4 changed files with 98 additions and 16 deletions

View File

@ -1,3 +1,6 @@
{% if page.jekyll_escape %}
<script>var JekyllEscape=true;</script>
{% endif %}
<script src="assets/highlight.min.js"></script> <script src="assets/highlight.min.js"></script>
<script src="assets/script.js"></script> <script src="assets/script.js"></script>
<script> <script>

View File

@ -15,3 +15,15 @@
}); });
} }
})(); })();
(function () {
var tags = document.querySelectorAll('pre code, pre span');
for (var i=0, len=tags.length; i<len; i++) {
var tag = tags[i];
if (~tag.innerHTML.indexOf('{\\%'))
tag.innerHTML = tag.innerHTML.replace(/{\\%/g, '{%');
if (~tag.innerHTML.indexOf('{\\{'))
tag.innerHTML = tag.innerHTML.replace(/{\\{/g, '{{');
}
})();

View File

@ -1,6 +1,6 @@
html, body { html, body {
font-family: lato, sans-serif; font-family: lato, sans-serif;
font-size: 15px; font-size: 16px;
line-height: 1.556; line-height: 1.556;
color: #444; color: #444;
margin: 0; margin: 0;
@ -19,9 +19,13 @@ h1 {
font-weight: 100; font-weight: 100;
} }
pre {
line-height: 1.4;
}
pre, code { pre, code {
font-family: menlo, monospace; font-family: menlo, monospace;
font-size: 12px; font-size: 0.9em;
} }
a { a {
@ -52,7 +56,7 @@ a {
* stuff * stuff
*/ */
.header, .content, .pages { div.header, div.content, div.pages {
max-width: 800px; max-width: 800px;
margin: 0 auto; margin: 0 auto;
padding-left: 15px; padding-left: 15px;

View File

@ -1,6 +1,7 @@
--- ---
title: Jekyll title: Jekyll
layout: default layout: default
jekyll_escape: true
--- ---
### Installation ### Installation
@ -26,8 +27,7 @@ layout: default
_site/ _site/
... ...
Frontmatter ## [Front-matter](http://jekyllrb.com/docs/frontmatter/)
-----------
--- ---
layout: post layout: post
@ -42,10 +42,6 @@ Frontmatter
categories: ['html', 'css'] categories: ['html', 'css']
tags: ['html', 'css'] tags: ['html', 'css']
### Reference
* [Front-matter](http://jekyllrb.com/docs/frontmatter/)
Configuration Configuration
------------- -------------
@ -58,8 +54,7 @@ Configuration
* [Configuration](http://jekyllrb.com/docs/configuration/) * [Configuration](http://jekyllrb.com/docs/configuration/)
Variables ## [Variables](http://jekyllrb.com/docs/variables/)
---------
{\{ site }} - from config.yml {\{ site }} - from config.yml
{\{ page }} - from frontmatter, and page-specific info {\{ page }} - from frontmatter, and page-specific info
@ -75,6 +70,8 @@ Variables
{\{ site.categories.CATEGORY }} - list {\{ site.categories.CATEGORY }} - list
{\{ site.tags.TAG }} - list {\{ site.tags.TAG }} - list
{\{ site.static_files }}
### Page ### Page
{\{ page.content }} - un-rendered content {\{ page.content }} - un-rendered content
@ -82,19 +79,53 @@ Variables
{\{ page.excerpt }} - un-rendered excerpt {\{ page.excerpt }} - un-rendered excerpt
{\{ page.url }} {\{ page.url }}
{\{ page.date }} {\{ page.date }}
{\{ page.id }} {\{ page.id }} - unique id for RSS feeds
{\{ page.categories }} {\{ page.categories }}
{\{ page.tags }} {\{ page.tags }}
{\{ page.path }} {\{ page.path }}
{\{ post.excerpt | remove: '<p>' | remove: '</p>' }}
{\{ post.excerpt | strip_html }}
### Paginator <!-- blog pagination: -->
{\{ page.next }}
{\{ page.previous }}
### [Paginator](http://jekyllrb.com/docs/pagination/)
{\{ paginator.page }} - page number
{\{ paginator.total_posts}}
{\{ paginator.total_pages}}
{\{ paginator.per_page }} {\{ paginator.per_page }}
{\{ paginator.posts }}
{\% for post in paginator.posts %} ... {\% endfor %}
{\% if paginator.previous_page %}
<a href="{\{ paginator.previous_page_path }}">Previous</a>
{\% else %}
{\% endif %}
{\{ paginator.next_page }} - page number
{\{ paginator.next_page_path }}
... ...
Sample code {\% if paginator.total_pages > 1 %}
----------- {\% endif %}
Add this to `_config.yml`:
paginate: 5
paginate_path: "blog/:num"
### Code
{\% highlight ruby linenos %}
def show
...
end
{\% endhighlight %}
Markup
------
### Loops ### Loops
@ -119,6 +150,34 @@ Sample code
{\% include header.html %} {\% include header.html %}
Blogging
--------
_posts/YEAR-MONTH-DAY-title.md
### Image paths
![My helpful screenshot]({\{ site.url }}/assets/screenshot.jpg)
### [Drafts](http://jekyllrb.com/docs/drafts/)
vi _drafts/a-draft-post.md
jekyll build --drafts
### [Permalinks](http://jekyllrb.com/docs/permalinks/)
# _config.yml
permalink: date # /:categories/:year/:month/:day/:title.html
permalink: pretty # /:categories/:year/:month/:day/:title/
permalink: none # /:categories/:title.html
permalink: "/:title"
## [Data](http://jekyllrb.com/docs/datafiles/)
_data/members.yml
{\% for member in site.data.members %}
Integration Integration
----------- -----------
@ -132,3 +191,7 @@ Integration
* [Compass](https://gist.github.com/parkr/2874934) * [Compass](https://gist.github.com/parkr/2874934)
* [Asset pipeline](https://github.com/matthodan/jekyll-asset-pipeline) * [Asset pipeline](https://github.com/matthodan/jekyll-asset-pipeline)
### References
* http://jekyllrb.com/docs/home/