test.leo: semi-official tests
@settings
@data unl-path-prefixes
@data history-list
@button copy-test
Latex buttons
@@button Create LaTeX
@@clean c:\test\latex_test.tex
level 1
level 2
Viewrendered examples
Python code
@graphics-script
@html display Leo tree (cool)
@html Leo's home page
@image LeoSplash
@image splash screen
@movie Gayane Ballet (Local file)
@movie Gayane Ballet (Url)
@movie Sample video (Local file)
@movie Sample video (Url)
@networkx my network
@pyplot matplotlib animate_decay
data_gen
init
run
@pyplot basic_example
Figure 1
Figure 2
@pyplot barchar_demo
@svg bubbles sources
@svg bubbles.svg
@url Leo's home page (md default)
@url Leo's home page (md explicit)
@url Leo's home page (rST default)
@url Leo's home page (rST explicit)
@url weather (md default)
@url weather (rst default)
docstring test
markdown test (including url)
rst test (including url)
Recent tests
@jupyter
Coloring tests
Syntax coloring template
g.es test
g.error/note/warning test
test of parse-body
test of tree abbreviations
script: diff-branches/revs (one file)
pyscript code (requires VR3)
--- nodes with various kinds of gnx
test ksuid
test uuid
test legacy gnx
script: change body font
script: unchange body font
--- colorizing
colorizer test
<< defined section >>
html/js test
html/js test
javascript test
test of @language json
test of @language md
test of @language python
<< exists >>
test of @language rest
script: asttokens
QToolBar test
--- tests of UNL (do not delete!)
@file ../plugins/importers/__init__.py
@clean ../plugins/leo_babel/__init__.py
Error messages (copy to log)
Legacy UNLs: in this file
Legacy UNLs: other files
URLs and UNLs:
New UNLs with empty file parts
New UNLs with short file parts
New UNLs with relative file parts
New UNLS with long(absolute) file parts
file:///c:/Test/04_Neural_Networks.ipynb
@language python
@ doc part (colored as **markdown**)
@c
def spam():
'''Docstring'''
# Comment.
a = 'Regular string'
@language python
"""
Changes LaTeX section definition levels in the subtree of an @clean file node to their subtree level.
Only one LaTeX section level can therefore be used within a single node body.
"""
import re
section_levels = {
1: 'chapter',
2: 'section',
3: 'subsection',
4: 'subsubsection',
5: 'paragraph',
6: 'subparagraph'
}
def latex_convert_section_levels(p, adjusted_level_name):
""" Replaces LaTeX section definition levels found on a single line (re multiline mode).
Returns the modified node body."""
return re.sub(r'\\(chapter|section|subsection|subsubsection|paragraph|subparagraph)(\[.*?\])?({.*})',
r'\\'+adjusted_level_name+r'\g<2>\g<3>', p.b, re.M)
u, undoType = c.undoer, 'change-latex'
h = p.h.strip()
if g.match_word(h, 0, '@clean') and h.endswith('.tex'):
bunch = u.beforeChangeTree(c.p)
changed, dirtyVnodeList = 0, []
root_level = p.level()
for p in p.subtree():
level = p.level() - root_level
if level < 7:
level_name = section_levels[level]
else:
level_name = 'subparagraph'
s = latex_convert_section_levels(p, level_name)
if s != p.b:
bunch2 = u.beforeChangeNodeContents(p)
p.b = s
u.afterChangeNodeContents(p, undoType, bunch2, dirtyVnodeList=dirtyVnodeList)
p.v.setDirty()
changed += 1
if changed:
u.afterChangeTree(c.p, undoType, bunch)
g.es('Changed %s node%s.' % (changed, g.plural(changed)))
else:
g.es('No nodes changed')
else:
g.es('not a LaTeX file node?')
@language tex
@others
\paragraph{one}
\paragraph{two}
table = (
# g.actualColor calls
'error', 'info', 'warning',
'black', 'white',
'xxx',
'firebrick', 'grey', 'pink', 'purple', # Tk colors.
# Solarized colors...
'blue', 'cyan', 'green','magenta', 'orange', 'red',
'violet', 'yellow',
)
for s in table:
g.es(s, color=s)
# g.cls()
g.error('error')
g.note('note')
g.warning('warning')
g.blue('blue')
g.red('red')
g.es_print('test')
g.es_print('black',color='black')
C:\Users\edreamleo\SampleVideo_1280x720_1mb.mp4
http://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_1mb.mp4
# This *does* play.
# http://matplotlib.org/1.5.1/examples/animation/animate_decay.html
np = matplotlib = None
try:
import numpy as np
except Exception:
g.es_print('Can not import numpy')
try:
import matplotlib.pyplot as plt
import matplotlib.animation as animation
except Exception:
g.es_print('Can not import matplotlib')
@others
# global data.
if np and matplotlib:
fig, ax = plt.subplots()
line, = ax.plot([], [], lw=2)
ax.grid()
xdata, ydata = [], []
ani = animation.FuncAnimation(
fig, run, data_gen, blit=False, interval=10,
repeat=False, init_func=init)
plt.ion()
# sets interactive mode. Prevents this message:
# QCoreApplication::exec: The event loop is already running
plt.show()
def data_gen(t=0):
cnt = 0
while cnt < 1000:
cnt += 1
t += 0.1
yield t, np.sin(2*np.pi*t) * np.exp(-t/10.)
def init():
ax.set_ylim(-1.1, 1.1)
ax.set_xlim(0, 10)
del xdata[:]
del ydata[:]
line.set_data(xdata, ydata)
return line,
def run(data):
# update the data
t, y = data
xdata.append(t)
ydata.append(y)
xmin, xmax = ax.get_xlim()
if t >= xmax:
ax.set_xlim(xmin, 2*xmax)
ax.figure.canvas.draw()
line.set_data(xdata, ydata)
return line,
# http://matplotlib.org/1.5.1/examples/animation/basic_example.html
if 0:
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
@others
if 0:
plt.ion()
# sets interactive mode. Prevents this message:
# QCoreApplication::exec: The event loop is already running
plt.show()
if 1:
def update_line(num, data, line):
line.set_data(data[..., :num])
return line, # a tuple.
fig1 = plt.figure()
data = np.random.rand(2, 25)
l, = plt.plot([], [], 'r-')
plt.xlim(0, 1)
plt.ylim(0, 1)
plt.xlabel('x')
plt.title('test')
line_ani = animation.FuncAnimation(fig1, update_line, 25,
fargs=(data, l),
interval=50,
blit=True)
fig2 = plt.figure()
x = np.arange(-9, 10)
y = np.arange(-9, 10).reshape(-1, 1)
base = np.hypot(x, y)
ims = []
for add in np.arange(15):
ims.append((plt.pcolor(x, y, base + add, norm=plt.Normalize(0, 30)),))
animation.ArtistAnimation(fig2, ims,
interval=50,
repeat_delay=3000,
blit=True)
#im_ani.save('im.mp4', metadata={'artist':'Guido'})
@language python
def spam():
'''This is a docstring.'''
pass
#!/usr/bin/env python
# a bar plot with errorbars
import numpy as np
import matplotlib.pyplot as plt
N = 5
menMeans = (20, 35, 30, 35, 27)
menStd = (2, 3, 4, 1, 2)
ind = np.arange(N) # the x locations for the groups
width = 0.35 # the width of the bars
fig, ax = plt.subplots()
rects1 = ax.bar(ind, menMeans, width, color='r', yerr=menStd)
womenMeans = (25, 32, 34, 20, 25)
womenStd = (3, 5, 2, 3, 3)
rects2 = ax.bar(ind + width, womenMeans, width, color='y', yerr=womenStd)
# add some text for labels, title and axes ticks
ax.set_ylabel('Scores')
ax.set_title('Scores by group and gender')
ax.set_xticks(ind + width)
ax.set_xticklabels(('G1', 'G2', 'G3', 'G4', 'G5'))
ax.legend((rects1[0], rects2[0]), ('Men', 'Women'))
def autolabel(rects):
# attach some text labels
for rect in rects:
height = rect.get_height()
ax.text(rect.get_x() + rect.get_width()/2., 1.05*height,
'%d' % int(height),
ha='center', va='bottom')
autolabel(rects1)
autolabel(rects2)
plt.ion()
# sets interactive mode. Prevents this message:
# QCoreApplication::exec: The event loop is already running
plt.show()
@nocolor-node
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg width="20cm" height="15cm" viewBox="0 0 800 600"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlik/"
baseProfile="tiny" version="1.2">
<title>Spheres</title>
<desc>Semi-transparent bubbles on a colored background.</desc>
<defs>
<!-- Create radial gradients for each bubble. -->
<radialGradient id="blueBubble" gradientUnits="userSpaceOnUse"
cx="0" cy="0" r="100" fx="-50" fy="-50">
<stop offset="0%" stop-color="white" stop-opacity="1" />
<stop offset="25%" stop-color="#cdcdff" stop-opacity=".65" />
<stop offset="100%" stop-color="#cdaacd" stop-opacity=".75" />
</radialGradient>
<radialGradient id="redBubble" gradientUnits="userSpaceOnUse"
cx="0" cy="0" r="100" fx="-50" fy="-50">
<stop offset="0%" stop-color="white" stop-opacity="1" />
<stop offset="25%" stop-color="#ffcdcd" stop-opacity=".65" />
<stop offset="100%" stop-color="#bbbb99" stop-opacity=".75" />
</radialGradient>
<radialGradient id="greenBubble" gradientUnits="userSpaceOnUse"
cx="0" cy="0" r="100" fx="-50" fy="-50">
<stop offset="0%" stop-color="white" stop-opacity="1" />
<stop offset="25%" stop-color="#cdffcd" stop-opacity=".65" />
<stop offset="100%" stop-color="#99aaaa" stop-opacity=".75" />
</radialGradient>
<radialGradient id="yellowBubble" gradientUnits="userSpaceOnUse"
cx="0" cy="0" r="100" fx="-50" fy="-50">
<stop offset="0%" stop-color="white" stop-opacity="1" />
<stop offset="25%" stop-color="#ffffcd" stop-opacity=".65" />
<stop offset="100%" stop-color="#bbbbaa" stop-opacity=".75" />
</radialGradient>
<radialGradient id="background" gradientUnits="userSpaceOnUse"
cx="0" cy="0" r="400" fx="250" fy="250">
<stop offset="0%" stop-color="#ffffee" />
<stop offset="100%" stop-color="#ccccaa" />
</radialGradient>
<linearGradient id="surface" gradientUnits="userSpaceOnUse"
x1="-100" y1="200" x2="400" y2="200">
<stop offset="0%" stop-color="#ffffcc" />
<stop offset="100%" stop-color="#bbbb88" />
</linearGradient>
<!-- Create radial gradients for each circle to make them look like
spheres. -->
<radialGradient id="blueSphere" gradientUnits="userSpaceOnUse"
cx="0" cy="0" r="100" fx="-50" fy="-50">
<stop offset="0%" stop-color="white" />
<stop offset="75%" stop-color="blue" />
<stop offset="100%" stop-color="#222244" />
</radialGradient>
<radialGradient id="redSphere" gradientUnits="userSpaceOnUse"
cx="0" cy="0" r="100" fx="-50" fy="-50">
<stop offset="0%" stop-color="white" />
<stop offset="75%" stop-color="red" />
<stop offset="100%" stop-color="#442222" />
</radialGradient>
<radialGradient id="greenSphere" gradientUnits="userSpaceOnUse"
cx="0" cy="0" r="100" fx="-50" fy="-50">
<stop offset="0%" stop-color="white" />
<stop offset="75%" stop-color="green" />
<stop offset="100%" stop-color="#113311" />
</radialGradient>
<radialGradient id="yellowSphere" gradientUnits="userSpaceOnUse"
cx="0" cy="0" r="100" fx="-50" fy="-50">
<stop offset="0%" stop-color="white" />
<stop offset="75%" stop-color="yellow" />
<stop offset="100%" stop-color="#444422" />
</radialGradient>
<radialGradient id="shadowGrad" gradientUnits="userSpaceOnUse"
cx="0" cy="0" r="100" fx="-50" fy="50">
<stop offset="0%" stop-color="black" stop-opacity="1.0" />
<stop offset="100%" stop-color="black" stop-opacity="0.0" />
</radialGradient>
<!-- Define a shadow for each sphere. -->
<circle id="shadow" fill="url(#shadowGrad)" cx="0" cy="0" r="100" />
<g id="bubble">
<circle fill="black" cx="0" cy="0" r="50" />
<circle fill="#a6ce39" cx="0" cy="0" r="33" />
<path fill="black" d="M 37,50 L 50,37 L 12,-1 L 22,-11 L 10,-24 L -24,10
L -11,22 L -1,12 Z" />
<circle cx="0" cy="0" r="100" />
</g>
</defs>
<g>
<rect fill="url(#background)" x="0" y="0" width="800" height="600" />
</g>
<g transform="translate(200,700)">
<use xlink:href="#bubble" fill="url(#blueBubble)" />
<animateTransform attributeName="transform" type="translate" additive="sum"
values="0,0; 0,-800" begin="1s" dur="10s" fill="freeze" repeatCount="indefinite" />
</g>
<g transform="translate(315,700)">
<g transform="scale(0.5,0.5)">
<use xlink:href="#bubble" fill="url(#redBubble)" />
</g>
<animateTransform attributeName="transform" type="translate" additive="sum"
values="0,0; 0,-800" begin="3s" dur="7s" fill="freeze" repeatCount="indefinite" />
</g>
<g transform="translate(80,700)">
<g transform="scale(0.65,0.65)">
<use xlink:href="#bubble" fill="url(#greenBubble)" />
</g>
<animateTransform attributeName="transform" type="translate" additive="sum"
values="0,0; 0,-800" begin="5s" dur="9s" fill="freeze" repeatCount="indefinite" />
</g>
<g transform="translate(255,700)">
<g transform="scale(0.3,0.3)">
<use xlink:href="#bubble" fill="url(#yellowBubble)" />
</g>
<animateTransform attributeName="transform" type="translate" additive="sum"
values="0,0; 0,-800" begin="2s" dur="6s" fill="freeze" repeatCount="indefinite" />
</g>
<g transform="translate(565,700)">
<g transform="scale(0.4,0.4)">
<use xlink:href="#bubble" fill="url(#blueBubble)" />
</g>
<animateTransform attributeName="transform" type="translate" additive="sum"
values="0,0; 0,-800" begin="4s" dur="8s" fill="freeze" repeatCount="indefinite" />
</g>
<g transform="translate(715,700)">
<g transform="scale(0.6,0.6)">
<use xlink:href="#bubble" fill="url(#redBubble)" />
</g>
<animateTransform attributeName="transform" type="translate" additive="sum"
values="0,0; 0,-800" begin="1s" dur="4s" fill="freeze" repeatCount="indefinite" />
</g>
<g transform="translate(645,700)">
<g transform="scale(0.375,0.375)">
<use xlink:href="#bubble" fill="url(#greenBubble)" />
</g>
<animateTransform attributeName="transform" type="translate" additive="sum"
values="0,0; 0,-800" begin="0s" dur="11s" fill="freeze" repeatCount="indefinite" />
</g>
<g transform="translate(555,700)">
<g transform="scale(0.9,0.9)">
<use xlink:href="#bubble" fill="url(#yellowBubble)" />
</g>
<animateTransform attributeName="transform" type="translate" additive="sum"
values="0,0; 0,-800" begin="3s" dur="7.5s" fill="freeze" repeatCount="indefinite" />
</g>
<g transform="translate(360,700)">
<g transform="scale(0.5,0.5)">
<use xlink:href="#bubble" fill="url(#blueBubble)" />
</g>
<animateTransform attributeName="transform" type="translate" additive="sum"
values="0,0; 0,-800" begin="3s" dur="6s" fill="freeze" repeatCount="indefinite" />
</g>
<g transform="translate(215,700)">
<g transform="scale(0.45,0.45)">
<use xlink:href="#bubble" fill="url(#redBubble)" />
</g>
<animateTransform attributeName="transform" type="translate" additive="sum"
values="0,0; 0,-800" begin="5.5s" dur="7s" fill="freeze" repeatCount="indefinite" />
</g>
<g transform="translate(420,700)">
<g transform="scale(0.75,0.75)">
<use xlink:href="#bubble" fill="url(#greenBubble)" />
</g>
<animateTransform attributeName="transform" type="translate" additive="sum"
values="0,0; 0,-800" begin="1s" dur="9s" fill="freeze" repeatCount="indefinite" />
</g>
<g transform="translate(815,700)">
<g transform="scale(0.6,0.6)">
<use xlink:href="#bubble" fill="url(#yellowBubble)" />
</g>
<animateTransform attributeName="transform" type="translate" additive="sum"
values="0,0; 0,-800" begin="2s" dur="9.5s" fill="freeze" repeatCount="indefinite" />
</g>
<g transform="translate(225,375)" >
<g transform="scale(1.0,0.5)" >
<path d="M 0 0 L 350 0 L 450 450 L -100 450 z"
fill="url(#surface)" stroke="none" />
</g>
</g>
<g transform="translate(200,0)" >
<g transform="translate(200,490) scale(2.0,1.0) rotate(45)" >
<rect fill="#a6ce39" x="-69" y="-69" width="138" height="138" />
<circle fill="black" cx="0" cy="0" r="50" />
<circle fill="#a6ce39" cx="0" cy="0" r="33" />
<path fill="black" d="M 37,50 L 50,37 L 12,-1 L 22,-11 L 10,-24 L -24,10
L -11,22 L -1,12 Z" />
<animateTransform attributeName="transform" type="rotate" additive="sum" values="0; 360"
begin="0s" dur="10s" fill="freeze" repeatCount="indefinite" />
</g>
<g transform="translate(200,375)">
<use xlink:href="#shadow" transform="translate(25,55) scale(1.0,0.5)" />
<circle fill="url(#blueSphere)" cx="0" cy="0" r="100" />
</g>
<g transform="translate(315,440)">
<g transform="scale(0.5,0.5)">
<use xlink:href="#shadow" transform="translate(25,55) scale(1.0,0.5)" />
<circle fill="url(#redSphere)" cx="0" cy="0" r="100" />
</g>
</g>
<g transform="translate(80,475)">
<g transform="scale(0.65,0.65)">
<use xlink:href="#shadow" transform="translate(25,55) scale(1.0,0.5)" />
<circle fill="url(#greenSphere)" cx="0" cy="0" r="100" />
</g>
</g>
<g transform="translate(255,525)">
<g transform="scale(0.3,0.3)">
<use xlink:href="#shadow" transform="translate(25,55) scale(1.0,0.5)" />
<circle fill="url(#yellowSphere)" cx="0" cy="0" r="100" />
</g>
</g>
</g>
</svg>
c:\leo.repo\leo-editor\leo\Icons\bubbles.svg
[Leo's home page](http://leoeditor.com/)
@language md
@wrap
[Leo's home page](http://leoeditor.com/)
`Leo's home page <http://leoeditor.com/>`_
@language rest
@wrap
`Leo's home page <http://leoeditor.com/>`_
[weather.com](http://www.weather.com/weather/today/Madison+WI+53705?from=hp_promolocator&lswe=53705&lwsa=Weather36HourHealthCommand)
`weather.com <http://www.weather.com/weather/today/Madison+WI+53705?from=hp_promolocator&lswe=53705&lwsa=Weather36HourHealthCommand>`_
@language rest
@wrap
''' Creates a window for *live* rendering of rst, html, etc. (Qt only).
Commands
========
viewrendered.py creates the following (``Alt-X``) commands:
``viewrendered``
opens a new window where the current body text is rendered as HTML
(if it starts with '<'), or otherwise reStructuredText.
``viewrendered-big``
as above, but zoomed in, useful for presentations
``viewrendered-html``
displays the html source generated from reStructuredText, useful for
debugging
``viewrendered`` sets the process current directory (os.chdir()) to the path
to the node being rendered, to allow relative paths to work in
``.. image::`` directives.
reStructuredText errors and warnings may be shown. For example, both::
Heading
-------
`This` is **really** a line of text.
and::
<h1>Heading<h1>
<tt>This</tt> is <b>really</b> a line of text.
will look something like:
**Heading**
`This` is **really** a line of text.
Settings
========
@string view-rendered-default-kind = rst
----------------------------------------
The default kind of rendering. One of (big,rst,html)
@bool view-rendered-auto-create = False
---------------------------------------
When True, the plugin will create a rendering pane automatically.
'''
gs.clear()
gs.addText('\n%s\n%s' % (gv,gs))
if 0:
for i in range(50):
gs.addText('\n' * i +'More')
@language md
# Title
This is **bold** and *italics*.
More info at [Leo's home page](<http://leoeditor.com/).
### Section
- Bullet list
- Another item
- Third item.
@language rest
#####
Title
#####
This is **bold** and *italics*.
More info at `Leo's home page <http://leoeditor.com/>`_.
Section
=======
- Bullet list
- Another item
- Third item.
<!DOCTYPE html>
<html>
<head>
<style>
ul.leo-tree-example {
background-color: #ffffec;
zoom: 150%; # blurs icons a bit.
}
ul.leo-tree-example li {
background-repeat: no-repeat;
background-position: 0px 5px;
padding-left: 27px;
}
li {
background-image:
url('https://raw.github.com/vivainio/leo/master/leo/Icons/box00.GIF');
background-repeat: no-repeat;
background-position: 0px 5px;
padding-left: 27px;
}
li.selected {
background-color: lightgrey;
}
li.leaf {
list-style-type: none;
}
li.plus {
list-style-image: url('http://leoeditor.com/plusnode.gif')
}
li.minus {
list-style-image: url('http://leoeditor.com/minusnode.gif')
}
li.leaf {
background-image: url('http://leoeditor.com/box00.GIF')
}
li.body {
background-image: url('http://leoeditor.com/box01.GIF')
}
li.mark {
background-image: url('http://leoeditor.com/box02.GIF')
}
li.mark-body {
background-image: url('http://leoeditor.com/box03.GIF')
}
li.clone {
background-image: url('http://leoeditor.com/box04.GIF')
}
li.clone-body {
background-image: url('http://leoeditor.com/box05.GIF')
}
li.clone-mark {
background-image: url('http://leoeditor.com/box06.GIF')
}
li.clone-mark-body {
background-image: url('http://leoeditor.com/box07.GIF')
}
li.dirty {
background-image: url('http://leoeditor.com/box08.GIF')
}
li.dirty-body {
background-image: url('http://leoeditor.com/box09.GIF')
}
li.dirty-mark {
background-image: url('http://leoeditor.com/box10.GIF')
}
li.dirty-mark-body {
background-image: url('http://leoeditor.com/box11.GIF')
}
li.dirty-clone {
background-image: url('http://leoeditor.com/box12.GIF')
}
li.dirty-clone-body {
background-image: url('http://leoeditor.com/box13.GIF')
}
li.dirty-clone-mark {
background-image: url('http://leoeditor.com/box14.GIF')
}
</style>
</head>
<body>
<ul class="leo-tree-example">
<li class='plus clone-mark'>
test
</li>
<ul>
<li class='plus clone-body'>
child
</li>
<ul>
<li class='leaf body'>
grandchild
</li>
</ul>
<li class='plus clone-body'>
child
</li>
<ul>
<li class='leaf body'>
grandchild
</li>
</ul>
</ul>
</ul>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--@+leo-ver=5-thin-->
<!--@+node:ekr.20100808060203.4273: * @thin html/front.html-->
<!--@@first-->
<!--@@first-->
<!--@@language html-->
<!--@@tabwidth -2-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!--@+<< head >>-->
<!--@+node:ekr.20100808060203.4274: ** << head >>-->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Leo's Home Page</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/silver_city.css" type="text/css" />
<!--
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '4.7-final',
COLLAPSE_MODINDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: false
};
</script>
-->
<!-- <script type="text/javascript" src="_static/jquery.js"></script>-->
<!-- <script type="text/javascript" src="_static/doctools.js"></script>-->
<link rel="top" title="Leo v4.7-final documentation" href="index.html" />
<link rel="Users Guide" title="Leo’s Users Guide" href="leo_toc.html" />
<!-- <link rel="prev" title="Chapter 5: Using Leo’s Commands" href="commands.html" />-->
<!--@-<< head >>-->
</head>
<body>
<!--@+<< div top nav >>-->
<!--@+node:ekr.20100808060203.4276: ** << div top nav >>-->
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="leo_toc.html" title="Leo’s Users Guide"
accesskey="N">contents</a> |</li>
<!--
<li class="right" >
<a href="commands.html" title="Chapter 5: Using Leo’s Commands"
accesskey="P">previous</a> |</li>
-->
<li><a href="leo_toc.html">Leo v4.7-final documentation</a> »</li>
</ul>
</div>
<!--@-<< div top nav >>-->
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<!--@+<< div outer section >>-->
<!--@+node:ekr.20100808060203.4286: ** << div outer section >>-->
<div class="section" id="Leo’s Home page">
<h1>Leo’s Home Page</h1>
Leo is...
<!--@+<< what is Leo list >>-->
<!--@+node:ekr.20100808060203.4288: *3* << what is Leo list >>-->
<li>
An outline-oriented <i>browser</i> and <i>project manager</i> that organizes<br>
programs, web sites, URL's, pictures, movies or any other kind of data.<br>
You can organize your data in as many ways as you like within a <i>single</i> outline.</li>
<li>
A <i>programmer's editor</i> that fully integrates outline structure with programming.
<!--
<a HREF="http://www.eecs.harvard.edu/~nr/noweb/">noweb</a> and
<a HREF="http://www-cs-faculty.stanford.edu/~knuth/cweb.html">CWEB</a> markup.</li>
-->
<li>
<i>Fully scriptable</i> using <a HREF="http://www.python.org/">Python</a>.
Leo's core is 100% pure Python.</li>
<li>
<i>Portable</i>. Leo runs on Windows, Linux and MacOS X.<br>
Leo requires either the
<a HREF="http://docs.python.org/library/tkinter.html">Tkinter</a> or
<a HREF="http://www.riverbankcomputing.co.uk/software/pyqt/intro">PyQt</a> widget set.<br>
Leo's outline files are <a HREF="http://www.w3.org/XML/">XML</a> format.</li>
<li>
<a href="http://www.opensource.org/"><i>Open Software</i></a>,
distributed under the
<a href="http://www.opensource.org/licenses/mit-license.php/">MIT License</a>.</li>
<!--@-<< what is Leo list >>-->
<!-- div body toc -->
<!-- < < inner sections > > -->
<p>Leo has an active community of helpful users and developers.<br>
Please use the <a href="http://groups.google.com/group/leo-editor">leo-editor</a>
group to ask questions and make suggestions.</p>
<p>Leo's author is <a HREF="ekr.html">Edward K. Ream</a></p>
</div>
<!--@-<< div outer section >>-->
</div>
</div>
</div>
<!--@+<< sidebar >>-->
<!--@+node:ekr.20100808060203.4282: ** << sidebar >>-->
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<!--@+<< sidebar contents >>-->
<!--@+node:ekr.20100808060203.4283: *3* << sidebar contents >>-->
<p class="logo"><a href="leo_toc.html">
<img class="logo" src="_static/Leo4-80-border.jpg" alt="Logo"/></a></p>
<a class="reference external" href="intro.html">
Read this tutorial first</a><br>
<a class="reference external" href="http://www.3dtree.com/ev/e/sbooks/leo/sbframetoc_ie.htm">
Another tutorial</a><br>
<a class="reference external" href="http:screen-shots.html">
Screen shots of Leo</a><br>
<a class="reference external" href="testimonials.html">
Quotes from Leo’s Users</a><br>
<a class="reference external"
href="http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106">
Download Leo</a><br>
<a class="reference external" href="http://groups.google.com/group/leo-editor">
leo-editor: Google Groups</a><br>
<a class="reference external" href="http://launchpad.net/leo-editor">
leo-editor: Launchpad</a><br>
<a class="reference external" href="http://leo.zwiki.org">
Leo’s Wiki</a><br>
<a class="reference external" href="http://www.mind-mapping.org/">
Mind Mapping</a><br>
<a class="reference external" href="leoLinks.html">
More links...</a><br>
<!-- <a class="reference external" href="install.html">Installing Leo</a><br>-->
<!-- <a class="reference external" href="intro.html">Beginners Guide</a><br>-->
<!-- <a class="reference external" href="leo_toc.html">Users Guide</a><br>-->
<!-- <a class="reference external" href="FAQ.html">FAQ</a><br>-->
<!--Leo’s <a class="reference external" href="http://www.greygreen.org/leo/">Daily snapshots</a><br>-->
<!--
<h5>Edward K. Ream</h5>
<a class="reference external" href="ekr.html">Home</a><br>
<a class="reference external" href="mailto:edreamleo@gmail.com">Contact</a><br>
-->
<!--@-<< sidebar contents >>-->
<!-- < < sidebar links > > -->
<!-- < < searchbox > > -->
</div>
</div>
<!--@-<< sidebar >>-->
<div class="clearer"></div>
</div>
<!--@+<< div bottom nav >>-->
<!--@+node:ekr.20100808060203.4277: ** << div bottom nav >>-->
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="leo_toc.html" title="Leo’s Users Guide"
>contents</a> |</li>
<!--
<li class="right" >
<a href="commands.html" title="Chapter 5: Using Leo’s Commands"
>previous</a> |</li>
-->
<li><a href="leo_toc.html">Leo v4.7-final documentation</a> »</li>
</ul>
</div>
<!--@-<< div bottom nav >>-->
<!--@+<< div footer >>-->
<!--@+node:ekr.20100808060203.4278: ** << div footer >>-->
<div class="footer">
© Copyright 2010, Edward K. Ream.
Last updated on Aug 08, 2010.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.3.
</div>
<!--@-<< div footer >>-->
</body>
</html>
<!--@-leo-->
C:\leo.repo\leo-editor\leo\Icons\Leosplash.GIF
This is a comment
c:\leo.repo\leo-editor\leo\Icons\SplashScreen.ico
C:\Users\edreamleo\Documents\Music\2001- A Space Odyssey [Rhino]\06 Gayane Ballet Suite.mp3
https://www.youtube.com/watch?v=EB3IokHelRk
# Doesn't play, probably because of https.
# Note: Modify @data unl-path-prefixes (in this file)
# To match the paths on your machine.
# These links will be active only if the @<file> node exists.
# Absolute file names
# Exists, non-empty.
C:/Repos/leo-editor/leo/plugins/importers/__init__.py:1:0:flake8 error
# Exists, empty.
C:/Repos/leo-editor/leo/plugins/leo_babel/__init__.py:1:0:flake8 error
# Large.
# C:/Repos/leo-editor/leo/core/leoGlobals.py:100:0:flake8 error
h = 'Error messages (copy to log)'
p = g.findNodeAnywhere(c, h)
if p:
lines = [z for z in g.splitLines(p.b) if not z.strip().startswith('#')]
c.frame.log.put_html_links(''.join(lines))
else:
print('Not found:', h)
parse-body
diff-marked-nodes
refresh-from-disk
convert-unls
copy-test
https://github.com/leo-editor/leo-editor/pull/3215/files
# Exists: Recent tests.
unl:gnx://#ekr.20180311131424.1
# Error mssages (copy to log)
unl:gnx://#ekr.20230622112649.1
# Bad gnx
unl:gnx://xyzzy.leo#.20230622112649.1
# In LeoDocs.leo: will work only if LeoDocs.leo is open!
unl:gnx://#ekr.20100805171546.4412
# Shorter UNL:
unl://#Coloring tests-->Syntax coloring template
# Exists, non-empty.
unl://C:/Repos/leo-editor/leo/test/test.leo#@file ../plugins/importers/__init__.py
unl://#@file ../plugins/importers/__init__.py
# Exists, empty.
unl://C:/Repos/leo-editor/leo/test/test.leo#@clean ../plugins/leo_babel/__init__.py
unl://#@clean ../plugins/leo_babel/__init__.py
# Exists
unl://C:/Repos/leo-editor/leo/test/test.leo#Viewrendered examples
unl://#Viewrendered examples
unl://C:/Repos/leo-editor/leo/test/test.leo#Viewrendered examples-->Python code
unl://#Viewrendered examples-->Python code
# Exists: Recent tests
unl:gnx://test.leo#ekr.20180311131424.1
# Error mssages (copy to log)
unl:gnx://test.leo#ekr.20230622112649.1
# The following links depend on @data unl-path-prefixes.
# These links should open LeoDocs.leo if it is not already open.
# In LeoDocs.leo: Leo 6.7.3 release notes
unl:gnx://LeoDocs.leo#ekr.20230409052507.1
# In LeoDocs.leo: ** Read me first **
unl:gnx://LeoDocs.leo#ekr.20050831195449
# Bad gnx: xyzzy.leo does not exist.
unl:gnx://xyzzy.leo#.20230622112649.1
# The following links depend on @data unl-path-prefixes.
unl://LeoDocs.leo#Release Notes-->Leo 6.7.3 release notes
# In LeoDocs.leo
unl://LeoDocs.leo#Web pages
# In LeoDocs.leo. Will work only if LeoDocs.leo is open!
unl://#Web pages
# These unls will work only on EKR's machine.
# They are a test of absolute matches in g.openUNLFile.
# Exists: Recent tests
unl:gnx://c:\Repos\leo-editor\leo\test\test.leo#ekr.20180311131424.1
# Error mssages (copy to log)
unl:gnx://c:\Repos\leo-editor\leo\test\test.leo#ekr.20230622112649.1
# Should fail
unl:gnx://c:\Repos\leo-editor\leo\doc\test.leo#ekr.20230622112649.1
# The following links should open LeoDocs.leo if it is not already open.
# In LeoDocs.leo: Leo 6.7.3 release notes
unl:gnx://c:\Repos\leo-editor\leo\doc\LeoDocs.leo#ekr.20230409052507.1
# In LeoDocs.leo: ** Read me first **
unl:gnx://c:\Repos\leo-editor\leo\doc\LeoDocs.leo#ekr.20050831195449
# Bad gnx: xyzzy.leo does not exist.
unl:gnx://xyzzy.leo#.20230622112649.1
def spam():
pass
def eggs():
pass
demo;
importer;
mdfile;
new-unit-test;
new-unit-test;
g.cls()
import os
import leo.commands.editFileCommands as efc
path = g.finalize_join(g.app.loadDir, '..', '..')
print('path:', path)
os.chdir(path)
# Any revspec is valid as an argument to the "branch1" and "branch2" args.
# See https://git-scm.com/book/en/v2/Git-Tools-Revision-Selection
efc.GitDiffController(c).diff_two_branches(
branch1='devel', # old branch/rev
branch2='ekr-3435-undo-for-refresh-from-disk', # new branch/rev
fn='leo/core/leoGlobals.py', # Don't use back slashes.
)
@language python
# comment.
<< undefined section >>
<< defined section >>
Leo, http://leoeditor.com is an [IDE, outliner and PIM](http://leoeditor.com/preface.html).
- [6.6.3 issues](https://github.com/leo-editor/leo-editor/issues?q=is%3Aissue+milestone%3A6.6.3+)
- 6.6.3 issues: https://github.com/leo-editor/leo-editor/issues?q=is%3Aissue+milestone%3A6.6.3+
- [Documentation](http://leoeditor.com/leo_toc.html)
- [Tutorials](http://leoeditor.com/tutorial.html)
# Link to wikipedia entry
https://en.wikipedia.org/wiki/Leo_(text_editor)
# unl://C:/Users/Edward Ream/ekr.leo#Recent
# This node
# gnx:ekr.20220418190130.1
# Projects
# gnx:ekr.20171027091130.1
print('Hi')
@language html
<html>
<head>
<script>
// js comment
for (let i = 0; i < cars.length; i++) {
text += cars[i] + "<br>";
}
</script>
</head>
<body>
<p1>
<-- html comment -->
This is a test.
</body>
</html>
@language html
<script>
for (let i = 0; i < cars.length; i++) {
text += cars[i] + "<br>";
}
</script>
@language javascript
for (let i = 0; i < cars.length; i++) {
text += cars[i] + "<br>";
}
@language json
{
"leoHeader": {
"fileFormat": 2
},
"globals": {
"body_outline_ratio": 0.37926509186351703,
"body_secondary_ratio": 0.5978391356542617,
"globalWindowPosition": {
"height": 929,
"left": 510,
"top": 38,
"width": 841
}
},
"tnodes": {
"ekr.20201106041444.1": "",
"ekr.20220225070605.1": "# Trailing whitespace.\n\nunl://C:/Users/Edward Ream/ekr.leo#6.6-b2 checklist\n\n# Bare file name\n\nunl://C:/Users/Edward Ream/ekr.leo#\n\nOpens leoPy.leo\nunl://C:/leo.repo/leo-editor/leo/core/leoPy.leo#=== #2413: ctrl-click unl\nunl://C:/leo.repo/leo-editor/leo/core/leoPy.leo#g.findUNL & helpers-->function: full_match\n\nLocal\nunl://C:/Users/Edward Ream/ekr.leo#test: findUNL\n\n\n# Headline not found\n\nunl://C:/Users/Edward Ream/ekr.leo#xxx_yyy"
},
"uas": {
"ekr.20201106041444.1": "{\"annotate\": {\"priority\": 8, \"prisetdate\": \"2022-03-14\"}, \"icons\": [{\"type\": \"file\", \"file\": \"C:/leo.repo/leo-editor/leo/Icons/cleo/pri8.png\", \"relPath\": \"cleo/pri8.png\", \"where\": \"beforeHeadline\", \"yoffset\": 0, \"xoffset\": 2, \"xpad\": 1, \"on\": \"vnode\", \"cleoIcon\": \"1\"}]}"
},
"vnodes": [
{
"gnx": "ekr.20201106041444.1",
"vh": "Recent",
"status": 1024,
"children": [
{
"gnx": "ekr.20220225070605.1",
"vh": "test UNLs",
"status": 1024,
"children": []
}
]
}
]
}
@language md
<!-- comment -->
*Italic*
**Bold**
@language python
def spam():
a = "abc"
# Test.
<< test >>
<< exists >>
# https://ethanschoonover.com/solarized/
@language rest
.. comment
.. Should be `@font rest.comment2`
**Bold**
plain rest text.
*Italics*
import os
import time
t1 = time.process_time()
filenames = (
'leoGlobals.py',
'leoNodes.py',
)
for filename in filenames:
path = g.finalize_join(g.app.loadDir, filename)
assert os.path.exists(path), path
if 0: # Use leoAst.
import leo.core.leoAst as leoAst
d = {}
contents = leoAst.read_file(filename)
tokens = leoAst.make_tokens(contents)
d [path] = tokens
else: # 0.77 sec.
import asttokens
d = {}
with open(path, 'r') as f:
source = f.read()
tokens = asttokens.ASTTokens(source, parse=True)
d [path] = tokens
t2 = time.process_time()
print(f"{(t2-t1):5.2f} sec")
# g.printObj(d, tag=f"{(t2-t1):5.2f} sec")
# g.cls()
from leo.core.leoQt import QtWidgets
# from leo.core.leoQt import QtCore
assert isinstance(c.frame.top, QtWidgets.QMainWindow)
# g.trace(c.frame.top)
iconBar = c.frame.top.iconBar
# g.trace(iconBar)
# c.frame.top.addToolBarBreak(iconBar) ### QtCore.Qt.ToolBarArea.TopToolBarArea)
toolBar2 = QtWidgets.QToolBar()
c.frame.top.addToolBar(toolBar2)
toolBar2.addWidget(QtWidgets.QPushButton("TEST"))
<html>
<head>
<link rel="stylesheet" href="https://pyscript.net/latest/pyscript.css" />
<script defer src="https://pyscript.net/latest/pyscript.js"></script>
<style>
.pulse {
animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
@keyframes pulse {
0%, 100% {
opacity: 1;
}
50% {
opacity: .2;
}
}
</style>
</head>
<body>
<h1>Let's plot random numbers</h1>
<div id="plot">
<div class="pulse" >
<p style='font-family: monospace sans-serif;'><big><big><big><big>❰py❱</big></big></big></big></p>
</div>
</div>
<py-config>
packages = [
"numpy",
"matplotlib"
]
</py-config>
<py-script>
import matplotlib.pyplot as plt
import numpy as np
x = np.random.randn(1000)
y = np.random.randn(1000)
fig, ax = plt.subplots()
ax.scatter(x, y)
pyscript.write('plot', fig)
</py-script>
</body>
</html>
ksuid
uuid
Should be default gnx.
@language python
"""Change the body font of a node.
Called when the selected node changes. If the language directive
in effect is one of the specified ones, change the font family to
one of the specified fonts. Also change the font if the body
contains lines near the start that begin with ":id:" or ":ref:".
Otherwise change it back to the normal font."""
NOSTYLE = 'LeoQTextBrowser {}'
STYLE = ('LeoQTextBrowser {font-family: Verdana, "Sans-serif";'
'font-size: 10pt;}')
LANGS = ('@language rest', '@language md', '@language asciidoc',
'@language text', '@language plain')
LANGTAGS = ('@rest', '@md', '@rst', '@adoc')
TAGS = (':id:', ':ref:')
def qualifies(b, h):
"""See if we have a qualifying language or tag.
RETURNS
-- True if headline h starts with one of the LANGTAGS.
-- True if body b has a line starting with a qualifying tag or
language directive.
-- -1 if body b has a line starting with "@language" but
the language is not a qualifying one.
-- False otherwise.
"""
if h.startswith(LANGTAGS):
return True
lines = b[:300].splitlines()
lines = [l for l in lines if l.strip()]
for line in lines:
if line.startswith('@language'):
if line.startswith(LANGS):
return True
else:
return -1 # Tri-state logic; not a mistake
else:
if line.startswith(TAGS):
return True
return False
def set_alt_body_font(tag, keys):
"""Set body font if this node is one of the qualifying node kinds.
Looks up the tree until a qualifying node is found. Then sets the
CSS style based on the qualified language or tag.
Expected to be called by a hook procedure.
"""
c = keys['c']
css = NOSTYLE
# Check if language or special tags qualify
for p in c.p.self_and_parents():
found = qualifies(p.b, p.h)
if found is True:
css = STYLE
break
elif found is not False: # Tri-state logic!
break
editor = c.frame.body.wrapper.widget
editor.setStyleSheet(css)
ud = g.user_dict
ud['alt_body_font_proc'] = set_alt_body_font
g.registerHandler('select3', ud['alt_body_font_proc'])
@language python
"""Stop Changing the body font of a node.
Reverses the effect of the "change body font" script so that the body
font no longer changes when focus moves to a text/rest/md/etc node.
"""
NOSTYLE = 'LeoQTextBrowser {}'
def set_alt_body_font(tag, keys):
"""Set body font back to the theme's font.
Expected to be called by a hook procedure.
"""
c = keys['c']
css = NOSTYLE
editor = c.frame.body.wrapper.widget
editor.setStyleSheet(css)
ud = g.user_dict
g.unregisterHandler('select3', ud['alt_body_font_proc'])
ud['alt_body_font_proc'] = set_alt_body_font
g.registerHandler('select3', ud['alt_body_font_proc'])
# Exists: Recent tests
unl:gnx://#ekr.20180311131424.1
# Error mssages (copy to log)
unl:gnx://#ekr.20230622112649.1
# The following will work only if LeoDocs.leo is open!
# In LeoDocs.leo: Leo 6.7.3 release notes
unl:gnx://#ekr.20230409052507.1
# In LeoDocs.leo: ** Read me first **
unl:gnx://#ekr.20050831195449
# These data work on EKR's machine. Modify for your own!
# lines have the form:
# x.leo: <absolute path to x.leo>
test.leo: c:/Repos/leo-editor/leo/test
LeoDocs.leo: c:/Repos/leo-editor/leo/doc
# In LeoDocs.leo: Leo 6.7.3 release notes
unl:gnx://../doc/LeoDocs.leo#ekr.20230409052507.1
# In LeoDocs.leo: ** Leo's Documentation **
unl:gnx://../doc/LeoDocs.leo#ekr.20040414161647
# Just open LeoDocs.leo.
unl:gnx://../doc/LeoDocs.leo#