git @ Cat's Eye Technologies Feedmark / 8b5d425
Merge pull request #12 from cpressey/develop-0.12 Develop 0.12 Chris Pressey authored 4 years ago GitHub committed 4 years ago
8 changed file(s) with 65 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
00 History of Feedmark
11 ===================
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.
211
312 0.11
413 ----
1625 and produce only `filename` entries on output.
1726 * Parser now allows trailing `###` on h3-level section headers.
1827
19 0.9-2019.105
20 ------------
28 0.9-2019.1015
29 -------------
2130
2231 * Minor release to work out issues with `setup.py`.
2332
00 Feedmark
11 ========
22
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.*
44
55 **Feedmark** is a format for embedding structured data in Markdown files
66 in a way which is both human-readable and machine-extractable.
3838
3939 Or you can install it using `pip`:
4040
41 pip install Feedmark==0.11
41 pip install Feedmark==0.12
4242
4343 (Depending on your needs, you may wish to establish a virtual environment
4444 first. How to do this is outside the scope of this document.)
55
66 ### Maybe sighting the llama
77
8 ![photo of possible llama](https://static.catseye.tc/images/screenshots/Kolakoski_Kurve.jpg)
9
810 * date: Jan 1 1984 12:00:00
911
1012 It was a possible llama sighting.
1414 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.
1515
1616 ### A Possible Llama Under the Bridge
17
18 [![photo of possible llama](https://static.catseye.tc/images/screenshots/Heronsis_hermnonicii.jpg)](https://catseye.tc/article/Gewgaws.md)
19 ![another possible photo](https://static.catseye.tc/images/screenshots/A_Non-Random_Walk.jpg)
1720
1821 * date: Dec 15 2016 23:59:59
1922 * reporter: Gregor Samsa
7272 md += u'\n'
7373 md += u'### {}\n\n'.format(section.title)
7474 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 )
7784 md += u'\n'
7885 md += markdownize_properties(section.properties, property_priority_order)
7986 md += section.body
7878 help='Process no more than this many entries when making an Atom or HTML feed'
7979 )
8080
81 argparser.add_argument('--version', action='version', version="%(prog)s 0.11")
81 argparser.add_argument('--version', action='version', version="%(prog)s 0.12")
8282
8383 options = argparser.parse_args(args)
8484
169169 return re.match(r'^\s*$', self.line)
170170
171171 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 )
173176
174177 def is_property_line(self):
175178 return re.match(r'^\*\s+(.*?)\s*(\:|\@)\s*(.*?)\s*$', self.line)
266269 while self.is_blank_line() or self.is_image_line():
267270 if self.is_image_line():
268271 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 })
270284 self.scan()
271285 return images
272286
112112 self.assertEqual(data['documents'][0]['sections'], [
113113 {
114114 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 ],
116121 u'properties': {u'date': u'Jan 1 1984 12:00:00'},
117122 u'title': u'Maybe sighting the llama',
118123 u'anchor': u'maybe-sighting-the-llama',
119124 }
120125 ])
121126 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 ])
122142
123143 def test_output_htmlized_json(self):
124144 main(['eg/Referenced Llama Sightings.md', '--output-json', '--htmlized-json'])