markdown-up 3.3.1__tar.gz → 3.3.3__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: markdown-up
3
- Version: 3.3.1
3
+ Version: 3.3.3
4
4
  Summary: MarkdownUp is a Markdown viewer
5
5
  Author-email: "Craig A. Hobbs" <craigahobbs@gmail.com>
6
6
  License-Expression: MIT
@@ -30,7 +30,13 @@ Dynamic: license-file
30
30
  [![GitHub](https://img.shields.io/github/license/craigahobbs/markdown-up-py)](https://github.com/craigahobbs/markdown-up-py/blob/main/LICENSE)
31
31
  [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/markdown-up)](https://pypi.org/project/markdown-up/)
32
32
 
33
- MarkdownUp is a Markdown viewer.
33
+ MarkdownUp is a Markdown viewer. This is the MarkdownUp backend application.
34
+
35
+
36
+ ## Links
37
+
38
+ - [MarkdownUp Frontend](https://github.com/craigahobbs/markdown-up#readme)
39
+ - [Source code](https://github.com/craigahobbs/markdown-up-py)
34
40
 
35
41
 
36
42
  ## Install MarkdownUp
@@ -42,7 +48,7 @@ pip install markdown-up
42
48
  ~~~
43
49
 
44
50
 
45
- ## View Markdown Files
51
+ ## View Local Markdown Files
46
52
 
47
53
  To start MarkdownUp, open a terminal and run the `markdown-up` application:
48
54
 
@@ -84,64 +90,54 @@ The generated `.html` files are HTML stubs for the
84
90
  All Markdown parsing and rendering are done on the client.
85
91
 
86
92
 
87
- ### Configuration File
88
-
89
- The
90
- [MarkdownUp Application Configuration File](https://craigahobbs.github.io/markdown-up-py/config.html#var.vName='MarkdownUpConfig'),
91
- `markdown-up.json`, allows you to enable release mode, set the number of backend server threads, and more.
92
-
93
-
94
93
  ### Command-Line Arguments
95
94
 
96
95
  The `markdown-up` application has the following command-line arguments:
97
96
 
98
97
  ```
99
- usage: markdown-up [-h] [-p N] [-t N] [-n] [-r] [-q] [-c FILE] [path]
98
+ usage: markdown-up [-h] [--host HOST] [-p N] [-t N] [-n] [-r] [-q] [path]
100
99
 
101
100
  positional arguments:
102
101
  path the file or directory to view (default is ".")
103
102
 
104
103
  options:
105
104
  -h, --help show this help message and exit
105
+ --host HOST the host address to bind (default is "127.0.0.1"; "0.0.0.0" in release mode)
106
106
  -p, --port N the application port (default is 8080)
107
107
  -t, --threads N the number of web server threads (default is 8)
108
108
  -n, --no-browser don't open a web browser
109
109
  -r, --release release mode (cache statics, remove documentation and index)
110
110
  -q, --quiet hide access logging
111
- -c, --config FILE the application config filename (default is "markdown-up.json")
112
111
  ```
113
112
 
114
113
 
115
114
  ## MarkdownUp Applications
116
115
 
117
- With MarkdownUp, you can write client-rendered frontend applications using
118
- [BareScript](https://craigahobbs.github.io/bare-script/language/).
119
- MarkdownUp applications are created by adding `markdown-script` fenced code blocks containing
120
- [BareScript](https://craigahobbs.github.io/bare-script/language/)
121
- to a Markdown file and viewing it with the MarkdownUp frontend application. When the Markdown file
122
- is rendered, the BareScript is executed and its results are rendered in place. For example:
116
+ MarkdownUp applications are Markdown files that contain code. Add a `markdown-script` fenced code
117
+ block of [BareScript](https://craigahobbs.github.io/bare-script/language/) to any Markdown file, and
118
+ when MarkdownUp renders the file, it runs the script and renders its output in place of the code
119
+ block. For example:
123
120
 
124
121
  ~~~markdown
125
- # Frontend Hello World
122
+ # Hello World
126
123
 
127
124
  ```markdown-script
128
125
  markdownPrint('Hello, **World**!!')
129
126
  ```
130
127
  ~~~
131
128
 
129
+ Applications run entirely in the browser, so no server-side code is required. Use the following
130
+ resources to learn more:
132
131
 
133
- ### MarkdownUp Application Reference
134
-
135
- [The BareScript Language](https://craigahobbs.github.io/bare-script/language/)
136
-
137
- [The BareScript Library](https://craigahobbs.github.io/bare-script/library/)
138
-
139
- [MarkdownUp Frontend Examples](https://craigahobbs.github.io/#var.vPage='MarkdownUp')
132
+ - [The BareScript Language](https://craigahobbs.github.io/bare-script/language/)
133
+ - [The BareScript Library](https://craigahobbs.github.io/bare-script/library/)
134
+ - [MarkdownUp Application Examples](https://craigahobbs.github.io/#var.vPage='MarkdownUp')
135
+ - [The BareScript Creator](https://craigahobbs.github.io/bare-script-py/creator/)
140
136
 
141
137
 
142
- ### MarkdownUp Backend Applications
138
+ ### Backend Applications
143
139
 
144
- MarkdownUp no longer hosts BareScript backend APIs. To write a backend application in BareScript, use the
140
+ To write a backend application in BareScript, use the
145
141
  [bare-script](https://pypi.org/project/bare-script/) package's
146
142
  [WSGI support](https://craigahobbs.github.io/bare-script-py/wsgi.html).
147
143
 
@@ -5,7 +5,13 @@
5
5
  [![GitHub](https://img.shields.io/github/license/craigahobbs/markdown-up-py)](https://github.com/craigahobbs/markdown-up-py/blob/main/LICENSE)
6
6
  [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/markdown-up)](https://pypi.org/project/markdown-up/)
7
7
 
8
- MarkdownUp is a Markdown viewer.
8
+ MarkdownUp is a Markdown viewer. This is the MarkdownUp backend application.
9
+
10
+
11
+ ## Links
12
+
13
+ - [MarkdownUp Frontend](https://github.com/craigahobbs/markdown-up#readme)
14
+ - [Source code](https://github.com/craigahobbs/markdown-up-py)
9
15
 
10
16
 
11
17
  ## Install MarkdownUp
@@ -17,7 +23,7 @@ pip install markdown-up
17
23
  ~~~
18
24
 
19
25
 
20
- ## View Markdown Files
26
+ ## View Local Markdown Files
21
27
 
22
28
  To start MarkdownUp, open a terminal and run the `markdown-up` application:
23
29
 
@@ -59,64 +65,54 @@ The generated `.html` files are HTML stubs for the
59
65
  All Markdown parsing and rendering are done on the client.
60
66
 
61
67
 
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
68
  ### Command-Line Arguments
70
69
 
71
70
  The `markdown-up` application has the following command-line arguments:
72
71
 
73
72
  ```
74
- usage: markdown-up [-h] [-p N] [-t N] [-n] [-r] [-q] [-c FILE] [path]
73
+ usage: markdown-up [-h] [--host HOST] [-p N] [-t N] [-n] [-r] [-q] [path]
75
74
 
76
75
  positional arguments:
77
76
  path the file or directory to view (default is ".")
78
77
 
79
78
  options:
80
79
  -h, --help show this help message and exit
80
+ --host HOST the host address to bind (default is "127.0.0.1"; "0.0.0.0" in release mode)
81
81
  -p, --port N the application port (default is 8080)
82
82
  -t, --threads N the number of web server threads (default is 8)
83
83
  -n, --no-browser don't open a web browser
84
84
  -r, --release release mode (cache statics, remove documentation and index)
85
85
  -q, --quiet hide access logging
86
- -c, --config FILE the application config filename (default is "markdown-up.json")
87
86
  ```
88
87
 
89
88
 
90
89
  ## MarkdownUp Applications
91
90
 
92
- With MarkdownUp, you can write client-rendered frontend applications using
93
- [BareScript](https://craigahobbs.github.io/bare-script/language/).
94
- MarkdownUp applications are created by adding `markdown-script` fenced code blocks containing
95
- [BareScript](https://craigahobbs.github.io/bare-script/language/)
96
- to a Markdown file and viewing it with the MarkdownUp frontend application. When the Markdown file
97
- is rendered, the BareScript is executed and its results are rendered in place. For example:
91
+ MarkdownUp applications are Markdown files that contain code. Add a `markdown-script` fenced code
92
+ block of [BareScript](https://craigahobbs.github.io/bare-script/language/) to any Markdown file, and
93
+ when MarkdownUp renders the file, it runs the script and renders its output in place of the code
94
+ block. For example:
98
95
 
99
96
  ~~~markdown
100
- # Frontend Hello World
97
+ # Hello World
101
98
 
102
99
  ```markdown-script
103
100
  markdownPrint('Hello, **World**!!')
104
101
  ```
105
102
  ~~~
106
103
 
104
+ Applications run entirely in the browser, so no server-side code is required. Use the following
105
+ resources to learn more:
107
106
 
108
- ### MarkdownUp Application Reference
109
-
110
- [The BareScript Language](https://craigahobbs.github.io/bare-script/language/)
111
-
112
- [The BareScript Library](https://craigahobbs.github.io/bare-script/library/)
113
-
114
- [MarkdownUp Frontend Examples](https://craigahobbs.github.io/#var.vPage='MarkdownUp')
107
+ - [The BareScript Language](https://craigahobbs.github.io/bare-script/language/)
108
+ - [The BareScript Library](https://craigahobbs.github.io/bare-script/library/)
109
+ - [MarkdownUp Application Examples](https://craigahobbs.github.io/#var.vPage='MarkdownUp')
110
+ - [The BareScript Creator](https://craigahobbs.github.io/bare-script-py/creator/)
115
111
 
116
112
 
117
- ### MarkdownUp Backend Applications
113
+ ### Backend Applications
118
114
 
119
- MarkdownUp no longer hosts BareScript backend APIs. To write a backend application in BareScript, use the
115
+ To write a backend application in BareScript, use the
120
116
  [bare-script](https://pypi.org/project/bare-script/) package's
121
117
  [WSGI support](https://craigahobbs.github.io/bare-script-py/wsgi.html).
122
118
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "markdown-up"
7
- version = "3.3.1"
7
+ version = "3.3.3"
8
8
  description = "MarkdownUp is a Markdown viewer"
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -22,10 +22,10 @@ class MarkdownUpApplication(chisel.Application):
22
22
  __slots__ = ('root', 'release', 'add_request_lock')
23
23
 
24
24
 
25
- def __init__(self, root, config=None):
25
+ def __init__(self, root, release=False):
26
26
  super().__init__()
27
27
  self.root = root
28
- self.release = config.get('release', False) if config else False
28
+ self.release = release
29
29
  self.add_request_lock = threading.Lock()
30
30
 
31
31
  # Release mode?
@@ -7,13 +7,11 @@ The MarkdownUp backend command-line application
7
7
 
8
8
  import argparse
9
9
  from functools import partial
10
- import json
11
10
  import os
12
11
  import sys
13
12
  import threading
14
13
  import webbrowser
15
14
 
16
- from schema_markdown import parse_schema_markdown, validate_type
17
15
  import waitress
18
16
 
19
17
  from .app import HTML_EXTS, MARKDOWN_EXTS, MarkdownUpApplication
@@ -31,18 +29,18 @@ def main(argv=None):
31
29
  parser = argparse.ArgumentParser(**argument_parser_args)
32
30
  parser.add_argument('path', nargs='?', default='.',
33
31
  help='the file or directory to view (default is ".")')
32
+ parser.add_argument('--host', metavar='HOST',
33
+ help='the host address to bind (default is "127.0.0.1"; "0.0.0.0" in release mode)')
34
34
  parser.add_argument('-p', '--port', metavar='N', type=int, default=8080,
35
35
  help='the application port (default is 8080)')
36
- parser.add_argument('-t', '--threads', metavar='N', type=int,
36
+ parser.add_argument('-t', '--threads', metavar='N', type=int, default=8,
37
37
  help='the number of web server threads (default is 8)')
38
38
  parser.add_argument('-n', '--no-browser', action='store_true',
39
39
  help="don't open a web browser")
40
- parser.add_argument('-r', '--release', action='store_true', default=None,
40
+ parser.add_argument('-r', '--release', action='store_true',
41
41
  help="release mode (cache statics, remove documentation and index)")
42
42
  parser.add_argument('-q', '--quiet', action='store_true',
43
43
  help="hide access logging")
44
- parser.add_argument('-c', '--config', metavar='FILE', default='markdown-up.json',
45
- help='the application config filename (default is "markdown-up.json")')
46
44
  args = parser.parse_args(args=argv)
47
45
 
48
46
  # Verify the path exists
@@ -61,20 +59,13 @@ def main(argv=None):
61
59
  if root == '':
62
60
  root = '.'
63
61
 
64
- # Load and validate the configuration file
65
- config_path = os.path.normpath(os.path.join(root, args.config))
66
- if os.path.isfile(config_path):
67
- with open(config_path, 'r', encoding='utf-8') as config_file:
68
- config = validate_type(CONFIG_TYPES, 'MarkdownUpConfig', json.load(config_file))
69
- else:
70
- config = {}
71
-
72
- # Add arguments to the config
73
- config['release'] = args.release if args.release is not None else config.get('release', False)
74
- config['threads'] = max(1, args.threads if args.threads is not None else config.get('threads', 8))
62
+ # Determine the host address to bind. By default, only release mode is reachable from other machines.
63
+ bind_host = args.host or ('0.0.0.0' if args.release else '127.0.0.1')
75
64
 
76
- # Construct the URL
77
- host = '127.0.0.1'
65
+ # Construct the URL - an any-address bind is viewed at its loopback address
66
+ host = {'0.0.0.0': '127.0.0.1', '::': '::1'}.get(bind_host, bind_host)
67
+ if ':' in host:
68
+ host = f'[{host}]'
78
69
  if is_file:
79
70
  path_base = os.path.basename(args.path)
80
71
  path_root, path_ext = os.path.splitext(path_base)
@@ -86,19 +77,19 @@ def main(argv=None):
86
77
  url = f'http://{host}:{args.port}/'
87
78
 
88
79
  # Launch the web browser on a thread so the WSGI application can startup first
89
- if not config['release'] and not args.no_browser:
80
+ if not args.release and not args.no_browser:
90
81
  webbrowser_thread = threading.Thread(target=webbrowser.open, args=(url,))
91
82
  webbrowser_thread.daemon = True
92
83
  webbrowser_thread.start()
93
84
 
94
85
  # Create the WSGI application
95
- wsgiapp = MarkdownUpApplication(root, config)
86
+ wsgiapp = MarkdownUpApplication(root, release=args.release)
96
87
  wsgiapp_wrap = wsgiapp if args.quiet else partial(_wsgiapp_log_access, wsgiapp)
97
88
 
98
89
  # Host the application
99
90
  if not args.quiet:
100
91
  print(f'markdown-up: Serving at {url} ...')
101
- waitress.serve(wsgiapp_wrap, port=args.port, threads=config['threads'])
92
+ waitress.serve(wsgiapp_wrap, host=bind_host, port=args.port, threads=max(1, args.threads))
102
93
 
103
94
 
104
95
  # WSGI application wrapper and the start_response function so we can log status and environ
@@ -108,19 +99,3 @@ def _wsgiapp_log_access(wsgiapp, environ, start_response):
108
99
  print(f'markdown-up: {status[0:3]} {environ["REQUEST_METHOD"]} {environ["PATH_INFO"]}{query_string}')
109
100
  return start_response(status, response_headers)
110
101
  return wsgiapp(environ, log_start_response)
111
-
112
-
113
- # The backend configuration schema
114
- CONFIG_TYPES = parse_schema_markdown('''\
115
- group "Application Configuration"
116
-
117
-
118
- # The MarkdownUp application configuration (e.g. `markdown-up.json`)
119
- struct MarkdownUpConfig
120
-
121
- # If true, run in release mode. Default is false.
122
- optional bool release
123
-
124
- # The number of backend server threads. Default is 8.
125
- optional int threads
126
- ''')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: markdown-up
3
- Version: 3.3.1
3
+ Version: 3.3.3
4
4
  Summary: MarkdownUp is a Markdown viewer
5
5
  Author-email: "Craig A. Hobbs" <craigahobbs@gmail.com>
6
6
  License-Expression: MIT
@@ -30,7 +30,13 @@ Dynamic: license-file
30
30
  [![GitHub](https://img.shields.io/github/license/craigahobbs/markdown-up-py)](https://github.com/craigahobbs/markdown-up-py/blob/main/LICENSE)
31
31
  [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/markdown-up)](https://pypi.org/project/markdown-up/)
32
32
 
33
- MarkdownUp is a Markdown viewer.
33
+ MarkdownUp is a Markdown viewer. This is the MarkdownUp backend application.
34
+
35
+
36
+ ## Links
37
+
38
+ - [MarkdownUp Frontend](https://github.com/craigahobbs/markdown-up#readme)
39
+ - [Source code](https://github.com/craigahobbs/markdown-up-py)
34
40
 
35
41
 
36
42
  ## Install MarkdownUp
@@ -42,7 +48,7 @@ pip install markdown-up
42
48
  ~~~
43
49
 
44
50
 
45
- ## View Markdown Files
51
+ ## View Local Markdown Files
46
52
 
47
53
  To start MarkdownUp, open a terminal and run the `markdown-up` application:
48
54
 
@@ -84,64 +90,54 @@ The generated `.html` files are HTML stubs for the
84
90
  All Markdown parsing and rendering are done on the client.
85
91
 
86
92
 
87
- ### Configuration File
88
-
89
- The
90
- [MarkdownUp Application Configuration File](https://craigahobbs.github.io/markdown-up-py/config.html#var.vName='MarkdownUpConfig'),
91
- `markdown-up.json`, allows you to enable release mode, set the number of backend server threads, and more.
92
-
93
-
94
93
  ### Command-Line Arguments
95
94
 
96
95
  The `markdown-up` application has the following command-line arguments:
97
96
 
98
97
  ```
99
- usage: markdown-up [-h] [-p N] [-t N] [-n] [-r] [-q] [-c FILE] [path]
98
+ usage: markdown-up [-h] [--host HOST] [-p N] [-t N] [-n] [-r] [-q] [path]
100
99
 
101
100
  positional arguments:
102
101
  path the file or directory to view (default is ".")
103
102
 
104
103
  options:
105
104
  -h, --help show this help message and exit
105
+ --host HOST the host address to bind (default is "127.0.0.1"; "0.0.0.0" in release mode)
106
106
  -p, --port N the application port (default is 8080)
107
107
  -t, --threads N the number of web server threads (default is 8)
108
108
  -n, --no-browser don't open a web browser
109
109
  -r, --release release mode (cache statics, remove documentation and index)
110
110
  -q, --quiet hide access logging
111
- -c, --config FILE the application config filename (default is "markdown-up.json")
112
111
  ```
113
112
 
114
113
 
115
114
  ## MarkdownUp Applications
116
115
 
117
- With MarkdownUp, you can write client-rendered frontend applications using
118
- [BareScript](https://craigahobbs.github.io/bare-script/language/).
119
- MarkdownUp applications are created by adding `markdown-script` fenced code blocks containing
120
- [BareScript](https://craigahobbs.github.io/bare-script/language/)
121
- to a Markdown file and viewing it with the MarkdownUp frontend application. When the Markdown file
122
- is rendered, the BareScript is executed and its results are rendered in place. For example:
116
+ MarkdownUp applications are Markdown files that contain code. Add a `markdown-script` fenced code
117
+ block of [BareScript](https://craigahobbs.github.io/bare-script/language/) to any Markdown file, and
118
+ when MarkdownUp renders the file, it runs the script and renders its output in place of the code
119
+ block. For example:
123
120
 
124
121
  ~~~markdown
125
- # Frontend Hello World
122
+ # Hello World
126
123
 
127
124
  ```markdown-script
128
125
  markdownPrint('Hello, **World**!!')
129
126
  ```
130
127
  ~~~
131
128
 
129
+ Applications run entirely in the browser, so no server-side code is required. Use the following
130
+ resources to learn more:
132
131
 
133
- ### MarkdownUp Application Reference
134
-
135
- [The BareScript Language](https://craigahobbs.github.io/bare-script/language/)
136
-
137
- [The BareScript Library](https://craigahobbs.github.io/bare-script/library/)
138
-
139
- [MarkdownUp Frontend Examples](https://craigahobbs.github.io/#var.vPage='MarkdownUp')
132
+ - [The BareScript Language](https://craigahobbs.github.io/bare-script/language/)
133
+ - [The BareScript Library](https://craigahobbs.github.io/bare-script/library/)
134
+ - [MarkdownUp Application Examples](https://craigahobbs.github.io/#var.vPage='MarkdownUp')
135
+ - [The BareScript Creator](https://craigahobbs.github.io/bare-script-py/creator/)
140
136
 
141
137
 
142
- ### MarkdownUp Backend Applications
138
+ ### Backend Applications
143
139
 
144
- MarkdownUp no longer hosts BareScript backend APIs. To write a backend application in BareScript, use the
140
+ To write a backend application in BareScript, use the
145
141
  [bare-script](https://pypi.org/project/bare-script/) package's
146
142
  [WSGI support](https://craigahobbs.github.io/bare-script-py/wsgi.html).
147
143
 
File without changes
File without changes