Commit 8ec8eaab authored by Kosmas Hench's avatar Kosmas Hench

updated bookdown

parent 146c79d1
---
output: html_document
editor_options:
chunk_output_type: console
---
# Workflow
......
.book .book-header h1 {
padding-left: 20px;
padding-right: 20px;
}
.book .book-header.fixed {
position: fixed;
right: 0;
top: 0;
left: 0;
border-bottom: 1px solid rgba(0,0,0,.07);
}
span.search-highlight {
background-color: #ffff88;
}
@media (min-width: 600px) {
.book.with-summary .book-header.fixed {
left: 300px;
}
}
@media (max-width: 1240px) {
.book .book-body.fixed {
top: 50px;
}
.book .book-body.fixed .body-inner {
top: auto;
}
}
@media (max-width: 600px) {
.book.with-summary .book-header.fixed {
left: calc(100% - 60px);
min-width: 300px;
}
.book.with-summary .book-body {
transform: none;
left: calc(100% - 60px);
min-width: 300px;
}
.book .book-body.fixed {
top: 0;
}
}
.book .book-body.fixed .body-inner {
top: 50px;
}
.book .book-body .page-wrapper .page-inner section.normal sub, .book .book-body .page-wrapper .page-inner section.normal sup {
font-size: 85%;
}
@media print {
.book .book-summary, .book .book-body .book-header, .fa {
display: none !important;
}
.book .book-body.fixed {
left: 0px;
}
.book .book-body,.book .book-body .body-inner, .book.with-summary {
overflow: visible !important;
}
}
.kable_wrapper {
border-spacing: 20px 0;
border-collapse: separate;
border: none;
margin: auto;
}
.kable_wrapper > tbody > tr > td {
vertical-align: top;
}
.book .book-body .page-wrapper .page-inner section.normal table tr.header {
border-top-width: 2px;
}
.book .book-body .page-wrapper .page-inner section.normal table tr:last-child td {
border-bottom-width: 2px;
}
.book .book-body .page-wrapper .page-inner section.normal table td, .book .book-body .page-wrapper .page-inner section.normal table th {
border-left: none;
border-right: none;
}
.book .book-body .page-wrapper .page-inner section.normal table.kable_wrapper > tbody > tr, .book .book-body .page-wrapper .page-inner section.normal table.kable_wrapper > tbody > tr > td {
border-top: none;
}
.book .book-body .page-wrapper .page-inner section.normal table.kable_wrapper > tbody > tr:last-child > td {
border-bottom: none;
}
div.theorem, div.lemma, div.corollary, div.proposition {
font-style: italic;
}
span.theorem, span.lemma, span.corollary, span.proposition {
font-style: normal;
}
div.proof:after {
content: "\25a2";
float: right;
}
.header-section-number {
padding-right: .5em;
}
/*
* Theme 1
*/
.color-theme-1 .dropdown-menu {
background-color: #111111;
border-color: #7e888b;
}
.color-theme-1 .dropdown-menu .dropdown-caret .caret-inner {
border-bottom: 9px solid #111111;
}
.color-theme-1 .dropdown-menu .buttons {
border-color: #7e888b;
}
.color-theme-1 .dropdown-menu .button {
color: #afa790;
}
.color-theme-1 .dropdown-menu .button:hover {
color: #73553c;
}
/*
* Theme 2
*/
.color-theme-2 .dropdown-menu {
background-color: #2d3143;
border-color: #272a3a;
}
.color-theme-2 .dropdown-menu .dropdown-caret .caret-inner {
border-bottom: 9px solid #2d3143;
}
.color-theme-2 .dropdown-menu .buttons {
border-color: #272a3a;
}
.color-theme-2 .dropdown-menu .button {
color: #62677f;
}
.color-theme-2 .dropdown-menu .button:hover {
color: #f4f4f5;
}
.book .book-header .font-settings .font-enlarge {
line-height: 30px;
font-size: 1.4em;
}
.book .book-header .font-settings .font-reduce {
line-height: 30px;
font-size: 1em;
}
.book.color-theme-1 .book-body {
color: #704214;
background: #f3eacb;
}
.book.color-theme-1 .book-body .page-wrapper .page-inner section {
background: #f3eacb;
}
.book.color-theme-2 .book-body {
color: #bdcadb;
background: #1c1f2b;
}
.book.color-theme-2 .book-body .page-wrapper .page-inner section {
background: #1c1f2b;
}
.book.font-size-0 .book-body .page-inner section {
font-size: 1.2rem;
}
.book.font-size-1 .book-body .page-inner section {
font-size: 1.4rem;
}
.book.font-size-2 .book-body .page-inner section {
font-size: 1.6rem;
}
.book.font-size-3 .book-body .page-inner section {
font-size: 2.2rem;
}
.book.font-size-4 .book-body .page-inner section {
font-size: 4rem;
}
.book.font-family-0 {
font-family: Georgia, serif;
}
.book.font-family-1 {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal {
color: #704214;
}
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal a {
color: inherit;
}
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal h1,
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal h2,
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal h3,
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal h4,
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal h5,
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal h6 {
color: inherit;
}
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal h1,
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal h2 {
border-color: inherit;
}
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal h6 {
color: inherit;
}
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal hr {
background-color: inherit;
}
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal blockquote {
border-color: inherit;
}
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre,
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code {
background: #fdf6e3;
color: #657b83;
border-color: #f8df9c;
}
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal .highlight {
background-color: inherit;
}
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal table th,
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal table td {
border-color: #f5d06c;
}
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal table tr {
color: inherit;
background-color: #fdf6e3;
border-color: #444444;
}
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal table tr:nth-child(2n) {
background-color: #fbeecb;
}
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal {
color: #bdcadb;
}
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal a {
color: #3eb1d0;
}
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal h1,
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal h2,
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal h3,
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal h4,
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal h5,
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal h6 {
color: #fffffa;
}
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal h1,
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal h2 {
border-color: #373b4e;
}
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal h6 {
color: #373b4e;
}
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal hr {
background-color: #373b4e;
}
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal blockquote {
border-color: #373b4e;
}
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre,
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code {
color: #9dbed8;
background: #2d3143;
border-color: #2d3143;
}
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal .highlight {
background-color: #282a39;
}
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal table th,
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal table td {
border-color: #3b3f54;
}
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal table tr {
color: #b6c2d2;
background-color: #2d3143;
border-color: #3b3f54;
}
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal table tr:nth-child(2n) {
background-color: #35394b;
}
.book.color-theme-1 .book-header {
color: #afa790;
background: transparent;
}
.book.color-theme-1 .book-header .btn {
color: #afa790;
}
.book.color-theme-1 .book-header .btn:hover {
color: #73553c;
background: none;
}
.book.color-theme-1 .book-header h1 {
color: #704214;
}
.book.color-theme-2 .book-header {
color: #7e888b;
background: transparent;
}
.book.color-theme-2 .book-header .btn {
color: #3b3f54;
}
.book.color-theme-2 .book-header .btn:hover {
color: #fffff5;
background: none;
}
.book.color-theme-2 .book-header h1 {
color: #bdcadb;
}
.book.color-theme-1 .book-body .navigation {
color: #afa790;
}
.book.color-theme-1 .book-body .navigation:hover {
color: #73553c;
}
.book.color-theme-2 .book-body .navigation {
color: #383f52;
}
.book.color-theme-2 .book-body .navigation:hover {
color: #fffff5;
}
/*
* Theme 1
*/
.book.color-theme-1 .book-summary {
color: #afa790;
background: #111111;
border-right: 1px solid rgba(0, 0, 0, 0.07);
}
.book.color-theme-1 .book-summary .book-search {
background: transparent;
}
.book.color-theme-1 .book-summary .book-search input,
.book.color-theme-1 .book-summary .book-search input:focus {
border: 1px solid transparent;
}
.book.color-theme-1 .book-summary ul.summary li.divider {
background: #7e888b;
box-shadow: none;
}
.book.color-theme-1 .book-summary ul.summary li i.fa-check {
color: #33cc33;
}
.book.color-theme-1 .book-summary ul.summary li.done > a {
color: #877f6a;
}
.book.color-theme-1 .book-summary ul.summary li a,
.book.color-theme-1 .book-summary ul.summary li span {
color: #877f6a;
background: transparent;
font-weight: normal;
}
.book.color-theme-1 .book-summary ul.summary li.active > a,
.book.color-theme-1 .book-summary ul.summary li a:hover {
color: #704214;
background: transparent;
font-weight: normal;
}
/*
* Theme 2
*/
.book.color-theme-2 .book-summary {
color: #bcc1d2;
background: #2d3143;
border-right: none;
}
.book.color-theme-2 .book-summary .book-search {
background: transparent;
}
.book.color-theme-2 .book-summary .book-search input,
.book.color-theme-2 .book-summary .book-search input:focus {
border: 1px solid transparent;
}
.book.color-theme-2 .book-summary ul.summary li.divider {
background: #272a3a;
box-shadow: none;
}
.book.color-theme-2 .book-summary ul.summary li i.fa-check {
color: #33cc33;
}
.book.color-theme-2 .book-summary ul.summary li.done > a {
color: #62687f;
}
.book.color-theme-2 .book-summary ul.summary li a,
.book.color-theme-2 .book-summary ul.summary li span {
color: #c1c6d7;
background: transparent;
font-weight: 600;
}
.book.color-theme-2 .book-summary ul.summary li.active > a,
.book.color-theme-2 .book-summary ul.summary li a:hover {
color: #f4f4f5;
background: #252737;
font-weight: 600;
}
This diff is collapsed.
.book .book-summary .book-search {
padding: 6px;
background: transparent;
position: absolute;
top: -50px;
left: 0px;
right: 0px;
transition: top 0.5s ease;
}
.book .book-summary .book-search input,
.book .book-summary .book-search input:focus,
.book .book-summary .book-search input:hover {
width: 100%;
background: transparent;
border: 1px solid #ccc;
box-shadow: none;
outline: none;
line-height: 22px;
padding: 7px 4px;
color: inherit;
box-sizing: border-box;
}
.book.with-search .book-summary .book-search {
top: 0px;
}
.book.with-search .book-summary ul.summary {
top: 50px;
}
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
gitbook.require(["jQuery"], function(jQuery) {
/*
* jQuery Highlight plugin
*
* Based on highlight v3 by Johann Burkard
* http://johannburkard.de/blog/programming/javascript/highlight-javascript-text-higlighting-jquery-plugin.html
*
* Code a little bit refactored and cleaned (in my humble opinion).
* Most important changes:
* - has an option to highlight only entire words (wordsOnly - false by default),
* - has an option to be case sensitive (caseSensitive - false by default)
* - highlight element tag and class names can be specified in options
*
* Copyright (c) 2009 Bartek Szopka
*
* Licensed under MIT license.
*
*/
jQuery.extend({
highlight: function (node, re, nodeName, className) {
if (node.nodeType === 3) {
var match = node.data.match(re);
if (match) {
var highlight = document.createElement(nodeName || 'span');
highlight.className = className || 'highlight';
var wordNode = node.splitText(match.index);
wordNode.splitText(match[0].length);
var wordClone = wordNode.cloneNode(true);
highlight.appendChild(wordClone);
wordNode.parentNode.replaceChild(highlight, wordNode);
return 1; //skip added node in parent
}
} else if ((node.nodeType === 1 && node.childNodes) && // only element nodes that have children
!/(script|style)/i.test(node.tagName) && // ignore script and style nodes
!(node.tagName === nodeName.toUpperCase() && node.className === className)) { // skip if already highlighted
for (var i = 0; i < node.childNodes.length; i++) {
i += jQuery.highlight(node.childNodes[i], re, nodeName, className);
}
}
return 0;
}
});
jQuery.fn.unhighlight = function (options) {
var settings = { className: 'highlight', element: 'span' };
jQuery.extend(settings, options);
return this.find(settings.element + "." + settings.className).each(function () {
var parent = this.parentNode;
parent.replaceChild(this.firstChild, this);
parent.normalize();
}).end();
};
jQuery.fn.highlight = function (words, options) {
var settings = { className: 'highlight', element: 'span', caseSensitive: false, wordsOnly: false };
jQuery.extend(settings, options);
if (words.constructor === String) {
words = [words];
}
words = jQuery.grep(words, function(word, i){
return word !== '';
});
words = jQuery.map(words, function(word, i) {
return word.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
});
if (words.length === 0) { return this; }
var flag = settings.caseSensitive ? "" : "i";
var pattern = "(" + words.join("|") + ")";
if (settings.wordsOnly) {
pattern = "\\b" + pattern + "\\b";
}
var re = new RegExp(pattern, flag);
return this.each(function () {
jQuery.highlight(this, re, settings.element, settings.className);
});
};
});
This diff is collapsed.
gitbook.require(["gitbook", "lodash", "jQuery"], function(gitbook, _, $) {
var gs = gitbook.storage;
gitbook.events.bind("start", function(e, config) {
// add the Edit button (edit on Github)
var edit = config.edit;
if (edit && edit.link) gitbook.toolbar.createButton({
icon: 'fa fa-edit',
label: edit.text || 'Edit',
position: 'left',
onClick: function(e) {
e.preventDefault();
window.open(edit.link);
}
});
var down = config.download;
var normalizeDownload = function() {
if (!down || !(down instanceof Array) || down.length === 0) return;
if (down[0] instanceof Array) return down;
return $.map(down, function(file, i) {
return [[file, file.replace(/.*[.]/g, '').toUpperCase()]];
});
};
down = normalizeDownload(down);
if (down) if (down.length === 1 && /[.]pdf$/.test(down[0][0])) {
gitbook.toolbar.createButton({
icon: 'fa fa-file-pdf-o',
label: down[0][1],
position: 'left',
onClick: function(e) {
e.preventDefault();
window.open(down[0][0]);
}
});
} else {
gitbook.toolbar.createButton({
icon: 'fa fa-download',
label: 'Download',
position: 'left',
dropdown: $.map(down, function(item, i) {
return {
text: item[1],
onClick: function(e) {
e.preventDefault();
window.open(item[0]);
}
};
})
});
}
// highlight the current section in TOC
var href = window.location.pathname;
href = href.substr(href.lastIndexOf('/') + 1);
if (href === '') href = 'index.html';
var li = $('a[href^="' + href + location.hash + '"]').parent('li.chapter').first();
var summary = $('ul.summary'), chaps = summary.find('li.chapter');
if (li.length === 0) li = chaps.first();
li.addClass('active');
chaps.on('click', function(e) {
chaps.removeClass('active');
$(this).addClass('active');
gs.set('tocScrollTop', summary.scrollTop());
});
var toc = config.toc;
// collapse TOC items that are not for the current chapter
if (toc && toc.collapse) (function() {
var type = toc.collapse;
if (type === 'none') return;
if (type !== 'section' && type !== 'subsection') return;
// sections under chapters
var toc_sub = summary.children('li[data-level]').children('ul');
if (type === 'section') {
toc_sub.hide()
.parent().has(li).children('ul').show();
} else {
toc_sub.children('li').children('ul').hide()
.parent().has(li).children('ul').show();
}
li.children('ul').show();
var toc_sub2 = toc_sub.children('li');
if (type === 'section') toc_sub2.children('ul').hide();
summary.children('li[data-level]').find('a')
.on('click.bookdown', function(e) {
if (href === $(this).attr('href').replace(/#.*/, ''))
$(this).parent('li').children('ul').toggle();
});
})();
// add tooltips to the <a>'s that are truncated
$('a').each(function(i, el) {
if (el.offsetWidth >= el.scrollWidth) return;
if (typeof el.title === 'undefined') return;
el.title = el.text;
});
// restore TOC scroll position
var pos = gs.get('tocScrollTop');
if (typeof pos !== 'undefined') summary.scrollTop(pos);
// highlight the TOC item that has same text as the heading in view as scrolling
if (toc && toc.scroll_highlight !== false) (function() {
// scroll the current TOC item into viewport
var ht = $(window).height(), rect = li[0].getBoundingClientRect();
if (rect.top >= ht || rect.top <= 0 || rect.bottom <= 0) {
summary.scrollTop(li[0].offsetTop);
}
// current chapter TOC items
var items = $('a[href^="' + href + '"]').parent('li.chapter'),
m = items.length;
if (m === 0) {
items = summary.find('li.chapter');
m = items.length;
}
if (m === 0) return;
// all section titles on current page
var hs = bookInner.find('.page-inner').find('h1,h2,h3'), n = hs.length,
ts = hs.map(function(i, el) { return $(el).text(); });
if (n === 0) return;
var scrollHandler = function(e) {
var ht = $(window).height();
clearTimeout($.data(this, 'scrollTimer'));
$.data(this, 'scrollTimer', setTimeout(function() {
// find the first visible title in the viewport
for (var i = 0; i < n; i++) {
var rect = hs[i].getBoundingClientRect();
if (rect.top >= 0 && rect.bottom <= ht) break;
}
if (i === n) return;
items.removeClass('active');
for (var j = 0; j < m; j++) {
if (items.eq(j).children('a').first().text() === ts[i]) break;
}
if (j === m) j = 0; // highlight the chapter title
// search bottom-up for a visible TOC item to highlight; if an item is
// hidden, we check if its parent is visible, and so on
while (j > 0 && items.eq(j).is(':hidden')) j--;
items.eq(j).addClass('active');
}, 250));
};
bookInner.on('scroll.bookdown', scrollHandler);
bookBody.on('scroll.bookdown', scrollHandler);
})();
// do not refresh the page if the TOC item points to the current page
$('a[href="' + href + '"]').parent('li.chapter').children('a')
.on('click', function(e) {
bookInner.scrollTop(0);
bookBody.scrollTop(0);
return false;
});
var toolbar = config.toolbar;
if (!toolbar || toolbar.position !== 'static') {
var bookHeader = $('.book-header');
bookBody.addClass('fixed');
bookHeader.addClass('fixed')
.css('background-color', bookBody.css('background-color'))
.on('click.bookdown', function(e) {