Skip to content

Commit a6c57b0

Browse files
authored
fixing some css bugs (jupyter-book#188)
fixing some css bugs
2 parents cbc512d + 81d9be6 commit a6c57b0

File tree

7 files changed

+76
-45
lines changed

7 files changed

+76
-45
lines changed

jupyter_book/book_template/_sass/components/_components.textbook__page.scss

+9-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ div.highlighter-rouge {
4343
position: relative;
4444
}
4545

46-
div.c-textbook__content > div.highlighter-rouge > div.highlight pre, div.input_area > div.highlighter-rouge > div.highlight > pre, div.output_wrapper pre {
46+
div.c-textbook__content > div.highlighter-rouge > div.highlight pre,
47+
div.input_area > div.highlighter-rouge > div.highlight > pre,
48+
div.output_wrapper pre {
4749
background-color: $color-light-gray;
4850
font-size: 0.9em;
4951
margin-bottom: $spacing-unit-small;
@@ -52,6 +54,11 @@ div.c-textbook__content > div.highlighter-rouge > div.highlight pre, div.input_a
5254
border: 1px solid $color-dark-gray;
5355
}
5456

57+
// If we've got intentionally non-highlighted markup, make sure that the lines wrap
58+
pre code.language-no-highlight {
59+
white-space: pre-wrap;
60+
}
61+
5562
div.output_wrapper pre {
5663
border: 1px solid $color-light-gray !important;
5764
background-color: #fcfcfc !important;
@@ -65,7 +72,7 @@ div.output_wrapper pre {
6572
/* [5] */
6673
code {
6774
padding: 4px;
68-
white-space: pre-wrap;
75+
overflow-x: auto;
6976
@include inuit-font-size(14px);
7077
}
7178

jupyter_book/book_template/_sass/components/_components.textbook__sidebar-right.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ $right-sidebar-center-offset: ($page-max-width - $sidebar-width) / 2 -
2222

2323
.sidebar__right {
2424
display: none;
25+
overflow-x: hidden;
2526
@include mq($from: desktop) {
2627
display: block;
2728
width: $right-sidebar-width;
@@ -34,7 +35,6 @@ $right-sidebar-center-offset: ($page-max-width - $sidebar-width) / 2 -
3435
max-height: 90%; // Required for scrolling to work properly
3536
scrollbar-width: thin;
3637
direction: rtl;
37-
3838
z-index: 1; // Keep sidebar on top of page content
3939
}
4040

jupyter_book/book_template/content/features/limits.md

+45-39
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
# Push Features to the Limit
1+
# Demo page to showcase markdown
2+
3+
# NOTE: None of the information on this page applies to Jupyter Books.
4+
5+
It is taken from the Markdown
6+
documentation, and is meant to give an idea of how Jupyter Book renders really long pages of
7+
very diverse content!
28

39
## Amount of Content
410

@@ -17,20 +23,20 @@ You can play around with Markdown on our [live demo page](http://www.markdown-he
1723

1824
(If you're not a Markdown Here user, check out the [Markdown Cheatsheet](./Markdown-Cheatsheet) that is not specific to MDH. But, really, you should also use Markdown Here, because it's awesome. http://markdown-here.com)
1925

20-
##### Table of Contents
21-
[Headers](#headers)
22-
[Emphasis](#emphasis)
23-
[Lists](#lists)
24-
[Links](#links)
25-
[Images](#images)
26-
[Code and Syntax Highlighting](#code)
27-
[Tables](#tables)
28-
[Blockquotes](#blockquotes)
29-
[Inline HTML](#html)
30-
[Horizontal Rule](#hr)
31-
[Line Breaks](#lines)
32-
[YouTube Videos](#videos)
33-
[TeX Mathematical Formulae](#tex)
26+
##### Table of Contents
27+
[Headers](#headers)
28+
[Emphasis](#emphasis)
29+
[Lists](#lists)
30+
[Links](#links)
31+
[Images](#images)
32+
[Code and Syntax Highlighting](#code)
33+
[Tables](#tables)
34+
[Blockquotes](#blockquotes)
35+
[Inline HTML](#html)
36+
[Horizontal Rule](#hr)
37+
[Line Breaks](#lines)
38+
[YouTube Videos](#videos)
39+
[TeX Mathematical Formulae](#tex)
3440

3541
<a name="headers"/>
3642

@@ -98,11 +104,11 @@ Strikethrough uses two tildes. ~~Scratch this.~~
98104
```no-highlight
99105
1. First ordered list item
100106
2. Another item
101-
* Unordered sub-list.
107+
* Unordered sub-list.
102108
1. Actual numbers don't matter, just that it's a number
103109
1. Ordered sub-list
104-
4. And another item.
105-
110+
4. And another item.
111+
106112
Some text that should be aligned with the above item.
107113
108114
* Unordered list can use asterisks
@@ -112,11 +118,11 @@ Strikethrough uses two tildes. ~~Scratch this.~~
112118

113119
1. First ordered list item
114120
2. Another item
115-
* Unordered sub-list.
121+
* Unordered sub-list.
116122
1. Actual numbers don't matter, just that it's a number
117123
1. Ordered sub-list
118-
4. And another item.
119-
124+
4. And another item.
125+
120126
Some text that should be aligned with the above item.
121127

122128
* Unordered list can use asterisks
@@ -138,8 +144,8 @@ There are two ways to create links.
138144
139145
Or leave it empty and use the [link text itself]
140146
141-
URLs and URLs in angle brackets will automatically get turned into links.
142-
http://www.example.com or <http://www.example.com> and sometimes
147+
URLs and URLs in angle brackets will automatically get turned into links.
148+
http://www.example.com or <http://www.example.com> and sometimes
143149
example.com (but not on Github, for example).
144150
145151
Some text to show that the reference links can follow later.
@@ -157,8 +163,8 @@ Some text to show that the reference links can follow later.
157163

158164
Or leave it empty and use the [link text itself]
159165

160-
URLs and URLs in angle brackets will automatically get turned into links.
161-
http://www.example.com or <http://www.example.com> and sometimes
166+
URLs and URLs in angle brackets will automatically get turned into links.
167+
http://www.example.com or <http://www.example.com> and sometimes
162168
example.com (but not on Github, for example).
163169

164170
Some text to show that the reference links can follow later.
@@ -174,21 +180,21 @@ Some text to show that the reference links can follow later.
174180
```no-highlight
175181
Here's our logo (hover to see the title text):
176182
177-
Inline-style:
183+
Inline-style:
178184
![alt text](https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png "Logo Title Text 1")
179185
180-
Reference-style:
186+
Reference-style:
181187
![alt text][logo]
182188
183189
[logo]: https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png "Logo Title Text 2"
184190
```
185191

186192
Here's our logo (hover to see the title text):
187193

188-
Inline-style:
194+
Inline-style:
189195
![alt text](https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png "Logo Title Text 1")
190196

191-
Reference-style:
197+
Reference-style:
192198
![alt text][logo]
193199

194200
[logo]: https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png "Logo Title Text 2"
@@ -211,14 +217,14 @@ Blocks of code are either fenced by lines with three back-ticks <code>```</code>
211217
var s = "JavaScript syntax highlighting";
212218
alert(s);
213219
```
214-
220+
215221
```python
216222
s = "Python syntax highlighting"
217223
print s
218224
```
219-
225+
220226
```
221-
No language indicated, so no syntax highlighting.
227+
No language indicated, so no syntax highlighting.
222228
But let's throw in a &lt;b&gt;tag&lt;/b&gt;.
223229
```
224230
</code></pre>
@@ -236,7 +242,7 @@ print s
236242
```
237243

238244
```
239-
No language indicated, so no syntax highlighting in Markdown Here (varies on Github).
245+
No language indicated, so no syntax highlighting in Markdown Here (varies on Github).
240246
But let's throw in a <b>tag</b>.
241247
```
242248

@@ -290,21 +296,21 @@ Markdown | Less | Pretty
290296
291297
Quote break.
292298
293-
> This is a very long line that will still be quoted properly when it wraps. Oh boy let's keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can *put* **Markdown** into a blockquote.
299+
> This is a very long line that will still be quoted properly when it wraps. Oh boy let's keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can *put* **Markdown** into a blockquote.
294300
```
295301

296302
> Blockquotes are very handy in email to emulate reply text.
297303
> This line is part of the same quote.
298304
299305
Quote break.
300306

301-
> This is a very long line that will still be quoted properly when it wraps. Oh boy let's keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can *put* **Markdown** into a blockquote.
307+
> This is a very long line that will still be quoted properly when it wraps. Oh boy let's keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can *put* **Markdown** into a blockquote.
302308
303309
<a name="html"/>
304310

305311
## Inline HTML
306312

307-
You can also use raw HTML in your Markdown, and it'll mostly work pretty well.
313+
You can also use raw HTML in your Markdown, and it'll mostly work pretty well.
308314

309315
```no-highlight
310316
<dl>
@@ -362,7 +368,7 @@ Underscores
362368

363369
## Line Breaks
364370

365-
My basic recommendation for learning how line breaks work is to experiment and discover -- hit &lt;Enter&gt; once (i.e., insert one newline), then hit it twice (i.e., insert two newlines), see what happens. You'll soon learn to get what you want. "Markdown Toggle" is your friend.
371+
My basic recommendation for learning how line breaks work is to experiment and discover -- hit &lt;Enter&gt; once (i.e., insert one newline), then hit it twice (i.e., insert two newlines), see what happens. You'll soon learn to get what you want. "Markdown Toggle" is your friend.
366372

367373
Here are some things to try out:
368374

@@ -379,7 +385,7 @@ Here's a line for us to start with.
379385

380386
This line is separated from the one above by two newlines, so it will be a *separate paragraph*.
381387

382-
This line is also begins a separate paragraph, but...
388+
This line is also begins a separate paragraph, but...
383389
This line is only separated by a single newline, so it's a separate line in the *same paragraph*.
384390

385391
(Technical note: *Markdown Here* uses GFM line breaks, so there's no need to use MD's two-space line breaks.)
@@ -392,7 +398,7 @@ They can't be added directly but you can add an image with a link to the video l
392398

393399
```no-highlight
394400
<a href="http://www.youtube.com/watch?feature=player_embedded&v=YOUTUBE_VIDEO_ID_HERE
395-
" target="_blank"><img src="http://img.youtube.com/vi/YOUTUBE_VIDEO_ID_HERE/0.jpg"
401+
" target="_blank"><img src="http://img.youtube.com/vi/YOUTUBE_VIDEO_ID_HERE/0.jpg"
396402
alt="IMAGE ALT TEXT HERE" width="240" height="180" border="10" /></a>
397403
```
398404

jupyter_book/book_template/content/features/markdown.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,15 @@ The two kinds of files that contain course content are:
88
Each are contained in the `content/` folder and referenced from `_data/toc.yml`.
99

1010
If the file is markdown, it will be copied over with front-matter YAML added so
11-
that Jekyll can parse it
11+
that Jekyll can parse it.
12+
13+
```python
14+
print("Python (and any language-specific) code still works as expected")
15+
```
16+
17+
```
18+
As does non-language code.
19+
```
1220

1321
## Sidebars with Jekyll
1422

jupyter_book/build.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -198,15 +198,19 @@ def build_book(path_book, path_toc_yaml=None, config_file=None,
198198
else:
199199
prev_file_title = toc[ix_file - 1].get('title')
200200
url_prev_page = toc[ix_file - 1].get('url')
201-
url_prev_page = _prepare_url(url_prev_page)
201+
pre_external = toc[ix_file - 1].get('external', False)
202+
if pre_external is False:
203+
url_prev_page = _prepare_url(url_prev_page)
202204

203205
if ix_file == len(toc) - 1:
204206
url_next_page = ''
205207
next_file_title = ''
206208
else:
207209
next_file_title = toc[ix_file + 1].get('title')
208210
url_next_page = toc[ix_file + 1].get('url')
209-
url_next_page = _prepare_url(url_next_page)
211+
next_external = toc[ix_file + 1].get('external', False)
212+
if next_external is False:
213+
url_next_page = _prepare_url(url_next_page)
210214

211215
###############################################################################
212216
# Get kernel name and presence of widgets from notebooks metadata

jupyter_book/tests/site/_data/toc.yml

+3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
- title: Jupyter notebooks
2929
url: /tests/notebooks
3030
not_numbered: true
31+
- title: Test external
32+
url: https://github.com
33+
external: true
3134
- title: Interactive test
3235
url: /tests/interactive
3336
not_numbered: true

jupyter_book/tests/test_create.py

+3
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,9 @@ def test_notebook(tmpdir):
218218
# No interactive outputs
219219
assert is_in(lines, "has_widgets: false")
220220

221+
# Testing external link
222+
assert is_in(lines, "url: https://github.com")
223+
221224
###########################################
222225
# Testing interactive features
223226

0 commit comments

Comments
 (0)