markdown-up 2.2.0__tar.gz → 2.3.0__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.
Files changed (24) hide show
  1. markdown_up-2.3.0/PKG-INFO +321 -0
  2. markdown_up-2.3.0/README.md +295 -0
  3. {markdown_up-2.2.0 → markdown_up-2.3.0}/setup.cfg +4 -3
  4. {markdown_up-2.2.0 → markdown_up-2.3.0}/src/markdown_up/__main__.py +1 -1
  5. markdown_up-2.3.0/src/markdown_up/api.py +158 -0
  6. {markdown_up-2.2.0 → markdown_up-2.3.0}/src/markdown_up/app.py +32 -18
  7. markdown_up-2.3.0/src/markdown_up/main.py +181 -0
  8. {markdown_up-2.2.0 → markdown_up-2.3.0}/src/markdown_up/static/markdownUpIndex.bare +1 -1
  9. markdown_up-2.3.0/src/markdown_up.egg-info/PKG-INFO +321 -0
  10. {markdown_up-2.2.0 → markdown_up-2.3.0}/src/markdown_up.egg-info/SOURCES.txt +1 -0
  11. markdown_up-2.3.0/src/markdown_up.egg-info/requires.txt +3 -0
  12. markdown_up-2.2.0/PKG-INFO +0 -150
  13. markdown_up-2.2.0/README.md +0 -125
  14. markdown_up-2.2.0/src/markdown_up/main.py +0 -89
  15. markdown_up-2.2.0/src/markdown_up.egg-info/PKG-INFO +0 -150
  16. markdown_up-2.2.0/src/markdown_up.egg-info/requires.txt +0 -2
  17. {markdown_up-2.2.0 → markdown_up-2.3.0}/LICENSE +0 -0
  18. {markdown_up-2.2.0 → markdown_up-2.3.0}/pyproject.toml +0 -0
  19. {markdown_up-2.2.0 → markdown_up-2.3.0}/src/markdown_up/__init__.py +0 -0
  20. {markdown_up-2.2.0 → markdown_up-2.3.0}/src/markdown_up/static/__init__.py +0 -0
  21. {markdown_up-2.2.0 → markdown_up-2.3.0}/src/markdown_up/static/index.html +0 -0
  22. {markdown_up-2.2.0 → markdown_up-2.3.0}/src/markdown_up.egg-info/dependency_links.txt +0 -0
  23. {markdown_up-2.2.0 → markdown_up-2.3.0}/src/markdown_up.egg-info/entry_points.txt +0 -0
  24. {markdown_up-2.2.0 → markdown_up-2.3.0}/src/markdown_up.egg-info/top_level.txt +0 -0
@@ -0,0 +1,321 @@
1
+ Metadata-Version: 2.4
2
+ Name: markdown-up
3
+ Version: 2.3.0
4
+ Summary: MarkdownUp is a Markdown viewer
5
+ Home-page: https://github.com/craigahobbs/markdown-up-py
6
+ Author: Craig A. Hobbs
7
+ Author-email: craigahobbs@gmail.com
8
+ License: MIT
9
+ Keywords: Markdown,viewer
10
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3.14
19
+ Classifier: Topic :: Utilities
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Requires-Dist: bare-script>=3.3.0
23
+ Requires-Dist: chisel>=1.6.0
24
+ Requires-Dist: waitress>=3.0.0
25
+ Dynamic: license-file
26
+
27
+ # markdown-up
28
+
29
+ [![PyPI - Status](https://img.shields.io/pypi/status/markdown-up)](https://pypi.org/project/markdown-up/)
30
+ [![PyPI](https://img.shields.io/pypi/v/markdown-up)](https://pypi.org/project/markdown-up/)
31
+ [![GitHub](https://img.shields.io/github/license/craigahobbs/markdown-up-py)](https://github.com/craigahobbs/markdown-up-py/blob/main/LICENSE)
32
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/markdown-up)](https://pypi.org/project/markdown-up/)
33
+
34
+ MarkdownUp is a Markdown viewer.
35
+
36
+
37
+ ## Install MarkdownUp
38
+
39
+ Use Python's `pip` to install MarkdownUp as follows:
40
+
41
+ ~~~
42
+ pip install markdown-up
43
+ ~~~
44
+
45
+
46
+ ## View Markdown Files
47
+
48
+ To start MarkdownUp, open a terminal and run the `markdown-up` application:
49
+
50
+ ~~~
51
+ markdown-up
52
+ ~~~
53
+
54
+ The `markdown-up` application opens the web browser to the MarkdownUp file browser, which allows you
55
+ to view Markdown or HTML files and navigate directories. To view a file, click on its link.
56
+
57
+ You can view a specific file as follows:
58
+
59
+ ~~~
60
+ markdown-up README.md
61
+ ~~~
62
+
63
+ **Note:** MarkdownUp runs entirely offline. It does not use an external service to render Markdown
64
+ files.
65
+
66
+
67
+ ## Running MarkdownUp
68
+
69
+ When you run the `markdown-up` application, in addition to opening the web browser, it starts a
70
+ [chisel](https://pypi.org/project/chisel/)
71
+ backend API application using
72
+ [waitress](https://pypi.org/project/waitress/).
73
+
74
+
75
+ ### Automatic HTML for Markdown Files
76
+
77
+ When you run MarkdownUp and click on a Markdown file link, the link navigates to an HTML file that
78
+ renders the Markdown file. Every Markdown file hosted by MarkdownUp has a corresponding `.html` file
79
+ of the same name. For example, if you run MarkdownUp in a directory that has the following Markdown
80
+ files: "README.md" and "CHANGELOG.md". The MarkdownUp service automatically generates "README.html"
81
+ and "CHANGELOG.html" files.
82
+
83
+ The generated `.html` files are HTML stubs for the
84
+ [MarkdownUp Front-End Application](https://github.com/craigahobbs/markdown-up#readme).
85
+ All Markdown parsing and rendering are done on the client.
86
+
87
+
88
+ ### Configuration File
89
+
90
+ The
91
+ [MarkdownUp Application Configuration File](https://craigahobbs.github.io/markdown-up-py/config.html#var.vName='MarkdownUpConfig'),
92
+ `markdown-up.json`, allows you to enable release mode, set the number of backend server threads, and more.
93
+
94
+
95
+ ### Command-Line Arguments
96
+
97
+ The `markdown-up` application has the following command-line arguments:
98
+
99
+ ```
100
+ usage: markdown-up [-h] [-p N] [-t N] [-n] [-r] [-q] [-d] [-v VAR EXPR] [-c FILE] [-a FILE] [path]
101
+
102
+ positional arguments:
103
+ path the file or directory to view (default is ".")
104
+
105
+ options:
106
+ -h, --help show this help message and exit
107
+ -p, --port N the application port (default is 8080)
108
+ -t, --threads N the number of web server threads (default is 8)
109
+ -n, --no-browser don't open a web browser
110
+ -r, --release release mode (cache statics, remove documentation and index)
111
+ -q, --quiet hide access logging
112
+ -d, --debug backend debug mode
113
+ -v, --var VAR EXPR set a backend global variable
114
+ -c, --config FILE the application config filename (default is "markdown-up.json")
115
+ -a, --api FILE the API config filename (default is "markdown-up-api.json")
116
+ ```
117
+
118
+
119
+ ## MarkdownUp Applications
120
+
121
+ With MarkdownUp, you can write client-rendered frontend applications and backend APIs using
122
+ [BareScript](https://craigahobbs.github.io/bare-script/language/).
123
+
124
+
125
+ ### MarkdownUp Frontend Applications
126
+
127
+ MarkdownUp frontend applications are created by adding `markdown-script` fenced code blocks containing
128
+ [BareScript](https://craigahobbs.github.io/bare-script/language/)
129
+ to a Markdown file and viewing it with the MarkdownUp frontend application. When the Markdown file
130
+ is rendered, the BareScript is executed and its results are rendered in place. For example:
131
+
132
+ ~~~markdown
133
+ # Frontend Hello World
134
+
135
+ ```markdown-script
136
+ markdownPrint('Hello, **World**!!')
137
+ ```
138
+ ~~~
139
+
140
+
141
+ #### MarkdownUp Frontend Reference
142
+
143
+ [The BareScript Language](https://craigahobbs.github.io/bare-script/language/)
144
+
145
+ [The MarkdownUp Library](https://craigahobbs.github.io/markdown-up/library/)
146
+
147
+ [The MarkdownUp Include Library](https://craigahobbs.github.io/markdown-up/library/include.html)
148
+
149
+ [MarkdownUp Frontend Examples](https://craigahobbs.github.io/#var.vPage='MarkdownUp')
150
+
151
+
152
+ ### MarkdownUp Backend APIs
153
+
154
+ MarkdownUp backend applications are created by adding a
155
+ [MarkdownUp Backend API Configuration File](https://craigahobbs.github.io/markdown-up-py/config.html#var.vName='MarkdownUpAPIConfig'),
156
+ `markdown-up-api.json`.
157
+
158
+ The `markdown-up-api.json` file specifies the following:
159
+
160
+ - The [Schema Markdown](https://craigahobbs.github.io/schema-markdown-js/language/) files containing
161
+ the API input and output schema definitions
162
+
163
+ - The [BareScript](https://craigahobbs.github.io/bare-script/language/) files containing the API
164
+ implementations
165
+
166
+
167
+ #### MarkdownUp Backend Reference
168
+
169
+ [MarkdownUp Backend API Configuration File](https://craigahobbs.github.io/markdown-up-py/config.html#var.vName='MarkdownUpAPIConfig')
170
+
171
+ [The BareScript Language](https://craigahobbs.github.io/bare-script/language/)
172
+
173
+ [The Schema Markdown Language](https://craigahobbs.github.io/schema-markdown-js/language/)
174
+
175
+ [The MarkdownUp Backend API Library](https://craigahobbs.github.io/markdown-up-py/api.html)
176
+
177
+
178
+ ### MarkdownUp Full Stack Application Example
179
+
180
+ In this simple full-stack application example, we'll create a MarkdownUp frontend application to
181
+ input two numbers and display their sum. We'll use a MarkdownUp backend API to sum the numbers.
182
+
183
+
184
+ **index.md**
185
+
186
+ The frontend application's index file, `index.md`, includes the application script and executes the
187
+ main entry point:
188
+
189
+ ~~~markdown
190
+ ```markdown-script
191
+ include 'example.bare'
192
+
193
+ exampleMain()
194
+ ```
195
+ ~~~
196
+
197
+
198
+ **example.bare**
199
+
200
+ The frontend application file, `example.bare`, uses the
201
+ [args.bare](https://craigahobbs.github.io/markdown-up/library/include.html#var.vGroup='args.bare')
202
+ include library to parse the application arguments. It then uses the `sumNumbers` API to sum the
203
+ numbers. Finally, it then renders the links to change the input numbers and the result.
204
+
205
+ ```barescript
206
+ include <args.bare>
207
+
208
+
209
+ # The example application main entry point
210
+ async function exampleMain():
211
+ args = argsParse(exampleArguments)
212
+ n1 = objectGet(args, 'n1')
213
+ n2 = objectGet(args, 'n2')
214
+
215
+ # Call the backend service to add the two numbers
216
+ sumResponseText = systemFetch(objectNew( \
217
+ 'url', 'sumNumbers', \
218
+ 'body', jsonStringify(objectNew('n1', n1, 'n2', n2)) \
219
+ ))
220
+ sumResponseJSON = if(sumResponseText, jsonParse(sumResponseText))
221
+ result = if(sumResponseJSON, objectGet(sumResponseJSON, 'result'))
222
+
223
+ # Render the page
224
+ title = 'Sum Two Numbers'
225
+ documentSetTitle(title)
226
+ markdownPrint( \
227
+ '# ' + markdownEscape(title), \
228
+ '', \
229
+ 'n1 = ' + n1 + ' (' + \
230
+ argsLink(exampleArguments, 'Down', objectNew('n1', n1 - 1)) + ' | ' + \
231
+ argsLink(exampleArguments, 'Up', objectNew('n1', n1 + 1)) + ')', \
232
+ '', \
233
+ 'n2 = ' + n2 + ' (' + \
234
+ argsLink(exampleArguments, 'Down', objectNew('n2', n2 - 1)) + ' | ' + \
235
+ argsLink(exampleArguments, 'Up', objectNew('n2', n2 + 1)) + ')', \
236
+ '', \
237
+ n1 + ' + ' + n2 + ' = ' + result \
238
+ )
239
+ endfunction
240
+
241
+
242
+ # The example application's arguments (for use with argsParse, etc.)
243
+ exampleArguments = arrayNew( \
244
+ objectNew('name', 'n1', 'type', 'float', 'default', 0), \
245
+ objectNew('name', 'n2', 'type', 'float', 'default', 0) \
246
+ )
247
+ ```
248
+
249
+
250
+ **markdown-up-api.json**
251
+
252
+ The
253
+ [MarkdownUp Backend API Configuration File](https://craigahobbs.github.io/markdown-up-py/config.html#var.vName='MarkdownUpAPIConfig'),
254
+ `markdown-up-api.json`, specifies the backend API:
255
+
256
+ ```json
257
+ {
258
+ "schemas": ["example.smd"],
259
+ "scripts": ["exampleAPI.bare"],
260
+ "apis": [
261
+ {"name": "sumNumbers"}
262
+ ]
263
+ }
264
+ ```
265
+
266
+
267
+ **example.smd**
268
+
269
+ The API input and output schemas are defined using
270
+ [Schema Markdown](https://craigahobbs.github.io/schema-markdown-js/language/).
271
+
272
+ ```schema-markdown
273
+ group "Example"
274
+
275
+
276
+ # Sum two numbers
277
+ action sumNumbers
278
+ input
279
+ # The first number
280
+ float n1
281
+
282
+ # The second number
283
+ float n2
284
+
285
+ output
286
+ # The sum of the two numbers
287
+ float result
288
+ ```
289
+
290
+
291
+ **exampleAPI.bare**
292
+
293
+ The backend API is implemented in [BareScript](https://craigahobbs.github.io/bare-script/language/).
294
+ By default, API implementation functions have the same name as the API schema definition. API
295
+ implementation functions take a single argument, `request`, that is the schema-validated input
296
+ object.
297
+
298
+ ```barescript
299
+ # Implementation of the sumNumbers API
300
+ function sumNumbers(request):
301
+ n1 = objectGet(request, 'n1')
302
+ n2 = objectGet(request, 'n2')
303
+ return objectNew('result', n1 + n2)
304
+ endfunction
305
+ ```
306
+
307
+ To run the application, run `markdown-up` in the directory containing the application files.
308
+
309
+ ```sh
310
+ markdown-up index.md
311
+ ```
312
+
313
+
314
+ ## Development
315
+
316
+ This package is developed using [python-build](https://github.com/craigahobbs/python-build#readme).
317
+ It was started using [python-template](https://github.com/craigahobbs/python-template#readme) as follows:
318
+
319
+ ~~~
320
+ template-specialize python-template/template/ markdown-up-py/ -k package markdown-up -k name 'Craig A. Hobbs' -k email 'craigahobbs@gmail.com' -k github 'craigahobbs' -k noapi 1
321
+ ~~~
@@ -0,0 +1,295 @@
1
+ # markdown-up
2
+
3
+ [![PyPI - Status](https://img.shields.io/pypi/status/markdown-up)](https://pypi.org/project/markdown-up/)
4
+ [![PyPI](https://img.shields.io/pypi/v/markdown-up)](https://pypi.org/project/markdown-up/)
5
+ [![GitHub](https://img.shields.io/github/license/craigahobbs/markdown-up-py)](https://github.com/craigahobbs/markdown-up-py/blob/main/LICENSE)
6
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/markdown-up)](https://pypi.org/project/markdown-up/)
7
+
8
+ MarkdownUp is a Markdown viewer.
9
+
10
+
11
+ ## Install MarkdownUp
12
+
13
+ Use Python's `pip` to install MarkdownUp as follows:
14
+
15
+ ~~~
16
+ pip install markdown-up
17
+ ~~~
18
+
19
+
20
+ ## View Markdown Files
21
+
22
+ To start MarkdownUp, open a terminal and run the `markdown-up` application:
23
+
24
+ ~~~
25
+ markdown-up
26
+ ~~~
27
+
28
+ The `markdown-up` application opens the web browser to the MarkdownUp file browser, which allows you
29
+ to view Markdown or HTML files and navigate directories. To view a file, click on its link.
30
+
31
+ You can view a specific file as follows:
32
+
33
+ ~~~
34
+ markdown-up README.md
35
+ ~~~
36
+
37
+ **Note:** MarkdownUp runs entirely offline. It does not use an external service to render Markdown
38
+ files.
39
+
40
+
41
+ ## Running MarkdownUp
42
+
43
+ When you run the `markdown-up` application, in addition to opening the web browser, it starts a
44
+ [chisel](https://pypi.org/project/chisel/)
45
+ backend API application using
46
+ [waitress](https://pypi.org/project/waitress/).
47
+
48
+
49
+ ### Automatic HTML for Markdown Files
50
+
51
+ When you run MarkdownUp and click on a Markdown file link, the link navigates to an HTML file that
52
+ renders the Markdown file. Every Markdown file hosted by MarkdownUp has a corresponding `.html` file
53
+ of the same name. For example, if you run MarkdownUp in a directory that has the following Markdown
54
+ files: "README.md" and "CHANGELOG.md". The MarkdownUp service automatically generates "README.html"
55
+ and "CHANGELOG.html" files.
56
+
57
+ The generated `.html` files are HTML stubs for the
58
+ [MarkdownUp Front-End Application](https://github.com/craigahobbs/markdown-up#readme).
59
+ All Markdown parsing and rendering are done on the client.
60
+
61
+
62
+ ### Configuration File
63
+
64
+ The
65
+ [MarkdownUp Application Configuration File](https://craigahobbs.github.io/markdown-up-py/config.html#var.vName='MarkdownUpConfig'),
66
+ `markdown-up.json`, allows you to enable release mode, set the number of backend server threads, and more.
67
+
68
+
69
+ ### Command-Line Arguments
70
+
71
+ The `markdown-up` application has the following command-line arguments:
72
+
73
+ ```
74
+ usage: markdown-up [-h] [-p N] [-t N] [-n] [-r] [-q] [-d] [-v VAR EXPR] [-c FILE] [-a FILE] [path]
75
+
76
+ positional arguments:
77
+ path the file or directory to view (default is ".")
78
+
79
+ options:
80
+ -h, --help show this help message and exit
81
+ -p, --port N the application port (default is 8080)
82
+ -t, --threads N the number of web server threads (default is 8)
83
+ -n, --no-browser don't open a web browser
84
+ -r, --release release mode (cache statics, remove documentation and index)
85
+ -q, --quiet hide access logging
86
+ -d, --debug backend debug mode
87
+ -v, --var VAR EXPR set a backend global variable
88
+ -c, --config FILE the application config filename (default is "markdown-up.json")
89
+ -a, --api FILE the API config filename (default is "markdown-up-api.json")
90
+ ```
91
+
92
+
93
+ ## MarkdownUp Applications
94
+
95
+ With MarkdownUp, you can write client-rendered frontend applications and backend APIs using
96
+ [BareScript](https://craigahobbs.github.io/bare-script/language/).
97
+
98
+
99
+ ### MarkdownUp Frontend Applications
100
+
101
+ MarkdownUp frontend applications are created by adding `markdown-script` fenced code blocks containing
102
+ [BareScript](https://craigahobbs.github.io/bare-script/language/)
103
+ to a Markdown file and viewing it with the MarkdownUp frontend application. When the Markdown file
104
+ is rendered, the BareScript is executed and its results are rendered in place. For example:
105
+
106
+ ~~~markdown
107
+ # Frontend Hello World
108
+
109
+ ```markdown-script
110
+ markdownPrint('Hello, **World**!!')
111
+ ```
112
+ ~~~
113
+
114
+
115
+ #### MarkdownUp Frontend Reference
116
+
117
+ [The BareScript Language](https://craigahobbs.github.io/bare-script/language/)
118
+
119
+ [The MarkdownUp Library](https://craigahobbs.github.io/markdown-up/library/)
120
+
121
+ [The MarkdownUp Include Library](https://craigahobbs.github.io/markdown-up/library/include.html)
122
+
123
+ [MarkdownUp Frontend Examples](https://craigahobbs.github.io/#var.vPage='MarkdownUp')
124
+
125
+
126
+ ### MarkdownUp Backend APIs
127
+
128
+ MarkdownUp backend applications are created by adding a
129
+ [MarkdownUp Backend API Configuration File](https://craigahobbs.github.io/markdown-up-py/config.html#var.vName='MarkdownUpAPIConfig'),
130
+ `markdown-up-api.json`.
131
+
132
+ The `markdown-up-api.json` file specifies the following:
133
+
134
+ - The [Schema Markdown](https://craigahobbs.github.io/schema-markdown-js/language/) files containing
135
+ the API input and output schema definitions
136
+
137
+ - The [BareScript](https://craigahobbs.github.io/bare-script/language/) files containing the API
138
+ implementations
139
+
140
+
141
+ #### MarkdownUp Backend Reference
142
+
143
+ [MarkdownUp Backend API Configuration File](https://craigahobbs.github.io/markdown-up-py/config.html#var.vName='MarkdownUpAPIConfig')
144
+
145
+ [The BareScript Language](https://craigahobbs.github.io/bare-script/language/)
146
+
147
+ [The Schema Markdown Language](https://craigahobbs.github.io/schema-markdown-js/language/)
148
+
149
+ [The MarkdownUp Backend API Library](https://craigahobbs.github.io/markdown-up-py/api.html)
150
+
151
+
152
+ ### MarkdownUp Full Stack Application Example
153
+
154
+ In this simple full-stack application example, we'll create a MarkdownUp frontend application to
155
+ input two numbers and display their sum. We'll use a MarkdownUp backend API to sum the numbers.
156
+
157
+
158
+ **index.md**
159
+
160
+ The frontend application's index file, `index.md`, includes the application script and executes the
161
+ main entry point:
162
+
163
+ ~~~markdown
164
+ ```markdown-script
165
+ include 'example.bare'
166
+
167
+ exampleMain()
168
+ ```
169
+ ~~~
170
+
171
+
172
+ **example.bare**
173
+
174
+ The frontend application file, `example.bare`, uses the
175
+ [args.bare](https://craigahobbs.github.io/markdown-up/library/include.html#var.vGroup='args.bare')
176
+ include library to parse the application arguments. It then uses the `sumNumbers` API to sum the
177
+ numbers. Finally, it then renders the links to change the input numbers and the result.
178
+
179
+ ```barescript
180
+ include <args.bare>
181
+
182
+
183
+ # The example application main entry point
184
+ async function exampleMain():
185
+ args = argsParse(exampleArguments)
186
+ n1 = objectGet(args, 'n1')
187
+ n2 = objectGet(args, 'n2')
188
+
189
+ # Call the backend service to add the two numbers
190
+ sumResponseText = systemFetch(objectNew( \
191
+ 'url', 'sumNumbers', \
192
+ 'body', jsonStringify(objectNew('n1', n1, 'n2', n2)) \
193
+ ))
194
+ sumResponseJSON = if(sumResponseText, jsonParse(sumResponseText))
195
+ result = if(sumResponseJSON, objectGet(sumResponseJSON, 'result'))
196
+
197
+ # Render the page
198
+ title = 'Sum Two Numbers'
199
+ documentSetTitle(title)
200
+ markdownPrint( \
201
+ '# ' + markdownEscape(title), \
202
+ '', \
203
+ 'n1 = ' + n1 + ' (' + \
204
+ argsLink(exampleArguments, 'Down', objectNew('n1', n1 - 1)) + ' | ' + \
205
+ argsLink(exampleArguments, 'Up', objectNew('n1', n1 + 1)) + ')', \
206
+ '', \
207
+ 'n2 = ' + n2 + ' (' + \
208
+ argsLink(exampleArguments, 'Down', objectNew('n2', n2 - 1)) + ' | ' + \
209
+ argsLink(exampleArguments, 'Up', objectNew('n2', n2 + 1)) + ')', \
210
+ '', \
211
+ n1 + ' + ' + n2 + ' = ' + result \
212
+ )
213
+ endfunction
214
+
215
+
216
+ # The example application's arguments (for use with argsParse, etc.)
217
+ exampleArguments = arrayNew( \
218
+ objectNew('name', 'n1', 'type', 'float', 'default', 0), \
219
+ objectNew('name', 'n2', 'type', 'float', 'default', 0) \
220
+ )
221
+ ```
222
+
223
+
224
+ **markdown-up-api.json**
225
+
226
+ The
227
+ [MarkdownUp Backend API Configuration File](https://craigahobbs.github.io/markdown-up-py/config.html#var.vName='MarkdownUpAPIConfig'),
228
+ `markdown-up-api.json`, specifies the backend API:
229
+
230
+ ```json
231
+ {
232
+ "schemas": ["example.smd"],
233
+ "scripts": ["exampleAPI.bare"],
234
+ "apis": [
235
+ {"name": "sumNumbers"}
236
+ ]
237
+ }
238
+ ```
239
+
240
+
241
+ **example.smd**
242
+
243
+ The API input and output schemas are defined using
244
+ [Schema Markdown](https://craigahobbs.github.io/schema-markdown-js/language/).
245
+
246
+ ```schema-markdown
247
+ group "Example"
248
+
249
+
250
+ # Sum two numbers
251
+ action sumNumbers
252
+ input
253
+ # The first number
254
+ float n1
255
+
256
+ # The second number
257
+ float n2
258
+
259
+ output
260
+ # The sum of the two numbers
261
+ float result
262
+ ```
263
+
264
+
265
+ **exampleAPI.bare**
266
+
267
+ The backend API is implemented in [BareScript](https://craigahobbs.github.io/bare-script/language/).
268
+ By default, API implementation functions have the same name as the API schema definition. API
269
+ implementation functions take a single argument, `request`, that is the schema-validated input
270
+ object.
271
+
272
+ ```barescript
273
+ # Implementation of the sumNumbers API
274
+ function sumNumbers(request):
275
+ n1 = objectGet(request, 'n1')
276
+ n2 = objectGet(request, 'n2')
277
+ return objectNew('result', n1 + n2)
278
+ endfunction
279
+ ```
280
+
281
+ To run the application, run `markdown-up` in the directory containing the application files.
282
+
283
+ ```sh
284
+ markdown-up index.md
285
+ ```
286
+
287
+
288
+ ## Development
289
+
290
+ This package is developed using [python-build](https://github.com/craigahobbs/python-build#readme).
291
+ It was started using [python-template](https://github.com/craigahobbs/python-template#readme) as follows:
292
+
293
+ ~~~
294
+ template-specialize python-template/template/ markdown-up-py/ -k package markdown-up -k name 'Craig A. Hobbs' -k email 'craigahobbs@gmail.com' -k github 'craigahobbs' -k noapi 1
295
+ ~~~
@@ -1,11 +1,11 @@
1
1
  [metadata]
2
2
  name = markdown-up
3
- version = 2.2.0
3
+ version = 2.3.0
4
4
  url = https://github.com/craigahobbs/markdown-up-py
5
5
  author = Craig A. Hobbs
6
6
  author_email = craigahobbs@gmail.com
7
7
  license = MIT
8
- description = The MarkdownUp launcher
8
+ description = MarkdownUp is a Markdown viewer
9
9
  long_description = file:README.md
10
10
  long_description_content_type = text/markdown
11
11
  keywords = Markdown, viewer
@@ -26,7 +26,8 @@ packages = markdown_up, markdown_up.static
26
26
  package_dir =
27
27
  = src
28
28
  install_requires =
29
- chisel >= 1.5.0
29
+ bare-script >= 3.3.0
30
+ chisel >= 1.6.0
30
31
  waitress >= 3.0.0
31
32
 
32
33
  [options.entry_points]
@@ -2,7 +2,7 @@
2
2
  # https://github.com/craigahobbs/markdown-up-py/blob/main/LICENSE
3
3
 
4
4
  """
5
- The MarkdownUp launcher command-line application stub
5
+ The MarkdownUp backend command-line application stub
6
6
  """
7
7
 
8
8
  from .main import main