Merge pull request #12 from cpressey/develop-0.12
Develop 0.12
Chris Pressey authored 4 years ago
GitHub committed 4 years ago
0 | 0 | History of Feedmark |
1 | 1 | =================== |
2 | ||
3 | 0.12 | |
4 | ---- | |
5 | ||
6 | * Added support for hyperlinks on images on entries. | |
7 | * Added test cases for correct handling of images on entries. | |
8 | * Format of entry images in output JSON has changed: each image | |
9 | is now represented as a dictionary with two or three keys | |
10 | rather than as a list with two elements. | |
2 | 11 | |
3 | 12 | 0.11 |
4 | 13 | ---- |
16 | 25 | and produce only `filename` entries on output. |
17 | 26 | * Parser now allows trailing `###` on h3-level section headers. |
18 | 27 | |
19 | 0.9-2019.105 | |
20 | ------------ | |
28 | 0.9-2019.1015 | |
29 | ------------- | |
21 | 30 | |
22 | 31 | * Minor release to work out issues with `setup.py`. |
23 | 32 |
0 | 0 | Feedmark |
1 | 1 | ======== |
2 | 2 | |
3 | *Version 0.11. Subject to change in backwards-incompatible ways without notice.* | |
3 | *Version 0.12. Subject to change in backwards-incompatible ways without notice.* | |
4 | 4 | |
5 | 5 | **Feedmark** is a format for embedding structured data in Markdown files |
6 | 6 | in a way which is both human-readable and machine-extractable. |
38 | 38 | |
39 | 39 | Or you can install it using `pip`: |
40 | 40 | |
41 | pip install Feedmark==0.11 | |
41 | pip install Feedmark==0.12 | |
42 | 42 | |
43 | 43 | (Depending on your needs, you may wish to establish a virtual environment |
44 | 44 | first. How to do this is outside the scope of this document.) |
5 | 5 | |
6 | 6 | ### Maybe sighting the llama |
7 | 7 | |
8 |  | |
9 | ||
8 | 10 | * date: Jan 1 1984 12:00:00 |
9 | 11 | |
10 | 12 | It was a possible llama sighting. |
14 | 14 | Fusce sed varius diam. Mauris massa lorem, fermentum et faucibus id, luctus suscipit lorem. Curabitur eu gravida neque. Nam mollis, nisl et cursus congue, felis orci maximus magna, vel varius tortor purus a nulla. Quisque quam ex, gravida vel vulputate nec, pellentesque in quam. Suspendisse odio arcu, ornare sit amet molestie at, ornare nec nisl. Suspendisse fermentum dolor quis euismod cursus. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Etiam eget orci semper, iaculis libero nec, viverra risus. Nullam a turpis id eros tincidunt congue. Mauris magna arcu, mattis in ultrices vel, aliquet sit amet diam. Nunc nec urna in ipsum pellentesque varius. Duis feugiat blandit urna ut auctor. |
15 | 15 | |
16 | 16 | ### A Possible Llama Under the Bridge |
17 | ||
18 | [](https://catseye.tc/article/Gewgaws.md) | |
19 |  | |
17 | 20 | |
18 | 21 | * date: Dec 15 2016 23:59:59 |
19 | 22 | * reporter: Gregor Samsa |
72 | 72 | md += u'\n' |
73 | 73 | md += u'### {}\n\n'.format(section.title) |
74 | 74 | if section.images: |
75 | for name, url in section.images: | |
76 | md += u'\n'.format(name, url) | |
75 | for entry in section.images: | |
76 | if 'link' in entry: | |
77 | md += u'[]({})\n'.format( | |
78 | entry['description'], entry['source'], entry['link'], | |
79 | ) | |
80 | else: | |
81 | md += u'\n'.format( | |
82 | entry['description'], entry['source'], | |
83 | ) | |
77 | 84 | md += u'\n' |
78 | 85 | md += markdownize_properties(section.properties, property_priority_order) |
79 | 86 | md += section.body |
78 | 78 | help='Process no more than this many entries when making an Atom or HTML feed' |
79 | 79 | ) |
80 | 80 | |
81 | argparser.add_argument('--version', action='version', version="%(prog)s 0.11") | |
81 | argparser.add_argument('--version', action='version', version="%(prog)s 0.12") | |
82 | 82 | |
83 | 83 | options = argparser.parse_args(args) |
84 | 84 |
169 | 169 | return re.match(r'^\s*$', self.line) |
170 | 170 | |
171 | 171 | def is_image_line(self): |
172 | return re.match(r'^\!\[.*?\]\(.*?\)\s*$', self.line) | |
172 | return ( | |
173 | re.match(r'^\!\[.*?\]\(.*?\)\s*$', self.line) or | |
174 | re.match(r'^\[\!\[.*?\]\(.*?\)\]\(.*?\)\s*$', self.line) | |
175 | ) | |
173 | 176 | |
174 | 177 | def is_property_line(self): |
175 | 178 | return re.match(r'^\*\s+(.*?)\s*(\:|\@)\s*(.*?)\s*$', self.line) |
266 | 269 | while self.is_blank_line() or self.is_image_line(): |
267 | 270 | if self.is_image_line(): |
268 | 271 | match = re.match(r'^\!\[(.*?)\]\((.*?)\)\s*$', self.line) |
269 | images.append( (match.group(1), match.group(2),) ) | |
272 | if match: | |
273 | images.append({ | |
274 | 'description': match.group(1), | |
275 | 'source': match.group(2), | |
276 | }) | |
277 | else: | |
278 | match = re.match(r'^\[\!\[(.*?)\]\((.*?)\)\]\((.*?)\)\s*$', self.line) | |
279 | images.append({ | |
280 | 'description': match.group(1), | |
281 | 'source': match.group(2), | |
282 | 'link': match.group(3), | |
283 | }) | |
270 | 284 | self.scan() |
271 | 285 | return images |
272 | 286 |
112 | 112 | self.assertEqual(data['documents'][0]['sections'], [ |
113 | 113 | { |
114 | 114 | u'body': data['documents'][0]['sections'][0]['body'], |
115 | u'images': [], | |
115 | u'images': [ | |
116 | { | |
117 | u'description': u'photo of possible llama', | |
118 | u'source': u'https://static.catseye.tc/images/screenshots/Kolakoski_Kurve.jpg', | |
119 | } | |
120 | ], | |
116 | 121 | u'properties': {u'date': u'Jan 1 1984 12:00:00'}, |
117 | 122 | u'title': u'Maybe sighting the llama', |
118 | 123 | u'anchor': u'maybe-sighting-the-llama', |
119 | 124 | } |
120 | 125 | ]) |
121 | 126 | self.assertIn(u'It was a possible llama sighting.\n\n', data['documents'][0]['sections'][0]['body']) |
127 | ||
128 | def test_output_json_with_multiple_images_and_linked_images(self): | |
129 | main(['eg/Recent Llama Sightings.md', '--output-json']) | |
130 | data = json.loads(sys.stdout.getvalue()) | |
131 | self.assertEqual(data['documents'][0]['sections'][1]['images'], [ | |
132 | { | |
133 | u'description': u'photo of possible llama', | |
134 | u'source': u'https://static.catseye.tc/images/screenshots/Heronsis_hermnonicii.jpg', | |
135 | u'link': u'https://catseye.tc/article/Gewgaws.md', | |
136 | }, | |
137 | { | |
138 | u'description': u'another possible photo', | |
139 | u'source': u'https://static.catseye.tc/images/screenshots/A_Non-Random_Walk.jpg', | |
140 | }, | |
141 | ]) | |
122 | 142 | |
123 | 143 | def test_output_htmlized_json(self): |
124 | 144 | main(['eg/Referenced Llama Sightings.md', '--output-json', '--htmlized-json']) |