markdown-site-utils 0.2.1__tar.gz → 0.2.2__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.
- {markdown_site_utils-0.2.1 → markdown_site_utils-0.2.2}/PKG-INFO +1 -1
- {markdown_site_utils-0.2.1 → markdown_site_utils-0.2.2}/mdsite/__init__.py +1 -1
- {markdown_site_utils-0.2.1 → markdown_site_utils-0.2.2}/mdsite/data.py +7 -12
- {markdown_site_utils-0.2.1 → markdown_site_utils-0.2.2}/mdsite/data_test.py +1 -0
- markdown_site_utils-0.2.2/mdsite/testdata/nohead.md +3 -0
- {markdown_site_utils-0.2.1 → markdown_site_utils-0.2.2}/pyproject.toml +1 -1
- {markdown_site_utils-0.2.1 → markdown_site_utils-0.2.2}/setup.py +1 -1
- markdown_site_utils-0.2.1/mdsite/testdata/nohead.md +0 -3
- {markdown_site_utils-0.2.1 → markdown_site_utils-0.2.2}/LICENSE +0 -0
- {markdown_site_utils-0.2.1 → markdown_site_utils-0.2.2}/README.md +0 -0
- {markdown_site_utils-0.2.1 → markdown_site_utils-0.2.2}/mdsite/testdata/config.toml +0 -0
- {markdown_site_utils-0.2.1 → markdown_site_utils-0.2.2}/mdsite/testdata/conflict/index.md +0 -0
- {markdown_site_utils-0.2.1 → markdown_site_utils-0.2.2}/mdsite/testdata/conflict.md +0 -0
- {markdown_site_utils-0.2.1 → markdown_site_utils-0.2.2}/mdsite/testdata/json.md +0 -0
- {markdown_site_utils-0.2.1 → markdown_site_utils-0.2.2}/mdsite/testdata/nougat/config.json +0 -0
- {markdown_site_utils-0.2.1 → markdown_site_utils-0.2.2}/mdsite/testdata/toml.md +0 -0
- {markdown_site_utils-0.2.1 → markdown_site_utils-0.2.2}/mdsite/testdata/yaml.md +0 -0
|
@@ -32,26 +32,24 @@ def _getlisting(dir):
|
|
|
32
32
|
def parse_file(file_path):
|
|
33
33
|
raw_data = []
|
|
34
34
|
content = []
|
|
35
|
-
raw_lines = []
|
|
36
35
|
state = BEGIN_FILE
|
|
37
36
|
end_sep = None
|
|
38
37
|
data_parser = None
|
|
39
38
|
seen_sep = False
|
|
40
39
|
with open(file_path) as fp:
|
|
41
40
|
for line in fp:
|
|
42
|
-
raw_lines.append(line)
|
|
43
41
|
if state == BEGIN_FILE:
|
|
44
|
-
|
|
45
|
-
if
|
|
46
|
-
continue
|
|
47
|
-
if line in DATA_SEPS:
|
|
42
|
+
stripped = line.strip()
|
|
43
|
+
if stripped in DATA_SEPS:
|
|
48
44
|
seen_sep = True
|
|
49
45
|
state = IN_DATA
|
|
50
|
-
end_sep, data_parser = DATA_SEPS[
|
|
51
|
-
|
|
46
|
+
end_sep, data_parser = DATA_SEPS[stripped]
|
|
47
|
+
else:
|
|
48
|
+
state = DATA_DONE
|
|
49
|
+
content.append(line)
|
|
52
50
|
elif state == IN_DATA:
|
|
53
51
|
if line.strip() == end_sep:
|
|
54
|
-
state = DATA_DONE
|
|
52
|
+
state = DATA_DONE
|
|
55
53
|
else:
|
|
56
54
|
raw_data.append(line)
|
|
57
55
|
elif state == DATA_DONE:
|
|
@@ -64,9 +62,6 @@ def parse_file(file_path):
|
|
|
64
62
|
data = data_parser("".join(raw_data))
|
|
65
63
|
else:
|
|
66
64
|
data = {}
|
|
67
|
-
if not seen_sep:
|
|
68
|
-
# no data header; backtrack to use all data without line stripping
|
|
69
|
-
content = raw_lines
|
|
70
65
|
html = Markup(
|
|
71
66
|
markdown2.markdown(
|
|
72
67
|
"".join(content), extras=["markdown-in-html", "smarty-pants"]
|
|
@@ -16,7 +16,7 @@ install_requires = \
|
|
|
16
16
|
|
|
17
17
|
setup_kwargs = {
|
|
18
18
|
'name': 'markdown-site-utils',
|
|
19
|
-
'version': '0.2.
|
|
19
|
+
'version': '0.2.2',
|
|
20
20
|
'description': 'Some utilities for managing Markdown files with metadata.',
|
|
21
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
22
|
'author': 'Jacob Smullyan',
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|