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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: markdown-site-utils
3
- Version: 0.2.1
3
+ Version: 0.2.2
4
4
  Summary: Some utilities for managing Markdown files with metadata.
5
5
  Home-page: https://github.com/smulloni/markdown_site_utils
6
6
  License: MIT
@@ -1,3 +1,3 @@
1
1
  from mdsite.data import PathConflict, DB
2
2
 
3
- version = '0.2.1'
3
+ version = '0.2.2'
@@ -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
- line = line.strip()
45
- if not line:
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[line]
51
- continue
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"]
@@ -73,5 +73,6 @@ class DBTests(unittest.TestCase):
73
73
  self.assertIn("This markdown file", data.get("content", ""))
74
74
 
75
75
 
76
+
76
77
  if __name__ == "__main__":
77
78
  unittest.main()
@@ -0,0 +1,3 @@
1
+ # No Data Header
2
+
3
+ ☞ This markdown file has no data header.
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "markdown-site-utils"
3
- version = "0.2.1"
3
+ version = "0.2.2"
4
4
  description = "Some utilities for managing Markdown files with metadata."
5
5
  authors = ["Jacob Smullyan <smulloni@smullyan.org>"]
6
6
  readme = "README.md"
@@ -16,7 +16,7 @@ install_requires = \
16
16
 
17
17
  setup_kwargs = {
18
18
  'name': 'markdown-site-utils',
19
- 'version': '0.2.1',
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',
@@ -1,3 +0,0 @@
1
- # No Data Header
2
-
3
- This markdown file has no data header.