Skip to content

Commit e171932

Browse files
committed
Improve code readability and add changes based on code review
1 parent 58a554c commit e171932

File tree

4 files changed

+32
-42
lines changed

4 files changed

+32
-42
lines changed

packages/markdown-table/.gitignore

-5
This file was deleted.

packages/markdown-table/README.md

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
# markdown-table
22

3-
This plugin adds styling to markdown tables, by adding bootstrap classes.
4-
Styling can be applied to ```<table>``` and ```thead``` by creating a configuration file
5-
named ```markdown-table.ini``` in the ```configs``` directory.
3+
This plugin adds styling to markdown tables, by adding bootstrap classes. Styling can be applied to `<table>` and `thead` by creating a configuration file named `markdown-table.ini` in the `configs` directory.
64

75
#### Example
86

9-
```
7+
```ini
108
[bootstrap_class]
119
table = 'table table-striped'
1210
thead = 'thead-dark'
1311
```
14-
If not specified, the default styles ```'table table-striped``` and ```thead-dark``` are applied.
12+
Unless specified, the default styles `table table-striped` and `thead-dark` are applied.

packages/markdown-table/lektor_markdown_table.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,29 @@
33

44

55
class MarkdownTablePlugin(Plugin):
6-
name = 'markdown-table'
7-
description = u'This plugin adds styling to markdown tables'
6+
name = "markdown-table"
7+
description = "This plugin adds styling to markdown tables"
88

99
def get_style(self):
10-
table_class = self.get_config().get('bootstrap_class.table', 'table table-striped')
11-
thead_class = self.get_config().get('bootstrap_class.thead', 'thead-dark')
10+
table_class = self.get_config().get(
11+
"bootstrap_class.table", "table table-striped"
12+
)
13+
thead_class = self.get_config().get(
14+
"bootstrap_class.thead", "thead-dark"
15+
)
1216

1317
return [table_class, thead_class]
1418

1519
def style_table(self, header, body):
1620
table_class, thead_class = self.get_style()
1721
return (
1822
'<table class="%s">\n<thead class="%s">%s</thead>\n'
19-
'<tbody>\n%s</tbody>\n</table>\n'
23+
"<tbody>\n%s</tbody>\n</table>\n"
2024
) % (table_class, thead_class, header, body)
2125

2226
def on_markdown_config(self, config, **extra):
2327
class StyleTableMixin(object):
2428
def table(ren, header, body):
2529
return self.style_table(header, body)
30+
2631
config.renderer_mixins.append(StyleTableMixin)

packages/markdown-table/setup.py

+19-27
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,30 @@
1-
import ast
2-
import io
3-
import re
4-
51
from setuptools import setup, find_packages
2+
from os import path
63

7-
with io.open('README.md', 'rt', encoding="utf8") as f:
8-
readme = f.read()
94

10-
_description_re = re.compile(r'description\s+=\s+(?P<description>.*)')
5+
this_directory = path.abspath(path.dirname(__file__))
6+
with open(path.join(this_directory, "README.md"), encoding="utf-8") as f:
7+
long_description = f.read()
118

12-
with open('lektor_markdown_table.py', 'rb') as f:
13-
description = str(ast.literal_eval(_description_re.search(
14-
f.read().decode('utf-8')).group(1)))
9+
description = "This plugin adds styling to markdown tables"
1510

1611
setup(
17-
author='Shubham Pandey',
18-
author_email='shubhampcpandey13@gmail.com',
12+
author="Shubham Pandey",
13+
author_email="shubhampcpandey13@gmail.com",
1914
description=description,
20-
keywords='Lektor plugin',
21-
license='MIT',
22-
long_description=readme,
23-
long_description_content_type='text/markdown',
24-
name='lektor-markdown-table',
15+
keywords="Lektor plugin",
16+
license="MIT",
17+
long_description=long_description,
18+
long_description_content_type="text/markdown",
19+
name="lektor-markdown-table",
2520
packages=find_packages(),
26-
py_modules=['lektor_markdown_table'],
27-
# url='[link to your repository]',
28-
version='0.1',
29-
classifiers=[
30-
'Framework :: Lektor',
31-
'Environment :: Plugins',
32-
],
21+
py_modules=["lektor_markdown_table"],
22+
url="https://github.com/sp35/lektor-markdown-table",
23+
version="0.1",
24+
classifiers=["Framework :: Lektor", "Environment :: Plugins", ],
3325
entry_points={
34-
'lektor.plugins': [
35-
'markdown-table = lektor_markdown_table:MarkdownTablePlugin',
26+
"lektor.plugins": [
27+
"markdown-table = lektor_markdown_table:MarkdownTablePlugin",
3628
]
37-
}
29+
},
3830
)

0 commit comments

Comments
 (0)