Skip to content

Commit a451785

Browse files
authored
Merge branch 'master' into internship_updates
2 parents d5750fe + 271c6f4 commit a451785

File tree

4 files changed

+76
-0
lines changed

4 files changed

+76
-0
lines changed

configs/markdown-table.ini

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[bootstrap_class]
2+
table = 'table table-striped'
3+
thead = 'thead-dark'

packages/markdown-table/README.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# markdown-table
2+
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.
4+
5+
#### Example
6+
7+
```ini
8+
[bootstrap_class]
9+
table = 'table table-striped'
10+
thead = 'thead-dark'
11+
```
12+
Unless specified, the default styles `table table-striped` and `thead-dark` are applied.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# -*- coding: utf-8 -*-
2+
from lektor.pluginsystem import Plugin
3+
4+
5+
class MarkdownTablePlugin(Plugin):
6+
name = "markdown-table"
7+
description = "This plugin adds styling to markdown tables"
8+
9+
def get_style(self):
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+
)
16+
17+
return [table_class, thead_class]
18+
19+
def style_table(self, header, body):
20+
table_class, thead_class = self.get_style()
21+
return (
22+
'<table class="%s">\n<thead class="%s">%s</thead>\n'
23+
"<tbody>\n%s</tbody>\n</table>\n"
24+
) % (table_class, thead_class, header, body)
25+
26+
def on_markdown_config(self, config, **extra):
27+
class StyleTableMixin(object):
28+
def table(ren, header, body):
29+
return self.style_table(header, body)
30+
31+
config.renderer_mixins.append(StyleTableMixin)

packages/markdown-table/setup.py

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from setuptools import setup, find_packages
2+
from os import path
3+
4+
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()
8+
9+
description = "This plugin adds styling to markdown tables"
10+
11+
setup(
12+
author="Shubham Pandey",
13+
author_email="shubhampcpandey13@gmail.com",
14+
description=description,
15+
keywords="Lektor plugin",
16+
license="MIT",
17+
long_description=long_description,
18+
long_description_content_type="text/markdown",
19+
name="lektor-markdown-table",
20+
packages=find_packages(),
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", ],
25+
entry_points={
26+
"lektor.plugins": [
27+
"markdown-table = lektor_markdown_table:MarkdownTablePlugin",
28+
]
29+
},
30+
)

0 commit comments

Comments
 (0)