File size: 1,793 Bytes
745e7ed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
Ruler
=====

This extension enables the Ruler CodeMirror feature


Configuration
-------------

You can set the number of characters in the notebook extensions configration page or use the ConfigManager:

```Python
from IPython.html.services.config import ConfigManager
ip = get_ipython()
cm = ConfigManager(parent=ip)
cm.update('notebook', {"ruler_column": [80]})
```


#### CSS patch ####

Notebook versions from 4.3.0 through 5.1.0dev show up a bug in their CodeMirror
CSS padding which causes the ruler to be misplaced (see
[jupyter/notebook#2869](https://github.com/jupyter/notebook/issues/2869)
for details).
This nbextension introduces a css patch to attempt to correct this, but if it
causes problems for you, you can disable it by setting the `ruler_do_css_patch`
config key to `false`.


#### Multiple Rulers ####

To specify multiple rulers, set the `ruler_column` to a list of values, for example

```Python
cm.update('notebook', {"ruler_column": [10, 20, 30, 40, 50, 60, 70, 80]})
```

A separate color and style can be specified for each ruler.

```Python
cm.update('notebook', {"color": ["#000000", "#111111", "#222222", "#333333", "#444444",
                                 "#555555", "#666666", "#777777", "#888888", "#999999"]})
```

Creating a repeating pattern for either color or style is as simple as giving a list shorter than the total number of rulers

```Python
cm.update('notebook', {"ruler_column": [10, 20, 30, 40, 50, 60, 70, 80]})
cm.update('notebook', {"color": ["#FF0000", "#00FF00", "#0000FF"]})
cm.update('notebook', {"style": ["dashed", "dotted"]})
```

will result in `red, green, blue, red, green, blue, red, green, blue, red` and alternating `dashed, dotted`

See [here](https://www.w3schools.com/cssref/pr_border-left_style.asp) for other line styles.