Skip to content
This repository has been archived by the owner on Sep 24, 2022. It is now read-only.

AttributeError: 'module' object has no attribute 'SmartyPants' #46

Closed
ghost opened this issue Oct 22, 2015 · 4 comments
Closed

AttributeError: 'module' object has no attribute 'SmartyPants' #46

ghost opened this issue Oct 22, 2015 · 4 comments

Comments

@ghost
Copy link

ghost commented Oct 22, 2015

I just updated my package this morning and then nothing is working anymore!

import os
import argparse
import json
import shutil
import misaka
import frontmatter
from pygments import highlight
from pygments.lexers import get_lexer_by_name
from pygments.formatters import HtmlFormatter
from jinja2 import Environment, FileSystemLoader  # PackageLoader
from datetime import datetime

class PygmentRender(misaka.HtmlRenderer, misaka.SmartyPants):

    def block_code(self, text, lang):
            print('[pyg][render] lang -> ', lang)
            if not lang:
                return '\n<pre><code>{}</code></pre>\n'.format(text)
            lexer = get_lexer_by_name(lang, stripall=True)
            formatter = HtmlFormatter(linenos='inline')
            # formatter = CodeHtmlFormatter(linenos='inline')
            return highlight(text, lexer, formatter)

Now i got this error every time i try to run the code

Traceback (most recent call last):
  File "/Users/vyscond/Tartarus/ephemerys/env/bin/ephemerys", line 9, in <module>
    load_entry_point('ephemerys==0.1.0', 'console_scripts', 'ephemerys')()
  File "/Users/vyscond/Tartarus/ephemerys/env/lib/python3.4/site-packages/pkg_resources/__init__.py", line 558, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/Users/vyscond/Tartarus/ephemerys/env/lib/python3.4/site-packages/pkg_resources/__init__.py", line 2682, in load_entry_point
    return ep.load()
  File "/Users/vyscond/Tartarus/ephemerys/env/lib/python3.4/site-packages/pkg_resources/__init__.py", line 2355, in load
    return self.resolve()
  File "/Users/vyscond/Tartarus/ephemerys/env/lib/python3.4/site-packages/pkg_resources/__init__.py", line 2361, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/Users/vyscond/Tartarus/ephemerys/env/lib/python3.4/site-packages/ephemerys/__init__.py", line 34, in <module>
    class PygmentRender(misaka.HtmlRenderer, misaka.SmartyPants):
AttributeError: 'module' object has no attribute 'SmartyPants'
@FSX
Copy link
Owner

FSX commented Oct 22, 2015

I've rewritten Misaka and introduced some changes that break compatibility with previous versions. The Smartypants mixin has been replaced with a function, smartypants. You can put the output of the markdown parser into that.

If you'd like to use the old API you can install the previous version of Misaka with: pip install 'misaka==1.0.2' and pin it in your requirements.txt with misaka==1.0.2.

@ghost
Copy link
Author

ghost commented Oct 23, 2015

Can you provide a example of how can we achieve the same results from the old example with the new API?

@FSX
Copy link
Owner

FSX commented Oct 23, 2015

Well, if you look at the documentation you see that it needs a string as input and returns a string. For example:

import misaka

s = misaka.html('some ... text ... here')
print(misaka.smartypants(s))

@mshava
Copy link

mshava commented Oct 16, 2017

Hi there,
Can you guys help me with this one module 'misaka' has no attribute 'html'

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants