markdown-site-utils 0.2.2__tar.gz → 0.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.
@@ -0,0 +1,139 @@
1
+ Metadata-Version: 2.4
2
+ Name: markdown-site-utils
3
+ Version: 0.3.0
4
+ Summary: Some utilities for managing Markdown files with metadata.
5
+ Author: Jacob Smullyan
6
+ Author-email: Jacob Smullyan <smulloni@smullyan.org>
7
+ License-Expression: MIT
8
+ License-File: LICENSE
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3 :: Only
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Classifier: Programming Language :: Python :: 3.14
15
+ Classifier: Programming Language :: Python :: 3.15
16
+ Requires-Dist: markupsafe>=2.1.2
17
+ Requires-Dist: pyyaml>=6.0
18
+ Requires-Dist: markdown2>=2.5.1
19
+ Requires-Python: >=3.11
20
+ Project-URL: Repository, https://github.com/smulloni/markdown_site_utils
21
+ Description-Content-Type: text/markdown
22
+
23
+ # Markdown Site Utils
24
+
25
+ Some utilities for managing Markdown files with metadata.
26
+
27
+ Requires Python 3.11 or later; tested on Python 3.11 through 3.15.
28
+
29
+ ## Installation
30
+
31
+ pip install markdown-site-utils
32
+
33
+ or, in a uv-managed project:
34
+
35
+ uv add markdown-site-utils
36
+
37
+ ## Overview
38
+
39
+ The notion is that a content-oriented website may be written as a
40
+ hierarchical series of Markdown files (with an ".md" extension) underneath
41
+ some data directory, e.g.:
42
+
43
+ DATA_DIR/
44
+ index.md
45
+ foo.md
46
+ bar.md
47
+ subdir/
48
+ index.md
49
+ foo.md
50
+ bar.md
51
+
52
+ Each file may contain metadata, written in TOML in a section at
53
+ the top, bounded by '+++' lines:
54
+
55
+ +++
56
+ title = "My Page Title"
57
+ +++
58
+
59
+ # Some Markdown
60
+
61
+ YAML and JSON may also be used. YAML blocks should start and end with lines
62
+ consisting of three dashes; JSON blocks should consist of a single JSON object
63
+ with opening and closing braces on lines by themselves. The data block is optional
64
+ but if present must begin on the first line of the file.
65
+
66
+ TOML is parsed with the standard library's
67
+ [`tomllib`](https://docs.python.org/3/library/tomllib.html), so the TOML syntax
68
+ accepted is whatever your Python version supports (TOML 1.0, plus TOML 1.1 on
69
+ Python 3.15 and later). If you need to support several Python versions, stick
70
+ to TOML 1.0 syntax.
71
+
72
+ ## Usage
73
+
74
+ To use the library, create an `mdsite.DB` object with the path to your
75
+ data directory:
76
+
77
+ mydb = mdsite.DB("/path/to/data/dir")
78
+
79
+ Then call `get_data(path)` for the path into the directory you want, leaving
80
+ out the `.md` filename suffix, and, if you are looking for an index file, leaving
81
+ out `index.md`:
82
+
83
+ data = mydb.get_data("/node/leaf")
84
+
85
+ The above gets data for `$DATA_DIR/node/leaf.md`, or for
86
+ `$DATA_DIR/node/leaf/index.md`, if that file exists instead. If both
87
+ `node/leaf.md` and a `node/leaf/` directory exist, `mdsite.PathConflict` is
88
+ raised. If nothing exists at the path, an empty dict is returned.
89
+
90
+ The returned dict contains the file's metadata, plus these keys:
91
+
92
+ - `content`: the Markdown rendered to HTML, as a `markupsafe.Markup` string
93
+ - `last_mod`: the modification time of the Markdown file, as a timezone-aware
94
+ `datetime` in UTC. For a directory this is the time of its `index.md` (the
95
+ same value `get_data("/node/leaf/index")` returns), or of the directory
96
+ itself if it has no `index.md`
97
+ - `path`: the normalized path, with a leading slash
98
+ - `id`: the last component of the path, or `"index"` for the root
99
+ - `listing`: for a directory, a `(subdirectories, pages)` tuple of sorted
100
+ names; otherwise `None`
101
+
102
+ `get_recursive_data(path)` returns the data for a directory and every
103
+ directory beneath it, keyed by path relative to the data directory (without a
104
+ leading slash; the root is `""`). It raises `mdsite.PathConflict` if any
105
+ directory in the tree conflicts with a file.
106
+
107
+ The library also supports hierarchical configuration, also written in TOML,
108
+ YAML, or JSON, stored in files called `config.{toml,yaml,json}` depending on the
109
+ config language employed. `get_config(path)` merges the configuration found in
110
+ the data directory and each directory along `path`, with deeper files
111
+ overriding shallower ones.
112
+
113
+ ## Upgrading to 0.3.0
114
+
115
+ - `last_mod` is now a timezone-aware UTC `datetime`. It used to be a naive
116
+ `datetime` (one with no timezone) holding the UTC time. Comparing it with a
117
+ naive `datetime` now raises `TypeError`. Compare it with aware datetimes
118
+ instead, such as `datetime.datetime.now(datetime.UTC)`.
119
+ - For a directory, `last_mod` now comes from its `index.md` rather than the
120
+ directory itself, so editing an index file updates it. It used to change
121
+ only when entries were added to or removed from the directory.
122
+ - TOML is now parsed with `tomllib` instead of the third-party `toml` package.
123
+ Parse errors are `tomllib.TOMLDecodeError` (still a `ValueError` subclass),
124
+ and offset datetimes in TOML metadata use `datetime.timezone.utc`.
125
+
126
+ ## Development
127
+
128
+ The project is managed with [uv](https://docs.astral.sh/uv/) and linted and
129
+ formatted with [ruff](https://docs.astral.sh/ruff/):
130
+
131
+ uv sync # create the virtualenv and install dependencies
132
+ uv run pytest # run the tests
133
+ uv run ruff check . # lint
134
+ uv run ruff format . # format
135
+ uv build # build the sdist and wheel
136
+
137
+ To run the tests against a particular Python version:
138
+
139
+ uv run --isolated --python 3.15 pytest
@@ -0,0 +1,117 @@
1
+ # Markdown Site Utils
2
+
3
+ Some utilities for managing Markdown files with metadata.
4
+
5
+ Requires Python 3.11 or later; tested on Python 3.11 through 3.15.
6
+
7
+ ## Installation
8
+
9
+ pip install markdown-site-utils
10
+
11
+ or, in a uv-managed project:
12
+
13
+ uv add markdown-site-utils
14
+
15
+ ## Overview
16
+
17
+ The notion is that a content-oriented website may be written as a
18
+ hierarchical series of Markdown files (with an ".md" extension) underneath
19
+ some data directory, e.g.:
20
+
21
+ DATA_DIR/
22
+ index.md
23
+ foo.md
24
+ bar.md
25
+ subdir/
26
+ index.md
27
+ foo.md
28
+ bar.md
29
+
30
+ Each file may contain metadata, written in TOML in a section at
31
+ the top, bounded by '+++' lines:
32
+
33
+ +++
34
+ title = "My Page Title"
35
+ +++
36
+
37
+ # Some Markdown
38
+
39
+ YAML and JSON may also be used. YAML blocks should start and end with lines
40
+ consisting of three dashes; JSON blocks should consist of a single JSON object
41
+ with opening and closing braces on lines by themselves. The data block is optional
42
+ but if present must begin on the first line of the file.
43
+
44
+ TOML is parsed with the standard library's
45
+ [`tomllib`](https://docs.python.org/3/library/tomllib.html), so the TOML syntax
46
+ accepted is whatever your Python version supports (TOML 1.0, plus TOML 1.1 on
47
+ Python 3.15 and later). If you need to support several Python versions, stick
48
+ to TOML 1.0 syntax.
49
+
50
+ ## Usage
51
+
52
+ To use the library, create an `mdsite.DB` object with the path to your
53
+ data directory:
54
+
55
+ mydb = mdsite.DB("/path/to/data/dir")
56
+
57
+ Then call `get_data(path)` for the path into the directory you want, leaving
58
+ out the `.md` filename suffix, and, if you are looking for an index file, leaving
59
+ out `index.md`:
60
+
61
+ data = mydb.get_data("/node/leaf")
62
+
63
+ The above gets data for `$DATA_DIR/node/leaf.md`, or for
64
+ `$DATA_DIR/node/leaf/index.md`, if that file exists instead. If both
65
+ `node/leaf.md` and a `node/leaf/` directory exist, `mdsite.PathConflict` is
66
+ raised. If nothing exists at the path, an empty dict is returned.
67
+
68
+ The returned dict contains the file's metadata, plus these keys:
69
+
70
+ - `content`: the Markdown rendered to HTML, as a `markupsafe.Markup` string
71
+ - `last_mod`: the modification time of the Markdown file, as a timezone-aware
72
+ `datetime` in UTC. For a directory this is the time of its `index.md` (the
73
+ same value `get_data("/node/leaf/index")` returns), or of the directory
74
+ itself if it has no `index.md`
75
+ - `path`: the normalized path, with a leading slash
76
+ - `id`: the last component of the path, or `"index"` for the root
77
+ - `listing`: for a directory, a `(subdirectories, pages)` tuple of sorted
78
+ names; otherwise `None`
79
+
80
+ `get_recursive_data(path)` returns the data for a directory and every
81
+ directory beneath it, keyed by path relative to the data directory (without a
82
+ leading slash; the root is `""`). It raises `mdsite.PathConflict` if any
83
+ directory in the tree conflicts with a file.
84
+
85
+ The library also supports hierarchical configuration, also written in TOML,
86
+ YAML, or JSON, stored in files called `config.{toml,yaml,json}` depending on the
87
+ config language employed. `get_config(path)` merges the configuration found in
88
+ the data directory and each directory along `path`, with deeper files
89
+ overriding shallower ones.
90
+
91
+ ## Upgrading to 0.3.0
92
+
93
+ - `last_mod` is now a timezone-aware UTC `datetime`. It used to be a naive
94
+ `datetime` (one with no timezone) holding the UTC time. Comparing it with a
95
+ naive `datetime` now raises `TypeError`. Compare it with aware datetimes
96
+ instead, such as `datetime.datetime.now(datetime.UTC)`.
97
+ - For a directory, `last_mod` now comes from its `index.md` rather than the
98
+ directory itself, so editing an index file updates it. It used to change
99
+ only when entries were added to or removed from the directory.
100
+ - TOML is now parsed with `tomllib` instead of the third-party `toml` package.
101
+ Parse errors are `tomllib.TOMLDecodeError` (still a `ValueError` subclass),
102
+ and offset datetimes in TOML metadata use `datetime.timezone.utc`.
103
+
104
+ ## Development
105
+
106
+ The project is managed with [uv](https://docs.astral.sh/uv/) and linted and
107
+ formatted with [ruff](https://docs.astral.sh/ruff/):
108
+
109
+ uv sync # create the virtualenv and install dependencies
110
+ uv run pytest # run the tests
111
+ uv run ruff check . # lint
112
+ uv run ruff format . # format
113
+ uv build # build the sdist and wheel
114
+
115
+ To run the tests against a particular Python version:
116
+
117
+ uv run --isolated --python 3.15 pytest
@@ -0,0 +1,5 @@
1
+ from mdsite.data import DB, PathConflict
2
+
3
+ __all__ = ["DB", "PathConflict"]
4
+
5
+ version = "0.3.0"
@@ -1,26 +1,25 @@
1
- from builtins import object
2
1
  import datetime
3
- import os
4
2
  import json
3
+ import os
4
+ import tomllib
5
5
 
6
- from markupsafe import Markup
7
6
  import markdown2
8
7
  import yaml
9
- import toml
8
+ from markupsafe import Markup
10
9
 
11
10
  BEGIN_FILE = 0
12
11
  IN_DATA = 1
13
12
  DATA_DONE = 2
14
13
  DATA_SEPS = {
15
14
  "{": ("}", lambda x: json.loads("{" + x + "}")),
16
- "+++": ("+++", toml.loads),
15
+ "+++": ("+++", tomllib.loads),
17
16
  "---": ("---", yaml.safe_load),
18
17
  }
19
18
 
20
19
 
21
20
  def _getmtime(path):
22
21
  mtime = os.path.getmtime(path)
23
- return datetime.datetime.utcfromtimestamp(mtime)
22
+ return datetime.datetime.fromtimestamp(mtime, tz=datetime.UTC)
24
23
 
25
24
 
26
25
  def _getlisting(dir):
@@ -35,13 +34,11 @@ def parse_file(file_path):
35
34
  state = BEGIN_FILE
36
35
  end_sep = None
37
36
  data_parser = None
38
- seen_sep = False
39
37
  with open(file_path) as fp:
40
38
  for line in fp:
41
39
  if state == BEGIN_FILE:
42
40
  stripped = line.strip()
43
41
  if stripped in DATA_SEPS:
44
- seen_sep = True
45
42
  state = IN_DATA
46
43
  end_sep, data_parser = DATA_SEPS[stripped]
47
44
  else:
@@ -49,7 +46,7 @@ def parse_file(file_path):
49
46
  content.append(line)
50
47
  elif state == IN_DATA:
51
48
  if line.strip() == end_sep:
52
- state = DATA_DONE
49
+ state = DATA_DONE
53
50
  else:
54
51
  raw_data.append(line)
55
52
  elif state == DATA_DONE:
@@ -75,13 +72,13 @@ class PathConflict(ValueError):
75
72
 
76
73
 
77
74
  CONFIG_FILES = (
78
- ("config.toml", toml.loads),
75
+ ("config.toml", tomllib.loads),
79
76
  ("config.yaml", yaml.safe_load),
80
77
  ("config.json", json.loads),
81
78
  )
82
79
 
83
80
 
84
- class DB(object):
81
+ class DB:
85
82
  def __init__(self, data_dir):
86
83
  self.data_dir = data_dir
87
84
 
@@ -119,13 +116,14 @@ class DB(object):
119
116
  path, file_path = self._clean_path(path)
120
117
  if os.path.isdir(file_path):
121
118
  if os.path.isfile(file_path + ".md"):
122
- raise PathConflict(
123
- "path {} is both a file and a directory".format(path)
124
- )
119
+ raise PathConflict(f"path {path} is both a file and a directory")
125
120
  if listing is None:
126
121
  listing = _getlisting(file_path)
127
- mtime = _getmtime(file_path)
128
- file_path = os.path.join(file_path, "index.md")
122
+ index_path = os.path.join(file_path, "index.md")
123
+ # Use the index file's mtime, as get_data("<dir>/index") would;
124
+ # fall back to the directory's mtime if there is no index file.
125
+ mtime = _getmtime(index_path if os.path.exists(index_path) else file_path)
126
+ file_path = index_path
129
127
  else:
130
128
  file_path += ".md"
131
129
  if not os.path.exists(file_path):
@@ -138,7 +136,7 @@ class DB(object):
138
136
  data["content"] = md_content
139
137
  data["listing"] = listing
140
138
  data["last_mod"] = mtime
141
- data["path"] = "/%s" % path
139
+ data["path"] = f"/{path}"
142
140
  data["id"] = "index" if path == "" else os.path.basename(path)
143
141
  return data
144
142
 
@@ -1,5 +1,6 @@
1
1
  import datetime
2
2
  import os
3
+ import tempfile
3
4
  import unittest
4
5
 
5
6
  from mdsite.data import DB, PathConflict
@@ -17,10 +18,9 @@ class DBTests(unittest.TestCase):
17
18
  self.assertEqual(result["owner"]["name"], "Tom Preston-Werner")
18
19
  self.assertEqual(
19
20
  result["owner"]["dob"].isoformat(),
20
- datetime.datetime(
21
- 1979, 5, 27, 7, 32, tzinfo=datetime.timezone.utc
22
- ).isoformat(),
21
+ datetime.datetime(1979, 5, 27, 7, 32, tzinfo=datetime.UTC).isoformat(),
23
22
  )
23
+ self.assertIs(result["owner"]["dob"].tzinfo, datetime.UTC)
24
24
 
25
25
  def testParseYAML(self):
26
26
  result = self.db.get_data("yaml")
@@ -72,6 +72,32 @@ class DBTests(unittest.TestCase):
72
72
  self.assertTrue(data.get("content", ""))
73
73
  self.assertIn("This markdown file", data.get("content", ""))
74
74
 
75
+ def testLastModIsAwareUTC(self):
76
+ for path in ("toml", "nougat"):
77
+ last_mod = self.db.get_data(path)["last_mod"]
78
+ self.assertEqual(last_mod.tzinfo, datetime.UTC)
79
+ fs_path = os.path.join(self.data_dir, path)
80
+ if not os.path.isdir(fs_path):
81
+ fs_path += ".md"
82
+ self.assertAlmostEqual(
83
+ last_mod.timestamp(), os.path.getmtime(fs_path), delta=1e-6
84
+ )
85
+
86
+ def testDirectoryLastModComesFromIndexFile(self):
87
+ with tempfile.TemporaryDirectory() as data_dir:
88
+ leaf_dir = os.path.join(data_dir, "a", "b")
89
+ os.makedirs(leaf_dir)
90
+ index_path = os.path.join(leaf_dir, "index.md")
91
+ with open(index_path, "w") as fp:
92
+ fp.write("# Leaf\n")
93
+ # Make the index file and its directory disagree, as they do
94
+ # when index.md is edited in place.
95
+ os.utime(index_path, (1_000_000_000, 1_000_000_000))
96
+ os.utime(leaf_dir, (2_000_000_000, 2_000_000_000))
97
+ db = DB(data_dir)
98
+ expected = datetime.datetime.fromtimestamp(1_000_000_000, tz=datetime.UTC)
99
+ self.assertEqual(db.get_data("/a/b/index")["last_mod"], expected)
100
+ self.assertEqual(db.get_data("/a/b")["last_mod"], expected)
75
101
 
76
102
 
77
103
  if __name__ == "__main__":
@@ -0,0 +1,61 @@
1
+ [project]
2
+ name = "markdown-site-utils"
3
+ version = "0.3.0"
4
+ description = "Some utilities for managing Markdown files with metadata."
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ license-files = ["LICENSE"]
8
+ requires-python = ">=3.11"
9
+ classifiers = [
10
+ "Programming Language :: Python :: 3",
11
+ "Programming Language :: Python :: 3 :: Only",
12
+ "Programming Language :: Python :: 3.11",
13
+ "Programming Language :: Python :: 3.12",
14
+ "Programming Language :: Python :: 3.13",
15
+ "Programming Language :: Python :: 3.14",
16
+ "Programming Language :: Python :: 3.15",
17
+ ]
18
+ dependencies = [
19
+ "MarkupSafe>=2.1.2",
20
+ "PyYAML>=6.0",
21
+ "markdown2>=2.5.1",
22
+ ]
23
+
24
+ [[project.authors]]
25
+ name = "Jacob Smullyan"
26
+ email = "smulloni@smullyan.org"
27
+
28
+ [project.urls]
29
+ Repository = "https://github.com/smulloni/markdown_site_utils"
30
+
31
+ [dependency-groups]
32
+ dev = [
33
+ "pytest>=7.3.0",
34
+ "ipython>=8.12.0",
35
+ "ruff>=0.17.6",
36
+ ]
37
+
38
+ [build-system]
39
+ requires = ["uv_build>=0.13.8,<0.14"]
40
+ build-backend = "uv_build"
41
+
42
+ [tool.uv.build-backend]
43
+ module-name = "mdsite"
44
+ module-root = ""
45
+
46
+ [tool.ruff]
47
+ target-version = "py311"
48
+
49
+ [tool.ruff.lint]
50
+ select = [
51
+ "F",
52
+ "E",
53
+ "W",
54
+ "I",
55
+ "UP",
56
+ "B",
57
+ "DTZ",
58
+ ]
59
+
60
+ [tool.pytest.ini_options]
61
+ filterwarnings = ["error"]
@@ -0,0 +1,51 @@
1
+ [project]
2
+ name = "markdown-site-utils"
3
+ version = "0.3.0"
4
+ description = "Some utilities for managing Markdown files with metadata."
5
+ authors = [{ name = "Jacob Smullyan", email = "smulloni@smullyan.org" }]
6
+ readme = "README.md"
7
+ license = "MIT"
8
+ license-files = ["LICENSE"]
9
+ requires-python = ">=3.11"
10
+ classifiers = [
11
+ "Programming Language :: Python :: 3",
12
+ "Programming Language :: Python :: 3 :: Only",
13
+ "Programming Language :: Python :: 3.11",
14
+ "Programming Language :: Python :: 3.12",
15
+ "Programming Language :: Python :: 3.13",
16
+ "Programming Language :: Python :: 3.14",
17
+ "Programming Language :: Python :: 3.15",
18
+ ]
19
+ dependencies = [
20
+ "MarkupSafe>=2.1.2",
21
+ "PyYAML>=6.0",
22
+ "markdown2>=2.5.1",
23
+ ]
24
+
25
+ [project.urls]
26
+ Repository = "https://github.com/smulloni/markdown_site_utils"
27
+
28
+ [dependency-groups]
29
+ dev = [
30
+ "pytest>=7.3.0",
31
+ "ipython>=8.12.0",
32
+ "ruff>=0.17.6",
33
+ ]
34
+
35
+ [build-system]
36
+ requires = ["uv_build>=0.13.8,<0.14"]
37
+ build-backend = "uv_build"
38
+
39
+ [tool.uv.build-backend]
40
+ module-name = "mdsite"
41
+ module-root = ""
42
+
43
+ [tool.ruff]
44
+ target-version = "py311"
45
+
46
+ [tool.ruff.lint]
47
+ # pyflakes, pycodestyle, isort, pyupgrade, bugbear, flake8-datetimez
48
+ select = ["F", "E", "W", "I", "UP", "B", "DTZ"]
49
+
50
+ [tool.pytest.ini_options]
51
+ filterwarnings = ["error"]
@@ -1,68 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: markdown-site-utils
3
- Version: 0.2.2
4
- Summary: Some utilities for managing Markdown files with metadata.
5
- Home-page: https://github.com/smulloni/markdown_site_utils
6
- License: MIT
7
- Author: Jacob Smullyan
8
- Author-email: smulloni@smullyan.org
9
- Requires-Python: >=3.11,<4.0
10
- Classifier: License :: OSI Approved :: MIT License
11
- Classifier: Programming Language :: Python :: 3
12
- Classifier: Programming Language :: Python :: 3.11
13
- Requires-Dist: MarkupSafe (>=2.1.2,<3.0.0)
14
- Requires-Dist: PyYAML (>=6.0,<7.0)
15
- Requires-Dist: markdown2 (>=2.4.8,<3.0.0)
16
- Requires-Dist: toml (>=0.10.2,<0.11.0)
17
- Project-URL: Repository, https://github.com/smulloni/markdown_site_utils
18
- Description-Content-Type: text/markdown
19
-
20
- # Markdown Site Utils
21
-
22
- Some utilities for managing Markdown files with metadata.
23
-
24
- The notion is that a content-oriented website may be written as a
25
- hierarchical series of Markdown files (with an ".md" extension) underneath
26
- some data directory, e.g.:
27
-
28
- DATA_DIR/
29
- index.md
30
- foo.md
31
- bar.md
32
- subdir/
33
- index.md
34
- foo.md
35
- bar.md
36
-
37
- Each file may contain metadata, written in TOML in a section at
38
- the top, bounded by '+++' lines:
39
-
40
- +++
41
- title = "My Page Title"
42
- +++
43
-
44
- # Some Markdown
45
-
46
- YAML and JSON may also be used. YAML blocks should start and end with lines
47
- consisting of three dashes; JSON blocks should consist of a single JSON object
48
- with opening and closing braces on lines by themselves. The data block is optional
49
- but if present must begin on the first line of the file.
50
-
51
- To use the library, you get create an `mdsite.DB` object with the path to your
52
- data directory:
53
-
54
- mydb = mdsite.DB("/path/to/data/dir")
55
-
56
- Then call `get_data(path)` for the path into the directory you want, leaving
57
- out the `.md` filename suffix, and, if you are looking for an index file, leaving
58
- out `index.md`:
59
-
60
- data = mydb.get_data("/node/leaf")
61
-
62
- The above gets data for `$DATA_DIR/node/leaf.md`, or for
63
- `$DATA_DIR/node/leaf/index.md`, if that file exists instead.
64
-
65
- The library also supports hierarchical configuration, also written in TOML,
66
- YAML, or JSON, stored in files called `config.{toml,yaml,json}` depending on the
67
- config language employed.
68
-
@@ -1,48 +0,0 @@
1
- # Markdown Site Utils
2
-
3
- Some utilities for managing Markdown files with metadata.
4
-
5
- The notion is that a content-oriented website may be written as a
6
- hierarchical series of Markdown files (with an ".md" extension) underneath
7
- some data directory, e.g.:
8
-
9
- DATA_DIR/
10
- index.md
11
- foo.md
12
- bar.md
13
- subdir/
14
- index.md
15
- foo.md
16
- bar.md
17
-
18
- Each file may contain metadata, written in TOML in a section at
19
- the top, bounded by '+++' lines:
20
-
21
- +++
22
- title = "My Page Title"
23
- +++
24
-
25
- # Some Markdown
26
-
27
- YAML and JSON may also be used. YAML blocks should start and end with lines
28
- consisting of three dashes; JSON blocks should consist of a single JSON object
29
- with opening and closing braces on lines by themselves. The data block is optional
30
- but if present must begin on the first line of the file.
31
-
32
- To use the library, you get create an `mdsite.DB` object with the path to your
33
- data directory:
34
-
35
- mydb = mdsite.DB("/path/to/data/dir")
36
-
37
- Then call `get_data(path)` for the path into the directory you want, leaving
38
- out the `.md` filename suffix, and, if you are looking for an index file, leaving
39
- out `index.md`:
40
-
41
- data = mydb.get_data("/node/leaf")
42
-
43
- The above gets data for `$DATA_DIR/node/leaf.md`, or for
44
- `$DATA_DIR/node/leaf/index.md`, if that file exists instead.
45
-
46
- The library also supports hierarchical configuration, also written in TOML,
47
- YAML, or JSON, stored in files called `config.{toml,yaml,json}` depending on the
48
- config language employed.
@@ -1,3 +0,0 @@
1
- from mdsite.data import PathConflict, DB
2
-
3
- version = '0.2.2'
@@ -1,29 +0,0 @@
1
- [tool.poetry]
2
- name = "markdown-site-utils"
3
- version = "0.2.2"
4
- description = "Some utilities for managing Markdown files with metadata."
5
- authors = ["Jacob Smullyan <smulloni@smullyan.org>"]
6
- readme = "README.md"
7
- license = "MIT"
8
- repository = "https://github.com/smulloni/markdown_site_utils"
9
- packages = [{include = "mdsite"}]
10
- include = [
11
- {path="mdsite/testdata/*"},
12
- {path="mdsite/testdata/conflict/*"},
13
- ]
14
-
15
- [tool.poetry.dependencies]
16
- python = "^3.11"
17
- MarkupSafe = "^2.1.2"
18
- PyYAML = "^6.0"
19
- markdown2 = "^2.4.8"
20
- toml = "^0.10.2"
21
-
22
- [tool.poetry.group.dev.dependencies]
23
- pytest = "^7.3.0"
24
- ipython = "^8.12.0"
25
- black = "^23.3.0"
26
-
27
- [build-system]
28
- requires = ["poetry-core"]
29
- build-backend = "poetry.core.masonry.api"
@@ -1,34 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- from setuptools import setup
3
-
4
- packages = \
5
- ['mdsite']
6
-
7
- package_data = \
8
- {'': ['*'],
9
- 'mdsite': ['testdata/*', 'testdata/conflict/*', 'testdata/nougat/*']}
10
-
11
- install_requires = \
12
- ['MarkupSafe>=2.1.2,<3.0.0',
13
- 'PyYAML>=6.0,<7.0',
14
- 'markdown2>=2.4.8,<3.0.0',
15
- 'toml>=0.10.2,<0.11.0']
16
-
17
- setup_kwargs = {
18
- 'name': 'markdown-site-utils',
19
- 'version': '0.2.2',
20
- 'description': 'Some utilities for managing Markdown files with metadata.',
21
- 'long_description': '# Markdown Site Utils\n\nSome utilities for managing Markdown files with metadata.\n\nThe notion is that a content-oriented website may be written as a \nhierarchical series of Markdown files (with an ".md" extension) underneath\nsome data directory, e.g.:\n\n DATA_DIR/\n index.md\n foo.md\n bar.md\n subdir/\n index.md\n foo.md\n bar.md\n\nEach file may contain metadata, written in TOML in a section at\nthe top, bounded by \'+++\' lines:\n\n +++\n title = "My Page Title"\n +++\n\n # Some Markdown\n\nYAML and JSON may also be used. YAML blocks should start and end with lines\nconsisting of three dashes; JSON blocks should consist of a single JSON object\nwith opening and closing braces on lines by themselves. The data block is optional\nbut if present must begin on the first line of the file.\n\nTo use the library, you get create an `mdsite.DB` object with the path to your\ndata directory:\n\n mydb = mdsite.DB("/path/to/data/dir")\n\nThen call `get_data(path)` for the path into the directory you want, leaving\nout the `.md` filename suffix, and, if you are looking for an index file, leaving\nout `index.md`:\n\n data = mydb.get_data("/node/leaf")\n\nThe above gets data for `$DATA_DIR/node/leaf.md`, or for\n`$DATA_DIR/node/leaf/index.md`, if that file exists instead. \n\nThe library also supports hierarchical configuration, also written in TOML,\nYAML, or JSON, stored in files called `config.{toml,yaml,json}` depending on the\nconfig language employed.\n',
22
- 'author': 'Jacob Smullyan',
23
- 'author_email': 'smulloni@smullyan.org',
24
- 'maintainer': 'None',
25
- 'maintainer_email': 'None',
26
- 'url': 'https://github.com/smulloni/markdown_site_utils',
27
- 'packages': packages,
28
- 'package_data': package_data,
29
- 'install_requires': install_requires,
30
- 'python_requires': '>=3.11,<4.0',
31
- }
32
-
33
-
34
- setup(**setup_kwargs)