pelican-plugins / render-math

Pelican plugin that renders mathematics via the MathJax JavaScript engine
Other
29 stars 7 forks source link

Development Installation 'module' object is not callable #10

Closed hno2 closed 4 years ago

hno2 commented 4 years ago

Hey,

sorry for my Newbie question, I guess I just need some pointers for a start. To help with the development of this plugin, I tried installing pelican+plugins as described here. I installed pelican and this plugin successful (both are visible as local projects with pip list). But when I try to add the plugin in the pelicanconfig.py (PLUGINS=["render_math"]) of a test blog I get the Error 'module' object is not callable.

My Folder Structure looks like this

|-- pelican
|   |-- docs
|   |-- pelican
|   |-- pelican.egg-info
|   | ...
|   `-- tox.ini
|-- pelican-plugins
|   `-- render-math
`-- test-blog
    |-- __pycache__
    |-- content
    |-- output
    |-- pelicanconf.py
    `-- publishconf.py

I am a bit confused by the whole namespace thing, do I need to import the package specifically somehow?

Thanks in Advance for your answer!

justinmayer commented 4 years ago

Hi @hno2. Start by taking a close look at the URL of the documentation you linked to. In addition to the outdated version number in the URL, at the very top of the page in the documentation you linked to, you will see a warning that you are looking at documentation for an old, out-of-date version of Pelican.

In short, you're looking at docs for Pelican 3.6.3 from several years ago, when things were quite different. For development, it's best to always use the development docs at the following link: https://docs.getpelican.com/en/latest/

Once there, you'll see that the set-up docs are very different from the steps you presumably followed to get to the point above. Using the proper steps, could you start over and let us know if you run into any questions?

hno2 commented 4 years ago

Hey @justinmayer! Thanks for your answer, indeed it seems like while I linked the old installation manual i actually followed the new one. (Sorry - No clue how that happend).

Nevertheless, I installed pelican again - starting from a fresh start. I can successfully run invoke tests for both pelican and render-math (and can confirm that these are the latest versions 4.5.0 and 1.0.2).

What is not working is setting up a new blog with the extension, as described above. I am pretty sure this is an error on my side (maybe with the folder structure), but I have no clue how to debug this.

This error only happens if math symbols are used in a markdown text.

justinmayer commented 4 years ago

What happens if you use pelican-quickstart to generate a totally fresh project and unmodified settings file? Do you get the same result?

hno2 commented 4 years ago

I dug a little deeper and installed both pelican and pelican-render-math in a new conda environment. And the same error occurs there. The "test-blog" was created with pelican-quickstart and no settings changed.

justinmayer commented 4 years ago

@moorepants: Hmm. Any idea what might cause the problem described in this issue?

jurasofish commented 4 years ago

I have the same issue. pelican --debug outputs

(jurasofish.github.io) C:\Users\michael\git\jurasofish.github.io>pelican --debug
DEBUG: Pelican version: 4.5.0
DEBUG: Python version: 3.7.7
DEBUG: Adding current directory to system path
DEBUG: Finding namespace plugins
DEBUG: Namespace plugins found:
  | pelican.plugins.render_math
DEBUG: Registering plugin `pelican.plugins.render_math`
WARNING: Docutils has no localization for 'english'. Using 'en' instead.
WARNING: Watched path does not exist: C:\Users\michael\git\jurasofish.github.io\content\images
DEBUG: Template list: ['!simple/archives.html', '!simple/article.html', '!simple/author.html', '!simple/authors.html', '!simple/base.html', '!simple/categories.html', '!simple/category.html', '!simple/gosquared.html', '!simpl
e/index.html', '!simple/page.html', '!simple/pagination.html', '!simple/period_archives.html', '!simple/tag.html', '!simple/tags.html', '!simple/translations.html', '!theme/analytics.html', '!theme/archives.html', '!theme/art
icle.html', '!theme/article_infos.html', '!theme/author.html', '!theme/authors.html', '!theme/base.html', '!theme/category.html', '!theme/comments.html', '!theme/disqus_script.html', '!theme/github.html', '!theme/index.html',
 '!theme/page.html', '!theme/period_archives.html', '!theme/tag.html', '!theme/taglist.html', '!theme/tags.html', '!theme/translations.html', '!theme/twitter.html', 'analytics.html', 'archives.html', 'article.html', 'article_
infos.html', 'author.html', 'authors.html', 'base.html', 'categories.html', 'category.html', 'comments.html', 'disqus_script.html', 'github.html', 'gosquared.html', 'index.html', 'page.html', 'pagination.html', 'period_archiv
es.html', 'tag.html', 'taglist.html', 'tags.html', 'translations.html', 'twitter.html']
DEBUG: Read file multilateration.md -> Article
DEBUG: Signal article_generator_preread.send(ArticlesGenerator)
DEBUG: Successfully loaded extension "pelican.plugins.render_math.pelican_mathjax_markdown_extension.PelicanMathJaxExtension".
DEBUG: Successfuly imported extension module "markdown.extensions.codehilite".
DEBUG: Successfully loaded extension "markdown.extensions.codehilite.CodeHiliteExtension".
DEBUG: Successfuly imported extension module "markdown.extensions.extra".
DEBUG: Successfully loaded extension "markdown.extensions.fenced_code.FencedCodeExtension".
DEBUG: Successfully loaded extension "markdown.extensions.footnotes.FootnoteExtension".
DEBUG: Successfully loaded extension "markdown.extensions.attr_list.AttrListExtension".
DEBUG: Successfully loaded extension "markdown.extensions.def_list.DefListExtension".
DEBUG: Successfully loaded extension "markdown.extensions.tables.TableExtension".
DEBUG: Successfully loaded extension "markdown.extensions.abbr.AbbrExtension".
DEBUG: Successfully loaded extension "markdown.extensions.extra.ExtraExtension".
DEBUG: Successfuly imported extension module "markdown.extensions.meta".
DEBUG: Successfully loaded extension "markdown.extensions.meta.MetaExtension".
ERROR: Could not process .\multilateration.md
  | 'module' object is not callable
  |___
  | Traceback (most recent call last):
  |   File "c:\users\michael\miniconda3\envs\jurasofish.github.io\lib\site-packages\pelican\generators.py", line 622, in generate_context
  |     context_sender=self)
  |   File "c:\users\michael\miniconda3\envs\jurasofish.github.io\lib\site-packages\pelican\readers.py", line 573, in read_file
  |     content, reader_metadata = reader.read(path)
  |   File "c:\users\michael\miniconda3\envs\jurasofish.github.io\lib\site-packages\pelican\readers.py", line 337, in read
  |     content = self._md.convert(text)
  |   File "c:\users\michael\miniconda3\envs\jurasofish.github.io\lib\site-packages\markdown\core.py", line 272, in convert
  |     newRoot = treeprocessor.run(root)
  |   File "c:\users\michael\miniconda3\envs\jurasofish.github.io\lib\site-packages\markdown\treeprocessors.py", line 372, in run
  |     self.__handleInline(text), child
  |   File "c:\users\michael\miniconda3\envs\jurasofish.github.io\lib\site-packages\markdown\treeprocessors.py", line 133, in __handleInline
  |     self.inlinePatterns[patternIndex], data, patternIndex, startIndex
  |   File "c:\users\michael\miniconda3\envs\jurasofish.github.io\lib\site-packages\markdown\treeprocessors.py", line 287, in __applyPattern
  |     node = pattern.handleMatch(match)
  |   File "c:\users\michael\miniconda3\envs\jurasofish.github.io\lib\site-packages\pelican\plugins\render_math\pelican_mathjax_markdown_extension.py", line 27, in handleMatch
  |     node = xml.etree.ElementTree(self.tag)
  | TypeError: 'module' object is not callable
-> Writing C:/Users/michael/git/jurasofish.github.io/docs/index.html
..........
justinmayer commented 4 years ago

Many thanks to @jurasofish for the fix for this issue, which I merged via 68cd8b9 and released as v1.0.3 PyPI. 🎉