-
Notifications
You must be signed in to change notification settings - Fork 844
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added pelican-gfm plugin #1224
base: master
Are you sure you want to change the base?
Added pelican-gfm plugin #1224
Changes from 1 commit
2f96d35
140ab9f
9b31101
44d5b95
886009c
284b90e
03dfb9d
963e121
469c99a
922db0c
962682a
7bb9115
6df3efd
f9518da
b897337
788e89b
8b6c56e
d22316b
a056e7e
76574fb
6439c43
4a932be
f57cf1d
7e8b15c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,8 +29,16 @@ | |
import pelican.utils | ||
import pelican.signals | ||
import pelican.readers | ||
from . import gfmSetup | ||
from . import Settings | ||
|
||
try: | ||
from . import gfmSetup | ||
except ImportError: | ||
import gfmSetup | ||
|
||
try: | ||
from . import Settings | ||
except: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you want to use this approach for imports I think this should only catch an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I ended up removing this entirely. |
||
import Settings | ||
|
||
_LIBDIR = Settings.LIBCMARKLOCATION | ||
_LIBCMARK = 'libcmark-gfm.so' | ||
|
@@ -204,13 +212,15 @@ def render(self, text): | |
|
||
def add_readers(readers): | ||
msg = "GFM plugin cannot find the required libcmark files.\ | ||
Please run python gfmSetup.py to build and\ | ||
configure the appropriate libcmark files" | ||
Please run python3 gfmSetup.py as a user with write permission \ | ||
to the directory into which the libcmark files will be placed." | ||
if gfmSetup.test_configuration(): | ||
readers.reader_classes['md'] = GFMReader | ||
return True | ||
else: | ||
raise Exception(msg) | ||
|
||
|
||
def register(): | ||
pelican.signals.readers_init.connect(add_readers) | ||
reader = pelican.signals.readers_init.connect(add_readers) | ||
return(reader) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/python -B | ||
|
||
import unittest | ||
|
||
# python2 and python3 differ on how to do this it seems | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See my other comment about |
||
try: | ||
from .gfm import * | ||
except ImportError: | ||
import gfm | ||
|
||
class gfmTest(unittest.TestCase): | ||
|
||
def test_for_gfm(self): | ||
self.assertTrue(gfm.register()) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose of this block with the relative import? If you are trying to maintain some compatibility with ancient Python versions can you solve this problem with the PEP 328
from __future__ import absolute_import
approach?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got the absolute imports working but now the plugin doesn't conform to your documentation.