Compare commits

...

43 Commits

Author SHA1 Message Date
e0e88e963a fix 404 error 2025-04-25 12:47:31 +08:00
f933650123 Merge pull request #507 from roneya/master
Smart Pointer Exercises for Box
2025-04-25 12:23:38 +08:00
21460fad98 Merge pull request #454 from 0xByteLeon/master
fix: Correct the wrong answer to Exercise 11 in Chapter borrowing
2025-04-25 12:12:21 +08:00
f659004418 Merge pull request #431 from stappersg/welcome_all
git clone HTTPS URL
2025-04-25 12:11:29 +08:00
0e2f42a214 Merge pull request #430 from xplorer1/patch-1
Update functions.md
2025-04-25 12:10:56 +08:00
8d25a5067c Merge pull request #422 from niyaznigmatullin/niyaznigmatullin-patch-1
Fix editability of tasks in `iterator.md`
2025-04-25 12:10:25 +08:00
716144c1ef Merge pull request #417 from adityakaklij/patch-1
Update ownership.md.
2025-04-25 12:09:51 +08:00
8377d339ce Merge pull request #416 from vittorius/patch-1
Fix dot call syntax in exercises to be double colon
2025-04-25 12:08:46 +08:00
fa0db45ae3 Merge pull request #415 from lostsquirrel/patch-1
remove the mistable semicolon
2025-04-25 12:08:10 +08:00
67920d9db0 Merge pull request #414 from Spartan09/patch-1
Update Q6 array.md
2025-04-25 12:07:28 +08:00
adfb3ed34d Merge pull request #401 from skaunov/patch-5
Update solution closure.md
2025-04-25 12:05:31 +08:00
bc9b3f3ec3 Merge pull request #528 from mckzm/master
Fix typo to make the Iterator section's exercise 8 editable in the browser
2025-04-25 12:03:51 +08:00
50d5af5cf0 Merge pull request #529 from Kibiandkimi/master
add editable to problem 4&6 in zh-CN/src/lifetime/advance.md
2025-04-25 12:01:29 +08:00
6765d55c47 Merge pull request #530 from a-mroz/patch-1
Update numbers.md – clear up instructions about printing range of ASCII characters
2025-04-25 12:00:55 +08:00
25842927fc Merge pull request #533 from Sagecheni/fix-typo
Fixing a typo at match-iflet
2025-04-25 11:58:32 +08:00
0302542061 Merge pull request #543 from nativemen/optimize
Fix minor issues to meet the requirements of the question and recommend using the modules provided by the library crate.
2025-04-25 11:57:26 +08:00
4e790a35be Merge pull request #546 from jpenna/patch-3
Add new solution in ownership ex. 9
2025-04-25 11:55:42 +08:00
2e1d40b55b Merge pull request #547 from msuganthan/patch-1
use ref instead of clone
2025-04-25 11:54:41 +08:00
c37f77758f Merge pull request #555 from vhyijk/patch-1
Update why-exercise.md
2025-04-25 11:53:27 +08:00
2cddf85611 Update why-exercise.md
改变 `git clone` 的链接,使其正常工作
2025-03-31 12:46:13 +08:00
94079c49af use ref 2025-03-01 19:06:53 -05:00
609e2d3f8c Add new solution in ownership ex. 9 2025-02-18 11:01:21 -03:00
a19015f9fa Fix minor issues to meet the requirements of the question and recommend using the modules provided by the library crate. 2025-01-20 12:49:39 -05:00
d89f88f1c3 Fixing a typo at match-iflet 2024-09-19 11:04:36 +08:00
73b7dd9694 Update numbers.md
I was really confused, why should I print out the result of subtracting two numbers in a loop (even though I'm very much aware of the ASCII characters). I hope it makes things a bit clearer.
2024-08-19 12:21:36 +02:00
3b6474a563 add editable to problem 6 in zh-CN/src/lifetime/advance.md 2024-08-04 09:15:56 +00:00
21188323d3 add editable to problem 4 in zh-CN/src/lifetime/advance.md 2024-08-04 04:47:02 +00:00
4f41faf49c Merge pull request #1 from mckzm/mckzm-iterator-8
Fix typo to make iterator's exercise 8 editable
2024-06-29 20:36:33 +09:00
ef381ba48d Fix typo to make iterator's exercise 8 editable 2024-06-29 20:28:16 +09:00
1410670d33 Merge branch 'sunface:master' into master 2024-05-05 10:51:46 +05:30
be61b49f9a Signed-off-by: roneya <iamrohanvidhate@gmail.com> 2024-03-12 18:12:37 +05:30
c478b37a0d Signed-off-by: roneya <iamrohanvidhate@gmail.com> 2024-03-12 18:05:37 +05:30
68c285d97b box practice questions 2024-03-12 18:01:16 +05:30
1c83c69d30 fix: Correct the wrong answer to Exercise 11 in Chapter borrowing
Calling only r1 in the new compiler version does not trigger a reborrowing error
2023-08-30 18:48:08 +08:00
1edb2c3125 git clone HTTPS URL
Changed the _git clone URL_ into an URL that is available
to all people that have Internet access.

Signed-off-by: Geert Stappers <stappers@stappers.it>
2023-08-05 11:16:46 +02:00
95d89d8f32 Update functions.md
There was a little grammatical error in this section.
I modified: `DON'T let `println!` works` to `DON'T let `println!` work`
2023-08-02 14:08:57 +01:00
a29f320605 Update iterator.md
Make two tasks editable
2023-07-19 15:19:13 +03:00
0600bb3bdc Fix typo in iterator.md
fix typo `edtiable` -> `editable`
2023-07-19 15:15:59 +03:00
5453e7a05c Update ownership.md.
Borrowing the variables in the first problem
2023-07-06 10:23:43 +05:30
5b9632276f Fix dot call syntax in exercises to be double colon
Looks like this was not intentional 🙂 and the dot syntax is not coming from Rust
2023-07-04 21:29:43 +03:00
2f1ed60e25 remove the mistable semicolon 2023-07-04 17:57:44 +08:00
ff6c841dd5 Update Q6 array.md
changed comment suggesting arr.get() return Option<T> to Option<&T>
2023-07-02 23:10:16 +05:30
0f9f0367d6 Update solution closure.md
Changed order of bounds so that readers new to Rust won't be confused by "bool + Copy" and could comprehend it faster and better.
2023-05-13 11:42:55 +03:00
18 changed files with 201 additions and 112 deletions

View File

@ -69,7 +69,7 @@ We use [mdbook](https://rust-lang.github.io/mdBook/) building our exercises. You
- Clone the repo
```shell
$ git clone git@github.com:sunface/rust-by-practice.git
$ git clone https://github.com/sunface/rust-by-practice
```
- Install mdbook using Cargo
```shell

View File

@ -120,7 +120,7 @@ fn main() {
```
### Range
9. 🌟🌟 Two goals: 1. Modify `assert!` to make it work 2. Make `println!` output: 97 - 122
9. 🌟🌟 Two goals: 1. Modify `assert!` to make it work 2. Make `println!` output list of numbers between 97 and 122
```rust,editable
fn main() {

View File

@ -63,7 +63,7 @@ fn main() {
}
fn sum(x: i32, y: i32) -> i32 {
x + y;
x + y
}
```

View File

@ -88,7 +88,7 @@ fn main() {
fn main() {
let names = [String::from("Sunfei"), "Sunface".to_string()];
// `Get` returns an Option<T>, it's safe to use
// `Get` returns an Option<&T>, it's safe to use
let name0 = names.get(0).unwrap();
// But indexing is not safe

View File

@ -50,10 +50,10 @@ mod front_of_house {
pub fn eat_at_restaurant() {
// Call add_to_waitlist with **absolute path**:
__.add_to_waitlist();
__::add_to_waitlist();
// Call with **relative path**
__.add_to_waitlist();
__::add_to_waitlist();
}
```
@ -67,7 +67,7 @@ mod back_of_house {
// FILL in the blank in three ways
//1. using keyword `super`
//2. using absolute path
__.serve_order();
__::serve_order();
}
fn cook_order() {}

View File

@ -223,7 +223,7 @@ Some of these methods call the method `next`to use up the iterator, so they are
8. 🌟🌟
```rust,edtiable
```rust,editable
/* Fill in the blank and fix the errors */
fn main() {

View File

@ -1 +1,52 @@
# Box
1. 🌟
```rust,editable
// Make it work
fn main() {
// Create a new box `b` that contains the integer 5
assert_eq!(*b, 5);
println!("Success!");
}
```
2. 🌟
```rust,editable
// Make it work
fn main() {
let b = Box::new("Hello");
print_boxed_string(b);
}
fn print_boxed_string(b : _) {
println!("{}", b);
}
```
3. 🌟
```rust,editable
// Make it work
fn main() {
let b1 = Box::new(5);
let b2 = b1;
assert_eq!(_, 5);
println!("Success!");
}
```
4. 🌟
```rust,editable
// Make it work
fn main() {
// Create a box `b` with an array [1, 2, 3, 4, 5]
// Print each integer in `b`
}
```
> You can find the solutions [here](https://github.com/sunface/rust-by-practice)(under the solutions path), but only use it when you need it

View File

@ -23,7 +23,7 @@ This book was designed for easily diving into and getting skilled with Rust, and
We use [mdbook](https://rust-lang.github.io/mdBook/) building our exercises. You can run locally with below steps:
```shell
$ git clone git@github.com:sunface/rust-by-practice.git
$ git clone https://github.com/sunface/rust-by-practice
$ cargo install mdbook
$ cd rust-by-practice && mdbook serve en/
```

View File

@ -83,8 +83,9 @@ mod back_of_house {
```rust
// in src/lib.rs
mod front_of_house;
mod back_of_house;
pub mod front_of_house;
pub mod back_of_house;
pub fn eat_at_restaurant() -> String {
front_of_house::hosting::add_to_waitlist();
@ -140,10 +141,8 @@ fn complain() {}
5.
```rust
mod front_of_house;
fn main() {
assert_eq!(front_of_house::hosting::seat_at_table(), "sit down please");
assert_eq!(hello_package::eat_at_restaurant(),"yummy yummy!");
assert_eq!(hello_package::front_of_house::hosting::seat_at_table(), "sit down please");
assert_eq!(hello_package::eat_at_restaurant(), "yummy yummy!");
}
```

View File

@ -118,7 +118,7 @@ fn main() {
```rust
fn fn_once<F>(func: F)
where
F: FnOnce(usize) -> bool + Copy,// 改动在这里
F: Copy + FnOnce(usize) -> bool,// 改动在这里
{
println!("{}", func(3));
println!("{}", func(4));

View File

@ -149,6 +149,6 @@ fn main() {
// add one line below to make a compiler error: cannot borrow `s` as mutable more than once at a time
// you can't use r1 and r2 at the same time
r1.push_str("world");
println!("{}, {}", r1, r2);
}
```

View File

@ -31,6 +31,15 @@ fn main() {
}
```
```
fn main() {
let x = String::from("hello, world");
let y = &x;
println!("{},{}",x,y);
}
```
2.
```rust
@ -163,7 +172,18 @@ fn main() {
let t = (String::from("hello"), String::from("world"));
// fill the blanks
let (s1, s2) = t.clone();
let (ref s1, ref s2) = t;
println!("{:?}, {:?}, {:?}", s1, s2, t); // -> "hello", "world", ("hello", "world")
}
```
```rust
fn main() {
let t = (String::from("hello"), String::from("world"));
// fill the blanks
let (ref s1, ref s2) = t;
println!("{:?}, {:?}, {:?}", s1, s2, t); // -> "hello", "world", ("hello", "world")
}

View File

@ -19,4 +19,4 @@ git-repository-url = "https://github.com/sunface/rust-by-practice"
edit-url-template = "https://github.com/sunface/rust-by-practice/edit/master/zh-CN/{path}"
[rust]
edition = "2021"
edition = "2018"

View File

@ -101,7 +101,7 @@ impl<'a> PartialEq<i32> for &'a T {
这里只能使用更高级别的约束,因为引用的生命周期比函数上任何可能的生命周期参数都短。
4. 🌟🌟🌟
```rust
```rust,editable
/* 添加 HRTB 使下面代码正常运行! */
fn call_on_ref_zero<'a, F>(f: F) where F: Fn(&'a i32) {
let zero = 0;
@ -237,7 +237,7 @@ struct Ref<'a, T> {
## 艰难的练习
6. 🌟🌟🌟🌟
```rust
```rust,editable
/* 使下面代码正常运行 */
struct Interface<'a> {
manager: &'a mut Manager<'a>

View File

@ -87,7 +87,7 @@ fn show_message(msg: Message) {
fn main() {
let alphabets = ['a', 'E', 'Z', '0', 'x', '9' , 'Y'];
// 使用 `matches` 填空
// 使用 `matches!` 填空
for ab in alphabets {
assert!(__)
}

View File

@ -23,7 +23,7 @@
我们使用 [mdbook](https://rust-lang.github.io/mdBook/) 构建在线练习题,你也可以下载到本地运行:
```shell
$ git clone git@github.com:sunface/rust-by-practice.git
$ git clone https://github.com/sunface/rust-by-practice
$ cargo install mdbook
$ cd rust-by-practice && mdbook serve zh-CN/
```

View File

@ -1,59 +1,62 @@
<!DOCTYPE HTML>
<html lang="{{ language }}" class="{{ default_theme }}" dir="{{ text_direction }}">
<head>
<!-- Book generated using mdBook -->
<meta charset="UTF-8">
<title>{{ title }}</title>
{{#if is_print }}
<meta name="robots" content="noindex">
{{/if}}
{{#if base_url}}
<base href="{{ base_url }}">
{{/if}}
<head>
<!-- Book generated using mdBook -->
<meta charset="UTF-8">
<title>{{ title }}</title>
{{#if is_print }}
<meta name="robots" content="noindex">
{{/if}}
{{#if base_url}}
<base href="{{ base_url }}">
{{/if}}
<!-- Custom HTML head -->
{{> head}}
<!-- Custom HTML head -->
{{> head}}
<meta name="description" content="{{ description }}">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#ffffff">
<meta name="description" content="{{ description }}">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#ffffff">
{{#if favicon_svg}}
<link rel="icon" href="{{ path_to_root }}favicon.svg">
{{/if}}
{{#if favicon_png}}
<link rel="shortcut icon" href="{{ path_to_root }}favicon.png">
{{/if}}
<link rel="stylesheet" href="{{ path_to_root }}css/variables.css">
<link rel="stylesheet" href="{{ path_to_root }}css/general.css">
<link rel="stylesheet" href="{{ path_to_root }}css/chrome.css">
{{#if print_enable}}
<link rel="stylesheet" href="{{ path_to_root }}css/print.css" media="print">
{{/if}}
{{#if favicon_svg}}
<link rel="icon" href="{{ path_to_root }}favicon.svg">
{{/if}}
{{#if favicon_png}}
<link rel="shortcut icon" href="{{ path_to_root }}favicon.png">
{{/if}}
<link rel="stylesheet" href="{{ path_to_root }}css/variables.css">
<link rel="stylesheet" href="{{ path_to_root }}css/general.css">
<link rel="stylesheet" href="{{ path_to_root }}css/chrome.css">
{{#if print_enable}}
<link rel="stylesheet" href="{{ path_to_root }}css/print.css" media="print">
{{/if}}
<!-- Fonts -->
<link rel="stylesheet" href="{{ path_to_root }}FontAwesome/css/font-awesome.css">
{{#if copy_fonts}}
<link rel="stylesheet" href="{{ path_to_root }}fonts/fonts.css">
{{/if}}
<!-- Fonts -->
<link rel="stylesheet" href="{{ path_to_root }}FontAwesome/css/font-awesome.css">
{{#if copy_fonts}}
<link rel="stylesheet" href="{{ path_to_root }}fonts/fonts.css">
{{/if}}
<!-- Highlight.js Stylesheets -->
<link rel="stylesheet" href="{{ path_to_root }}highlight.css">
<link rel="stylesheet" href="{{ path_to_root }}tomorrow-night.css">
<link rel="stylesheet" href="{{ path_to_root }}ayu-highlight.css">
<!-- Highlight.js Stylesheets -->
<link rel="stylesheet" href="{{ path_to_root }}highlight.css">
<link rel="stylesheet" href="{{ path_to_root }}tomorrow-night.css">
<link rel="stylesheet" href="{{ path_to_root }}ayu-highlight.css">
<!-- Custom theme stylesheets -->
{{#each additional_css}}
<link rel="stylesheet" href="{{ ../path_to_root }}{{ this }}">
{{/each}}
<!-- Custom theme stylesheets -->
{{#each additional_css}}
<link rel="stylesheet" href="{{ ../path_to_root }}{{ this }}">
{{/each}}
{{#if mathjax_support}}
<!-- MathJax -->
<script async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
{{/if}}
</head>
<body class="sidebar-visible no-js">
{{#if mathjax_support}}
<!-- MathJax -->
<script async
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
{{/if}}
</head>
<body class="sidebar-visible no-js">
<div id="body-container">
<!-- Provide site root to javascript -->
<script>
@ -80,7 +83,7 @@
<!-- Set the theme before any content is loaded, prevents flash -->
<script>
var theme;
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
try { theme = localStorage.getItem('mdbook-theme'); } catch (e) { }
if (theme === null || theme === undefined) { theme = default_theme; }
var html = document.querySelector('html');
html.classList.remove('{{ default_theme }}')
@ -98,7 +101,7 @@
var sidebar = null;
var sidebar_toggle = document.getElementById("sidebar-toggle-anchor");
if (document.body.clientWidth >= 1080) {
try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch (e) { }
sidebar = sidebar || 'visible';
} else {
sidebar = 'hidden';
@ -120,7 +123,7 @@
<!-- Track and set sidebar scroll position -->
<script>
var sidebarScrollbox = document.querySelector('#sidebar .sidebar-scrollbox');
sidebarScrollbox.addEventListener('click', function(e) {
sidebarScrollbox.addEventListener('click', function (e) {
if (e.target.tagName === 'A') {
sessionStorage.setItem('sidebar-scroll', sidebarScrollbox.scrollTop);
}
@ -146,10 +149,14 @@
<div id="menu-bar-hover-placeholder"></div>
<div id="menu-bar" class="menu-bar sticky">
<div class="left-buttons">
<label id="sidebar-toggle" class="icon-button" for="sidebar-toggle-anchor" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
<label id="sidebar-toggle" class="icon-button" for="sidebar-toggle-anchor"
title="Toggle Table of Contents" aria-label="Toggle Table of Contents"
aria-controls="sidebar">
<i class="fa fa-bars"></i>
</label>
<button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
<button id="theme-toggle" class="icon-button" type="button" title="Change theme"
aria-label="Change theme" aria-haspopup="true" aria-expanded="false"
aria-controls="theme-list">
<i class="fa fa-paint-brush"></i>
</button>
<ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
@ -160,7 +167,9 @@
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
</ul>
{{#if search_enabled}}
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)"
aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S"
aria-controls="searchbar">
<i class="fa fa-search"></i>
</button>
{{/if}}
@ -191,7 +200,8 @@
{{#if search_enabled}}
<div id="search-wrapper" class="hidden">
<form id="searchbar-outer" class="searchbar-outer">
<input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
<input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..."
aria-controls="searchresults-outer" aria-describedby="searchresults-header">
</form>
<div id="searchresults-outer" class="searchresults-outer hidden">
<div id="searchresults-header" class="searchresults-header"></div>
@ -205,14 +215,16 @@
<script>
document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
Array.from(document.querySelectorAll('#sidebar a')).forEach(function (link) {
link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
});
</script>
<div id="content" class="content">
<!-- Page table of contents -->
<div class="sidetoc"><nav class="pagetoc"></nav></div>
<div class="sidetoc">
<nav class="pagetoc"></nav>
</div>
<main>
{{{ content }}}
<div id="giscus-container"></div>
@ -221,15 +233,17 @@
<nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons -->
{{#previous}}
<a rel="prev" href="{{ path_to_root }}{{link}}" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a rel="prev" href="{{ path_to_root }}{{link}}" class="mobile-nav-chapters previous"
title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
{{/previous}}
{{#next}}
<a rel="next prefetch" href="{{ path_to_root }}{{link}}" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
<a rel="next prefetch" href="{{ path_to_root }}{{link}}" class="mobile-nav-chapters next"
title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
{{/next}}
<div style="clear: both"></div>
@ -239,15 +253,17 @@
<nav class="nav-wide-wrapper" aria-label="Page navigation">
{{#previous}}
<a rel="prev" href="{{ path_to_root }}{{link}}" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a rel="prev" href="{{ path_to_root }}{{link}}" class="nav-chapters previous" title="Previous chapter"
aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
{{/previous}}
{{#next}}
<a rel="next prefetch" href="{{ path_to_root }}{{link}}" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
<a rel="next prefetch" href="{{ path_to_root }}{{link}}" class="nav-chapters next" title="Next chapter"
aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
{{/next}}
</nav>
@ -266,7 +282,7 @@
}
};
window.onbeforeunload = function() {
window.onbeforeunload = function () {
socket.close();
}
</script>
@ -280,10 +296,12 @@
// make sure we don't activate google analytics if the developer is
// inspecting the book locally...
if (localAddrs.indexOf(document.location.hostname) === -1) {
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
(function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function () {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date(); a = s.createElement(o),
m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m)
})(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga');
ga('create', '{{google_analytics}}', 'auto');
ga('send', 'pageview');
@ -322,7 +340,7 @@
<script src="{{ path_to_root }}book.js"></script>
<script type="text/javascript" charset="utf-8">
var pagePath = "{{ path }}"
var pagePath = "{{ path }}"
</script>
@ -334,21 +352,22 @@
{{#if is_print}}
{{#if mathjax_support}}
<script>
window.addEventListener('load', function() {
MathJax.Hub.Register.StartupHook('End', function() {
window.setTimeout(window.print, 100);
window.addEventListener('load', function () {
MathJax.Hub.Register.StartupHook('End', function () {
window.setTimeout(window.print, 100);
});
});
});
</script>
{{else}}
<script>
window.addEventListener('load', function() {
window.setTimeout(window.print, 100);
});
window.addEventListener('load', function () {
window.setTimeout(window.print, 100);
});
</script>
{{/if}}
{{/if}}
</div>
</body>
</body>
</html>