markdown-analysis 0.1.0__tar.gz → 0.1.1__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: markdown_analysis
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: UNKNOWN
5
5
  Home-page: https://github.com/yannbanas/mrkdwn_analysis
6
6
  Author: yannbanas
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: markdown-analysis
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: UNKNOWN
5
5
  Home-page: https://github.com/yannbanas/mrkdwn_analysis
6
6
  Author: yannbanas
@@ -233,6 +233,7 @@ class MarkdownParser:
233
233
  separator_line = self.lines[self.pos+1].strip()
234
234
  self.pos += 2
235
235
  rows = []
236
+
236
237
  while self.pos < self.length:
237
238
  line = self.lines[self.pos].strip()
238
239
  if not line or self.starts_new_block(line):
@@ -240,12 +241,21 @@ class MarkdownParser:
240
241
  rows.append(line)
241
242
  self.pos += 1
242
243
 
243
- header_cells = [h.strip() for h in header_line.strip('|').split('|') if h.strip()]
244
- data_rows = []
245
- for r in rows:
246
- data_rows.append([c.strip() for c in r.strip('|').split('|') if c.strip()])
247
-
248
- self.tokens.append(BlockToken('table', meta={"header": header_cells, "rows": data_rows}, line=start+1))
244
+ def parse_row(row):
245
+ parts = row.strip().split('|')
246
+ if parts and not parts[0]:
247
+ parts.pop(0)
248
+ if parts and not parts[-1]:
249
+ parts.pop()
250
+ return [p.strip() for p in parts]
251
+
252
+ header_cells = parse_row(header_line)
253
+ data_rows = [parse_row(row) for row in rows]
254
+
255
+ self.tokens.append(BlockToken('table', meta={
256
+ "header": header_cells,
257
+ "rows": data_rows
258
+ }, line=start+1))
249
259
 
250
260
  def starts_new_block(self, line):
251
261
  return (self.ATX_HEADER_RE.match(line) or
@@ -6,7 +6,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
6
6
 
7
7
  setup(
8
8
  name='markdown_analysis',
9
- version='0.1.0',
9
+ version='0.1.1',
10
10
  long_description=long_description,
11
11
  long_description_content_type="text/markdown",
12
12
  author='yannbanas',