mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-10-08 06:11:38 +00:00
Improve style for page printing
This commit is contained in:
@@ -19,7 +19,7 @@ var Generator = function() {
|
||||
this.template = swig.compileFile(path.resolve(this.options.theme, 'templates/page.html'));
|
||||
|
||||
// List of pages content
|
||||
this.pages = [];
|
||||
this.pages = {};
|
||||
};
|
||||
util.inherits(Generator, BaseGenerator);
|
||||
|
||||
@@ -49,7 +49,7 @@ Generator.prototype.convertFile = function(content, input) {
|
||||
json.content = sections;
|
||||
})
|
||||
.then(function() {
|
||||
that.pages.push(json);
|
||||
that.pages[input] = json;
|
||||
});
|
||||
};
|
||||
|
||||
@@ -59,13 +59,6 @@ Generator.prototype.finish = function() {
|
||||
var output = path.join(this.options.output, "index.html");
|
||||
|
||||
return Q()
|
||||
// Order pages
|
||||
.then(function() {
|
||||
return _.sortBy(that.pages, function(page) {
|
||||
return page.progress.current.level;
|
||||
});
|
||||
})
|
||||
|
||||
// Generate html
|
||||
.then(function(pages) {
|
||||
return that.template({
|
||||
@@ -79,7 +72,7 @@ Generator.prototype.finish = function() {
|
||||
summary: that.options.summary,
|
||||
allNavigation: that.options.navigation,
|
||||
|
||||
pages: pages,
|
||||
pages: that.pages,
|
||||
|
||||
basePath: basePath,
|
||||
staticBase: path.join(basePath, "gitbook"),
|
||||
|
||||
@@ -1 +1 @@
|
||||
.hljs-comment,.hljs-title{color:#8e908c}.hljs-variable,.hljs-attribute,.hljs-tag,.hljs-regexp,.ruby .hljs-constant,.xml .hljs-tag .hljs-title,.xml .hljs-pi,.xml .hljs-doctype,.html .hljs-doctype,.css .hljs-id,.css .hljs-class,.css .hljs-pseudo{color:#c82829}.hljs-number,.hljs-preprocessor,.hljs-pragma,.hljs-built_in,.hljs-literal,.hljs-params,.hljs-constant{color:#f5871f}.ruby .hljs-class .hljs-title,.css .hljs-rules .hljs-attribute{color:#eab700}.hljs-string,.hljs-value,.hljs-inheritance,.hljs-header,.ruby .hljs-symbol,.xml .hljs-cdata{color:#718c00}.css .hljs-hexcolor{color:#3e999f}.hljs-function,.python .hljs-decorator,.python .hljs-title,.ruby .hljs-function .hljs-title,.ruby .hljs-title .hljs-keyword,.perl .hljs-sub,.javascript .hljs-title,.coffeescript .hljs-title{color:#4271ae}.hljs-keyword,.javascript .hljs-function{color:#8959a8}.hljs{display:block;background:white;color:#4d4d4c;padding:.5em}.coffeescript .javascript,.javascript .xml,.tex .hljs-formula,.xml .javascript,.xml .vbscript,.xml .css,.xml .hljs-cdata{opacity:.5}body{font:12pt Georgia,"Times New Roman",Times,serif;line-height:1.3}@page{margin:1.5cm}section{page-break-after:always}section article:after{border-bottom:1px solid #ccc}
|
||||
.hljs-comment,.hljs-title{color:#8e908c}.hljs-variable,.hljs-attribute,.hljs-tag,.hljs-regexp,.ruby .hljs-constant,.xml .hljs-tag .hljs-title,.xml .hljs-pi,.xml .hljs-doctype,.html .hljs-doctype,.css .hljs-id,.css .hljs-class,.css .hljs-pseudo{color:#c82829}.hljs-number,.hljs-preprocessor,.hljs-pragma,.hljs-built_in,.hljs-literal,.hljs-params,.hljs-constant{color:#f5871f}.ruby .hljs-class .hljs-title,.css .hljs-rules .hljs-attribute{color:#eab700}.hljs-string,.hljs-value,.hljs-inheritance,.hljs-header,.ruby .hljs-symbol,.xml .hljs-cdata{color:#718c00}.css .hljs-hexcolor{color:#3e999f}.hljs-function,.python .hljs-decorator,.python .hljs-title,.ruby .hljs-function .hljs-title,.ruby .hljs-title .hljs-keyword,.perl .hljs-sub,.javascript .hljs-title,.coffeescript .hljs-title{color:#4271ae}.hljs-keyword,.javascript .hljs-function{color:#8959a8}.hljs{display:block;background:white;color:#4d4d4c;padding:.5em}.coffeescript .javascript,.javascript .xml,.tex .hljs-formula,.xml .javascript,.xml .vbscript,.xml .css,.xml .hljs-cdata{opacity:.5}body{font:12pt Georgia,"Times New Roman",Times,serif;line-height:1.3}h1,h2{page-break-after:avoid;page-break-before:auto}pre,blockquote{border:1px solid #999;page-break-inside:avoid}img{max-width:100%!important;page-break-inside:avoid}section{page-break-after:always}section#cover{padding:3cm 0;text-align:center}section#cover h1{font-size:1.5cm}section#summary{text-align:center}section#summary ul{font-size:.5cm;line-height:1.8em;padding:0;margin:0;list-style:none}section#summary>ul>li{margin-bottom:1cm}section#summary>ul>li>a{font-size:.6cm}section article{margin:1.5cm}section article.new-chapter{page-break-after:always;font-size:.6cm;text-align:center;padding:3cm 0}
|
||||
File diff suppressed because one or more lines are too long
@@ -5,16 +5,63 @@ body {
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
@page {
|
||||
margin: 1.5cm;
|
||||
h1, h2 {
|
||||
page-break-after: avoid;
|
||||
page-break-before: auto;
|
||||
}
|
||||
|
||||
pre, blockquote {
|
||||
border: 1px solid #999;
|
||||
page-break-inside: avoid;
|
||||
}
|
||||
|
||||
img {
|
||||
max-width: 100% !important;
|
||||
page-break-inside: avoid;
|
||||
}
|
||||
|
||||
section {
|
||||
page-break-after: always;
|
||||
|
||||
&#cover {
|
||||
padding: 3cm 0cm;
|
||||
text-align: center;
|
||||
|
||||
h1 {
|
||||
font-size: 1.5cm;
|
||||
}
|
||||
}
|
||||
|
||||
&#summary {
|
||||
text-align: center;
|
||||
|
||||
ul {
|
||||
font-size: 0.5cm;
|
||||
line-height: 1.8em;
|
||||
padding: 0px;
|
||||
margin: 0px;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
> ul {
|
||||
> li {
|
||||
margin-bottom: 1cm;
|
||||
|
||||
> a {
|
||||
font-size: 0.6cm;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
article {
|
||||
&:after {
|
||||
border-bottom: 1px solid #ccc;
|
||||
margin: 1.5cm;
|
||||
|
||||
&.new-chapter {
|
||||
page-break-after: always;
|
||||
font-size: 0.6cm;
|
||||
text-align: center;
|
||||
padding: 3cm 0cm;
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -14,7 +14,7 @@
|
||||
|
||||
// Reset
|
||||
@import "normalize.less";
|
||||
@import "print.less";
|
||||
//@import "print.less";
|
||||
|
||||
// Core CSS
|
||||
@import "scaffolding.less";
|
||||
|
||||
+23
-10
@@ -3,6 +3,7 @@
|
||||
{% block title %}{{ title }}{% endblock %}
|
||||
|
||||
{% block style %}
|
||||
{% parent %}
|
||||
<link rel="stylesheet" href="{{ staticBase }}/print.css">
|
||||
{% endblock %}
|
||||
|
||||
@@ -11,23 +12,25 @@
|
||||
{# Cover #}
|
||||
<section id="cover">
|
||||
<h1>{{ title }}</h1>
|
||||
<h2>By @{{ githubAuthor }}</h2>
|
||||
<h2>By <a href="{{ githubHost }}{{ githubAuthor }}">@{{ githubAuthor }}</a></h2>
|
||||
</section>
|
||||
|
||||
{# Summary #}
|
||||
<section id="summary">
|
||||
<h1>Summary</h1>
|
||||
|
||||
<ul class="summary">
|
||||
<li>
|
||||
<a href="#README.md">Introduction</a>
|
||||
</li>
|
||||
{% for item in summary.chapters %}
|
||||
<li>
|
||||
<a href="#{{ item.path }}"><b>{{ item.level }})</b> {{ item.title }}</a>
|
||||
<a href="#{{ item.path }}">{{ item.level }}) {{ item.title }}</a>
|
||||
{% if item.articles.length > 0 %}
|
||||
<ul>
|
||||
{% for article in item.articles %}
|
||||
<li>
|
||||
<a href="#{{ article.path }}"><b>{{ article.level }})</b> {{ article.title }}</a>
|
||||
<a href="#{{ article.path }}">{{ article.level }}) {{ article.title }}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
@@ -38,15 +41,25 @@
|
||||
</section>
|
||||
|
||||
{# Pages content #}
|
||||
{% for page in pages %}
|
||||
<article id="{{ page.path }}">
|
||||
{% for section in page.content %}
|
||||
{% if section.type == "normal" %}
|
||||
{% autoescape false %}{{ section.content }}{% endautoescape %}
|
||||
{% for item in summary.chapters %}
|
||||
{% if item.articles.length > 0 %}
|
||||
<section>
|
||||
<article class="new-chapter">
|
||||
<h1>{{ item.title }}</h1>
|
||||
</article>
|
||||
|
||||
{% for article in item.articles %}
|
||||
<article id="{{ article.path }}">
|
||||
{% for section in pages[article.path].content %}
|
||||
{% if section.type == "normal" %}
|
||||
{% autoescape false %}{{ section.content }}{% endautoescape %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</article>
|
||||
{% endfor %}
|
||||
</section>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</article>
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
|
||||
{% block javascript %}{% endblock %}
|
||||
Reference in New Issue
Block a user