bare-script 5.1.3__tar.gz → 5.1.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {bare_script-5.1.3/src/bare_script.egg-info → bare_script-5.1.6}/PKG-INFO +102 -50
- {bare_script-5.1.3 → bare_script-5.1.6}/README.md +101 -49
- {bare_script-5.1.3 → bare_script-5.1.6}/pyproject.toml +1 -1
- {bare_script-5.1.3 → bare_script-5.1.6}/src/bare_script/include.py +23 -0
- bare_script-5.1.6/src/bare_script/include_source.py +4745 -0
- {bare_script-5.1.3 → bare_script-5.1.6/src/bare_script.egg-info}/PKG-INFO +102 -50
- bare_script-5.1.3/src/bare_script/include_source.py +0 -5350
- {bare_script-5.1.3 → bare_script-5.1.6}/LICENSE +0 -0
- {bare_script-5.1.3 → bare_script-5.1.6}/setup.cfg +0 -0
- {bare_script-5.1.3 → bare_script-5.1.6}/setup.py +0 -0
- {bare_script-5.1.3 → bare_script-5.1.6}/src/bare_script/__init__.py +0 -0
- {bare_script-5.1.3 → bare_script-5.1.6}/src/bare_script/__main__.py +0 -0
- {bare_script-5.1.3 → bare_script-5.1.6}/src/bare_script/bare.py +0 -0
- {bare_script-5.1.3 → bare_script-5.1.6}/src/bare_script/library.py +0 -0
- {bare_script-5.1.3 → bare_script-5.1.6}/src/bare_script/options.py +0 -0
- {bare_script-5.1.3 → bare_script-5.1.6}/src/bare_script/runtime.py +0 -0
- {bare_script-5.1.3 → bare_script-5.1.6}/src/bare_script/runtime_c.c +0 -0
- {bare_script-5.1.3 → bare_script-5.1.6}/src/bare_script/value.py +0 -0
- {bare_script-5.1.3 → bare_script-5.1.6}/src/bare_script.egg-info/SOURCES.txt +0 -0
- {bare_script-5.1.3 → bare_script-5.1.6}/src/bare_script.egg-info/dependency_links.txt +0 -0
- {bare_script-5.1.3 → bare_script-5.1.6}/src/bare_script.egg-info/entry_points.txt +0 -0
- {bare_script-5.1.3 → bare_script-5.1.6}/src/bare_script.egg-info/requires.txt +0 -0
- {bare_script-5.1.3 → bare_script-5.1.6}/src/bare_script.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: bare-script
|
|
3
|
-
Version: 5.1.
|
|
3
|
+
Version: 5.1.6
|
|
4
4
|
Summary: BareScript; a lightweight scripting and expression language
|
|
5
5
|
Author-email: "Craig A. Hobbs" <craigahobbs@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -49,7 +49,6 @@ confident that BareScript will execute the same regardless of the underlying run
|
|
|
49
49
|
|
|
50
50
|
- [The BareScript Language](https://craigahobbs.github.io/bare-script-py/language/)
|
|
51
51
|
- [The BareScript Library](https://craigahobbs.github.io/bare-script-py/library/)
|
|
52
|
-
- [The BareScript Include Library Tests](https://craigahobbs.github.io/bare-script/include/test/)
|
|
53
52
|
- [API Documentation](https://craigahobbs.github.io/bare-script-py/)
|
|
54
53
|
- [Source code](https://github.com/craigahobbs/bare-script-py)
|
|
55
54
|
|
|
@@ -96,20 +95,22 @@ This outputs:
|
|
|
96
95
|
```
|
|
97
96
|
|
|
98
97
|
|
|
99
|
-
|
|
98
|
+
## The BareScript Library
|
|
100
99
|
|
|
101
100
|
[The BareScript Library](https://craigahobbs.github.io/bare-script-py/library/)
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
101
|
+
documents the built-in functions available to every script and the include libraries loaded with
|
|
102
|
+
the [include statement](https://craigahobbs.github.io/bare-script-py/language/#include-statements).
|
|
103
|
+
Built-in functions cover mathematical operations, object and array manipulation, regular
|
|
104
|
+
expressions, HTTP fetch, and more. Angle-bracket includes (`include <markdown.bare>`) load libraries
|
|
105
|
+
bundled with the runtime. Quoted includes (`include 'util.bare'`) load a local file or URL.
|
|
106
|
+
|
|
107
|
+
The following example uses the built-in
|
|
105
108
|
[systemFetch](https://craigahobbs.github.io/bare-script-py/library/#var.vGroup='system'&systemfetch),
|
|
106
109
|
[objectGet](https://craigahobbs.github.io/bare-script-py/library/#var.vGroup='object'&objectget), and
|
|
107
110
|
[arrayLength](https://craigahobbs.github.io/bare-script-py/library/#var.vGroup='array'&arraylength)
|
|
108
|
-
functions
|
|
111
|
+
functions:
|
|
109
112
|
|
|
110
113
|
```python
|
|
111
|
-
import urllib.request
|
|
112
|
-
|
|
113
114
|
from bare_script import barescript_parse_script, execute_script, fetch_http
|
|
114
115
|
|
|
115
116
|
# Parse the script
|
|
@@ -131,44 +132,48 @@ This outputs:
|
|
|
131
132
|
The BareScript Library has 100 builtin functions
|
|
132
133
|
```
|
|
133
134
|
|
|
134
|
-
|
|
135
|
-
## Evaluating BareScript Expressions
|
|
136
|
-
|
|
137
|
-
To evaluate a
|
|
138
|
-
[BareScript expression](https://craigahobbs.github.io/bare-script-py/language/#expressions),
|
|
139
|
-
parse the expression using the
|
|
140
|
-
[barescript_parse_expression](https://craigahobbs.github.io/bare-script-py/expressions.html#barescript-parse-expression)
|
|
141
|
-
function. Then evaluate the expression using the
|
|
142
|
-
[evaluate_expression](https://craigahobbs.github.io/bare-script-py/expressions.html#evaluate-expression)
|
|
143
|
-
function.
|
|
144
|
-
|
|
145
|
-
Expression evaluation includes the
|
|
146
|
-
[BareScript Expression Library](https://craigahobbs.github.io/bare-script-py/library/expression.html),
|
|
147
|
-
a set of built-in, spreadsheet-like functions.
|
|
148
|
-
|
|
149
|
-
For example:
|
|
135
|
+
Include libraries are loaded before use:
|
|
150
136
|
|
|
151
137
|
```python
|
|
152
|
-
from bare_script import
|
|
138
|
+
from bare_script import barescript_parse_script, execute_script
|
|
153
139
|
|
|
154
|
-
# Parse the
|
|
155
|
-
|
|
140
|
+
# Parse the script
|
|
141
|
+
script = barescript_parse_script('''\
|
|
142
|
+
include <markdownParser.bare>
|
|
143
|
+
include <markdown.bare>
|
|
156
144
|
|
|
157
|
-
#
|
|
158
|
-
|
|
159
|
-
|
|
145
|
+
markdown = markdownParse('# Hello, Markdown!')
|
|
146
|
+
return markdownTitle(markdown)
|
|
147
|
+
''')
|
|
148
|
+
|
|
149
|
+
# Execute the script
|
|
150
|
+
print(execute_script(script))
|
|
160
151
|
```
|
|
161
152
|
|
|
162
153
|
This outputs:
|
|
163
154
|
|
|
164
155
|
```
|
|
165
|
-
|
|
156
|
+
Hello, Markdown!
|
|
166
157
|
```
|
|
167
158
|
|
|
159
|
+
Quoted includes and
|
|
160
|
+
[systemFetch](https://craigahobbs.github.io/bare-script-py/library/#var.vGroup='system'&systemfetch)
|
|
161
|
+
calls with a non-URL path need a filesystem-aware fetch function. Pass
|
|
162
|
+
[fetch_read_only](https://craigahobbs.github.io/bare-script-py/options.html#bare_script.fetch_read_only)
|
|
163
|
+
or
|
|
164
|
+
[fetch_read_write](https://craigahobbs.github.io/bare-script-py/options.html#bare_script.fetch_read_write):
|
|
165
|
+
|
|
166
|
+
```python
|
|
167
|
+
from bare_script import barescript_parse_script, execute_script, fetch_read_write
|
|
168
|
+
|
|
169
|
+
script = barescript_parse_script("include 'util.bare'")
|
|
170
|
+
execute_script(script, {'fetchFn': fetch_read_write})
|
|
171
|
+
```
|
|
168
172
|
|
|
169
|
-
## The Include Library Stub Functions
|
|
170
173
|
|
|
171
|
-
|
|
174
|
+
### Stub Functions
|
|
175
|
+
|
|
176
|
+
Include library functions are also callable directly from Python using the native stub functions
|
|
172
177
|
exported by the
|
|
173
178
|
[include module](https://craigahobbs.github.io/bare-script-py/include.html) — for example,
|
|
174
179
|
[data_aggregate](https://craigahobbs.github.io/bare-script-py/include.html#data-aggregate),
|
|
@@ -201,13 +206,54 @@ Hello, Markdown!
|
|
|
201
206
|
```
|
|
202
207
|
|
|
203
208
|
|
|
209
|
+
## Evaluating BareScript Expressions
|
|
210
|
+
|
|
211
|
+
To evaluate a
|
|
212
|
+
[BareScript expression](https://craigahobbs.github.io/bare-script-py/language/#expressions),
|
|
213
|
+
parse the expression using the
|
|
214
|
+
[barescript_parse_expression](https://craigahobbs.github.io/bare-script-py/expressions.html#barescript-parse-expression)
|
|
215
|
+
function. Then evaluate the expression using the
|
|
216
|
+
[evaluate_expression](https://craigahobbs.github.io/bare-script-py/expressions.html#evaluate-expression)
|
|
217
|
+
function.
|
|
218
|
+
|
|
219
|
+
Expression evaluation includes the
|
|
220
|
+
[BareScript Expression Library](https://craigahobbs.github.io/bare-script-py/library/expression.html),
|
|
221
|
+
a set of built-in, spreadsheet-like functions.
|
|
222
|
+
|
|
223
|
+
For example:
|
|
224
|
+
|
|
225
|
+
```python
|
|
226
|
+
from bare_script import barescript_parse_expression, evaluate_expression
|
|
227
|
+
|
|
228
|
+
# Parse the expression
|
|
229
|
+
expr = barescript_parse_expression('2 * max(a, b, c)')
|
|
230
|
+
|
|
231
|
+
# Evaluate the expression
|
|
232
|
+
variables = {'a': 1, 'b': 2, 'c': 3}
|
|
233
|
+
print(evaluate_expression(expr, None, variables))
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
This outputs:
|
|
237
|
+
|
|
238
|
+
```
|
|
239
|
+
6
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
|
|
204
243
|
## The BareScript Command-Line Interface (CLI)
|
|
205
244
|
|
|
206
245
|
You can run BareScript from the command line using the BareScript CLI, "bare". BareScript script
|
|
207
246
|
files use the ".bare" file extension.
|
|
208
247
|
|
|
209
248
|
```
|
|
210
|
-
bare script.bare
|
|
249
|
+
bare script.bare # run a script
|
|
250
|
+
bare -c 'systemLog("Hello, World!")' # execute inline code
|
|
251
|
+
bare -v N 10 script.bare # set the global N to 10
|
|
252
|
+
bare -d script.bare # debug mode
|
|
253
|
+
bare -m app.bare # MarkdownUp text output
|
|
254
|
+
bare -l app.bare # MarkdownUp HTML output
|
|
255
|
+
bare -s script.bare # parse and lint only
|
|
256
|
+
bare -x script.bare # lint with execution
|
|
211
257
|
```
|
|
212
258
|
|
|
213
259
|
**Note:** In the BareScript CLI, include statements and the
|
|
@@ -233,6 +279,11 @@ markdownPrint('Hello, Markdown!')
|
|
|
233
279
|
```
|
|
234
280
|
~~~
|
|
235
281
|
|
|
282
|
+
To run a MarkdownUp script (`.bare`) from this package, use `bare -m` (Markdown text) or `bare -l`
|
|
283
|
+
(HTML). To view a MarkdownUp document (`.md` with `markdown-script` blocks), install the
|
|
284
|
+
[markdown-up](https://github.com/craigahobbs/markdown-up-py#readme) viewer or open the file in the
|
|
285
|
+
[MarkdownUp web app](https://craigahobbs.github.io/markdown-up/).
|
|
286
|
+
|
|
236
287
|
|
|
237
288
|
## C Runtime
|
|
238
289
|
|
|
@@ -260,21 +311,21 @@ without a native Python equivalent are omitted.
|
|
|
260
311
|
|
|
261
312
|
| Test | Language | Time (ms) | Multiple |
|
|
262
313
|
| ---------------- | ---------------- | --------: | -------: |
|
|
263
|
-
| mandelbrot | Python |
|
|
264
|
-
| | BareScript (PyC) |
|
|
265
|
-
| | BareScript (Py) |
|
|
266
|
-
| schemaValidate | Python |
|
|
267
|
-
| | BareScript (PyC) |
|
|
268
|
-
| | BareScript (Py) |
|
|
314
|
+
| mandelbrot | Python | 4630.9 | |
|
|
315
|
+
| | BareScript (PyC) | 10900.0 | 2.4x |
|
|
316
|
+
| | BareScript (Py) | 341300.0 | 73.7x |
|
|
317
|
+
| schemaValidate | Python | 20.7 | |
|
|
318
|
+
| | BareScript (PyC) | 105.6 | 5.1x |
|
|
319
|
+
| | BareScript (Py) | 1433.2 | 69.2x |
|
|
269
320
|
| urlEncode | Python | 1.1 | |
|
|
270
|
-
| | BareScript (PyC) | 5.
|
|
271
|
-
| | BareScript (Py) | 39.
|
|
272
|
-
| schemaParse | Python | 17.
|
|
273
|
-
| | BareScript (PyC) |
|
|
274
|
-
| | BareScript (Py) |
|
|
321
|
+
| | BareScript (PyC) | 5.7 | 5.4x |
|
|
322
|
+
| | BareScript (Py) | 39.6 | 37.5x |
|
|
323
|
+
| schemaParse | Python | 17.2 | |
|
|
324
|
+
| | BareScript (PyC) | 123.6 | 7.2x |
|
|
325
|
+
| | BareScript (Py) | 904.8 | 52.7x |
|
|
275
326
|
| urlDecode | Python | 1.2 | |
|
|
276
|
-
| | BareScript (PyC) | 13.
|
|
277
|
-
| | BareScript (Py) | 68.
|
|
327
|
+
| | BareScript (PyC) | 13.2 | 11.2x |
|
|
328
|
+
| | BareScript (Py) | 68.8 | 58.3x |
|
|
278
329
|
|
|
279
330
|
|
|
280
331
|
## Using BareScript with an AI Assistant
|
|
@@ -283,7 +334,8 @@ This repository ships a
|
|
|
283
334
|
[`SKILL.md`](https://github.com/craigahobbs/bare-script-py/blob/main/SKILL.md)
|
|
284
335
|
file that teaches an AI coding assistant how to write idiomatic BareScript — language syntax, the
|
|
285
336
|
built-in and include libraries, the MarkdownUp application pattern, and the unit-test conventions.
|
|
286
|
-
It is plain Markdown and applies to either BareScript implementation.
|
|
337
|
+
It is plain Markdown and applies to either BareScript implementation. Assistants that discover
|
|
338
|
+
`SKILL.md` at the repository root can use it without copying.
|
|
287
339
|
|
|
288
340
|
For [Claude Code](https://claude.com/claude-code) and other tools that follow the
|
|
289
341
|
[Agent Skills](https://docs.claude.com/en/docs/agents-and-tools/agent-skills/overview)
|
|
@@ -304,7 +356,7 @@ claude "Build a MarkdownUp application that plays tic-tac-toe against the user,
|
|
|
304
356
|
```
|
|
305
357
|
|
|
306
358
|
To run the resulting MarkdownUp application locally, install the
|
|
307
|
-
[markdown-up](https://
|
|
359
|
+
[markdown-up](https://github.com/craigahobbs/markdown-up-py#readme) viewer and point it at the Markdown file:
|
|
308
360
|
|
|
309
361
|
```
|
|
310
362
|
pip install markdown-up
|
|
@@ -23,7 +23,6 @@ confident that BareScript will execute the same regardless of the underlying run
|
|
|
23
23
|
|
|
24
24
|
- [The BareScript Language](https://craigahobbs.github.io/bare-script-py/language/)
|
|
25
25
|
- [The BareScript Library](https://craigahobbs.github.io/bare-script-py/library/)
|
|
26
|
-
- [The BareScript Include Library Tests](https://craigahobbs.github.io/bare-script/include/test/)
|
|
27
26
|
- [API Documentation](https://craigahobbs.github.io/bare-script-py/)
|
|
28
27
|
- [Source code](https://github.com/craigahobbs/bare-script-py)
|
|
29
28
|
|
|
@@ -70,20 +69,22 @@ This outputs:
|
|
|
70
69
|
```
|
|
71
70
|
|
|
72
71
|
|
|
73
|
-
|
|
72
|
+
## The BareScript Library
|
|
74
73
|
|
|
75
74
|
[The BareScript Library](https://craigahobbs.github.io/bare-script-py/library/)
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
documents the built-in functions available to every script and the include libraries loaded with
|
|
76
|
+
the [include statement](https://craigahobbs.github.io/bare-script-py/language/#include-statements).
|
|
77
|
+
Built-in functions cover mathematical operations, object and array manipulation, regular
|
|
78
|
+
expressions, HTTP fetch, and more. Angle-bracket includes (`include <markdown.bare>`) load libraries
|
|
79
|
+
bundled with the runtime. Quoted includes (`include 'util.bare'`) load a local file or URL.
|
|
80
|
+
|
|
81
|
+
The following example uses the built-in
|
|
79
82
|
[systemFetch](https://craigahobbs.github.io/bare-script-py/library/#var.vGroup='system'&systemfetch),
|
|
80
83
|
[objectGet](https://craigahobbs.github.io/bare-script-py/library/#var.vGroup='object'&objectget), and
|
|
81
84
|
[arrayLength](https://craigahobbs.github.io/bare-script-py/library/#var.vGroup='array'&arraylength)
|
|
82
|
-
functions
|
|
85
|
+
functions:
|
|
83
86
|
|
|
84
87
|
```python
|
|
85
|
-
import urllib.request
|
|
86
|
-
|
|
87
88
|
from bare_script import barescript_parse_script, execute_script, fetch_http
|
|
88
89
|
|
|
89
90
|
# Parse the script
|
|
@@ -105,44 +106,48 @@ This outputs:
|
|
|
105
106
|
The BareScript Library has 100 builtin functions
|
|
106
107
|
```
|
|
107
108
|
|
|
108
|
-
|
|
109
|
-
## Evaluating BareScript Expressions
|
|
110
|
-
|
|
111
|
-
To evaluate a
|
|
112
|
-
[BareScript expression](https://craigahobbs.github.io/bare-script-py/language/#expressions),
|
|
113
|
-
parse the expression using the
|
|
114
|
-
[barescript_parse_expression](https://craigahobbs.github.io/bare-script-py/expressions.html#barescript-parse-expression)
|
|
115
|
-
function. Then evaluate the expression using the
|
|
116
|
-
[evaluate_expression](https://craigahobbs.github.io/bare-script-py/expressions.html#evaluate-expression)
|
|
117
|
-
function.
|
|
118
|
-
|
|
119
|
-
Expression evaluation includes the
|
|
120
|
-
[BareScript Expression Library](https://craigahobbs.github.io/bare-script-py/library/expression.html),
|
|
121
|
-
a set of built-in, spreadsheet-like functions.
|
|
122
|
-
|
|
123
|
-
For example:
|
|
109
|
+
Include libraries are loaded before use:
|
|
124
110
|
|
|
125
111
|
```python
|
|
126
|
-
from bare_script import
|
|
112
|
+
from bare_script import barescript_parse_script, execute_script
|
|
127
113
|
|
|
128
|
-
# Parse the
|
|
129
|
-
|
|
114
|
+
# Parse the script
|
|
115
|
+
script = barescript_parse_script('''\
|
|
116
|
+
include <markdownParser.bare>
|
|
117
|
+
include <markdown.bare>
|
|
130
118
|
|
|
131
|
-
#
|
|
132
|
-
|
|
133
|
-
|
|
119
|
+
markdown = markdownParse('# Hello, Markdown!')
|
|
120
|
+
return markdownTitle(markdown)
|
|
121
|
+
''')
|
|
122
|
+
|
|
123
|
+
# Execute the script
|
|
124
|
+
print(execute_script(script))
|
|
134
125
|
```
|
|
135
126
|
|
|
136
127
|
This outputs:
|
|
137
128
|
|
|
138
129
|
```
|
|
139
|
-
|
|
130
|
+
Hello, Markdown!
|
|
140
131
|
```
|
|
141
132
|
|
|
133
|
+
Quoted includes and
|
|
134
|
+
[systemFetch](https://craigahobbs.github.io/bare-script-py/library/#var.vGroup='system'&systemfetch)
|
|
135
|
+
calls with a non-URL path need a filesystem-aware fetch function. Pass
|
|
136
|
+
[fetch_read_only](https://craigahobbs.github.io/bare-script-py/options.html#bare_script.fetch_read_only)
|
|
137
|
+
or
|
|
138
|
+
[fetch_read_write](https://craigahobbs.github.io/bare-script-py/options.html#bare_script.fetch_read_write):
|
|
139
|
+
|
|
140
|
+
```python
|
|
141
|
+
from bare_script import barescript_parse_script, execute_script, fetch_read_write
|
|
142
|
+
|
|
143
|
+
script = barescript_parse_script("include 'util.bare'")
|
|
144
|
+
execute_script(script, {'fetchFn': fetch_read_write})
|
|
145
|
+
```
|
|
142
146
|
|
|
143
|
-
## The Include Library Stub Functions
|
|
144
147
|
|
|
145
|
-
|
|
148
|
+
### Stub Functions
|
|
149
|
+
|
|
150
|
+
Include library functions are also callable directly from Python using the native stub functions
|
|
146
151
|
exported by the
|
|
147
152
|
[include module](https://craigahobbs.github.io/bare-script-py/include.html) — for example,
|
|
148
153
|
[data_aggregate](https://craigahobbs.github.io/bare-script-py/include.html#data-aggregate),
|
|
@@ -175,13 +180,54 @@ Hello, Markdown!
|
|
|
175
180
|
```
|
|
176
181
|
|
|
177
182
|
|
|
183
|
+
## Evaluating BareScript Expressions
|
|
184
|
+
|
|
185
|
+
To evaluate a
|
|
186
|
+
[BareScript expression](https://craigahobbs.github.io/bare-script-py/language/#expressions),
|
|
187
|
+
parse the expression using the
|
|
188
|
+
[barescript_parse_expression](https://craigahobbs.github.io/bare-script-py/expressions.html#barescript-parse-expression)
|
|
189
|
+
function. Then evaluate the expression using the
|
|
190
|
+
[evaluate_expression](https://craigahobbs.github.io/bare-script-py/expressions.html#evaluate-expression)
|
|
191
|
+
function.
|
|
192
|
+
|
|
193
|
+
Expression evaluation includes the
|
|
194
|
+
[BareScript Expression Library](https://craigahobbs.github.io/bare-script-py/library/expression.html),
|
|
195
|
+
a set of built-in, spreadsheet-like functions.
|
|
196
|
+
|
|
197
|
+
For example:
|
|
198
|
+
|
|
199
|
+
```python
|
|
200
|
+
from bare_script import barescript_parse_expression, evaluate_expression
|
|
201
|
+
|
|
202
|
+
# Parse the expression
|
|
203
|
+
expr = barescript_parse_expression('2 * max(a, b, c)')
|
|
204
|
+
|
|
205
|
+
# Evaluate the expression
|
|
206
|
+
variables = {'a': 1, 'b': 2, 'c': 3}
|
|
207
|
+
print(evaluate_expression(expr, None, variables))
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
This outputs:
|
|
211
|
+
|
|
212
|
+
```
|
|
213
|
+
6
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
|
|
178
217
|
## The BareScript Command-Line Interface (CLI)
|
|
179
218
|
|
|
180
219
|
You can run BareScript from the command line using the BareScript CLI, "bare". BareScript script
|
|
181
220
|
files use the ".bare" file extension.
|
|
182
221
|
|
|
183
222
|
```
|
|
184
|
-
bare script.bare
|
|
223
|
+
bare script.bare # run a script
|
|
224
|
+
bare -c 'systemLog("Hello, World!")' # execute inline code
|
|
225
|
+
bare -v N 10 script.bare # set the global N to 10
|
|
226
|
+
bare -d script.bare # debug mode
|
|
227
|
+
bare -m app.bare # MarkdownUp text output
|
|
228
|
+
bare -l app.bare # MarkdownUp HTML output
|
|
229
|
+
bare -s script.bare # parse and lint only
|
|
230
|
+
bare -x script.bare # lint with execution
|
|
185
231
|
```
|
|
186
232
|
|
|
187
233
|
**Note:** In the BareScript CLI, include statements and the
|
|
@@ -207,6 +253,11 @@ markdownPrint('Hello, Markdown!')
|
|
|
207
253
|
```
|
|
208
254
|
~~~
|
|
209
255
|
|
|
256
|
+
To run a MarkdownUp script (`.bare`) from this package, use `bare -m` (Markdown text) or `bare -l`
|
|
257
|
+
(HTML). To view a MarkdownUp document (`.md` with `markdown-script` blocks), install the
|
|
258
|
+
[markdown-up](https://github.com/craigahobbs/markdown-up-py#readme) viewer or open the file in the
|
|
259
|
+
[MarkdownUp web app](https://craigahobbs.github.io/markdown-up/).
|
|
260
|
+
|
|
210
261
|
|
|
211
262
|
## C Runtime
|
|
212
263
|
|
|
@@ -234,21 +285,21 @@ without a native Python equivalent are omitted.
|
|
|
234
285
|
|
|
235
286
|
| Test | Language | Time (ms) | Multiple |
|
|
236
287
|
| ---------------- | ---------------- | --------: | -------: |
|
|
237
|
-
| mandelbrot | Python |
|
|
238
|
-
| | BareScript (PyC) |
|
|
239
|
-
| | BareScript (Py) |
|
|
240
|
-
| schemaValidate | Python |
|
|
241
|
-
| | BareScript (PyC) |
|
|
242
|
-
| | BareScript (Py) |
|
|
288
|
+
| mandelbrot | Python | 4630.9 | |
|
|
289
|
+
| | BareScript (PyC) | 10900.0 | 2.4x |
|
|
290
|
+
| | BareScript (Py) | 341300.0 | 73.7x |
|
|
291
|
+
| schemaValidate | Python | 20.7 | |
|
|
292
|
+
| | BareScript (PyC) | 105.6 | 5.1x |
|
|
293
|
+
| | BareScript (Py) | 1433.2 | 69.2x |
|
|
243
294
|
| urlEncode | Python | 1.1 | |
|
|
244
|
-
| | BareScript (PyC) | 5.
|
|
245
|
-
| | BareScript (Py) | 39.
|
|
246
|
-
| schemaParse | Python | 17.
|
|
247
|
-
| | BareScript (PyC) |
|
|
248
|
-
| | BareScript (Py) |
|
|
295
|
+
| | BareScript (PyC) | 5.7 | 5.4x |
|
|
296
|
+
| | BareScript (Py) | 39.6 | 37.5x |
|
|
297
|
+
| schemaParse | Python | 17.2 | |
|
|
298
|
+
| | BareScript (PyC) | 123.6 | 7.2x |
|
|
299
|
+
| | BareScript (Py) | 904.8 | 52.7x |
|
|
249
300
|
| urlDecode | Python | 1.2 | |
|
|
250
|
-
| | BareScript (PyC) | 13.
|
|
251
|
-
| | BareScript (Py) | 68.
|
|
301
|
+
| | BareScript (PyC) | 13.2 | 11.2x |
|
|
302
|
+
| | BareScript (Py) | 68.8 | 58.3x |
|
|
252
303
|
|
|
253
304
|
|
|
254
305
|
## Using BareScript with an AI Assistant
|
|
@@ -257,7 +308,8 @@ This repository ships a
|
|
|
257
308
|
[`SKILL.md`](https://github.com/craigahobbs/bare-script-py/blob/main/SKILL.md)
|
|
258
309
|
file that teaches an AI coding assistant how to write idiomatic BareScript — language syntax, the
|
|
259
310
|
built-in and include libraries, the MarkdownUp application pattern, and the unit-test conventions.
|
|
260
|
-
It is plain Markdown and applies to either BareScript implementation.
|
|
311
|
+
It is plain Markdown and applies to either BareScript implementation. Assistants that discover
|
|
312
|
+
`SKILL.md` at the repository root can use it without copying.
|
|
261
313
|
|
|
262
314
|
For [Claude Code](https://claude.com/claude-code) and other tools that follow the
|
|
263
315
|
[Agent Skills](https://docs.claude.com/en/docs/agents-and-tools/agent-skills/overview)
|
|
@@ -278,7 +330,7 @@ claude "Build a MarkdownUp application that plays tic-tac-toe against the user,
|
|
|
278
330
|
```
|
|
279
331
|
|
|
280
332
|
To run the resulting MarkdownUp application locally, install the
|
|
281
|
-
[markdown-up](https://
|
|
333
|
+
[markdown-up](https://github.com/craigahobbs/markdown-up-py#readme) viewer and point it at the Markdown file:
|
|
282
334
|
|
|
283
335
|
```
|
|
284
336
|
pip install markdown-up
|
|
@@ -30,6 +30,7 @@ execute_script(
|
|
|
30
30
|
{'url': 'markdown.bare', 'system': True},
|
|
31
31
|
{'url': 'markdownElements.bare', 'system': True},
|
|
32
32
|
{'url': 'markdownParser.bare', 'system': True},
|
|
33
|
+
{'url': 'markdownString.bare', 'system': True},
|
|
33
34
|
{'url': 'qrcode.bare', 'system': True},
|
|
34
35
|
{'url': 'schema.bare', 'system': True},
|
|
35
36
|
{'url': 'schemaDoc.bare', 'system': True},
|
|
@@ -499,6 +500,28 @@ def markdown_parse(text):
|
|
|
499
500
|
return _INCLUDE_GLOBALS['markdownParse']([text], _include_options())
|
|
500
501
|
|
|
501
502
|
|
|
503
|
+
#
|
|
504
|
+
# markdownString.bare
|
|
505
|
+
#
|
|
506
|
+
|
|
507
|
+
|
|
508
|
+
def markdown_to_string(markdown, wrap_width=None, ref_count=None):
|
|
509
|
+
"""
|
|
510
|
+
Render a Markdown model as Markdown text
|
|
511
|
+
|
|
512
|
+
:param dict markdown: The Markdown model
|
|
513
|
+
:param wrap_width: The text wrap width (default is 100). If zero or less, text is not wrapped.
|
|
514
|
+
:type wrap_width: int or None, optional
|
|
515
|
+
:param ref_count: The minimum number of occurrences of a link/image URL for which a link/image
|
|
516
|
+
reference is rendered (default is 0). If zero or less, all links/images are rendered inline.
|
|
517
|
+
:type ref_count: int or None, optional
|
|
518
|
+
:return: The Markdown text
|
|
519
|
+
:rtype: str
|
|
520
|
+
"""
|
|
521
|
+
|
|
522
|
+
return _INCLUDE_GLOBALS['markdownToString']([markdown, wrap_width, ref_count], _include_options())
|
|
523
|
+
|
|
524
|
+
|
|
502
525
|
#
|
|
503
526
|
# qrcode.bare
|
|
504
527
|
#
|