brettkromkamp / contextualise

Contextualise is an effective tool particularly suited for organising information-heavy projects and activities consisting of unstructured and widely diverse data and information resources
https://contextualise.dev/
MIT License
1.05k stars 44 forks source link

AttributeError AttributeError: module 'mistune' has no attribute 'html' #74

Closed brizzbane closed 4 years ago

brizzbane commented 4 years ago

This is my first time using contextualise.

Got it installed, created my first map. Then I went to edit the 'Home' topic for my map. I pasted in markdown text from a TiddlyWiki entry I had made.

It immediately went to this error page, and now when I go to 'view map', this same error page shows up.

AttributeError
AttributeError: module 'mistune' has no attribute 'html'

Traceback (most recent call last)
File "/home/brizz/Server/contextualise/.env/lib/python3.7/site-packages/flask/app.py", line 2464, in __call__
return self.wsgi_app(environ, start_response)
File "/home/brizz/Server/contextualise/.env/lib/python3.7/site-packages/flask/app.py", line 2450, in wsgi_app
response = self.handle_exception(e)
File "/home/brizz/Server/contextualise/.env/lib/python3.7/site-packages/flask/app.py", line 1867, in handle_exception
reraise(exc_type, exc_value, tb)
File "/home/brizz/Server/contextualise/.env/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/home/brizz/Server/contextualise/.env/lib/python3.7/site-packages/flask/app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "/home/brizz/Server/contextualise/.env/lib/python3.7/site-packages/flask/app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/brizz/Server/contextualise/.env/lib/python3.7/site-packages/flask/app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/brizz/Server/contextualise/.env/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/home/brizz/Server/contextualise/.env/lib/python3.7/site-packages/flask/app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "/home/brizz/Server/contextualise/.env/lib/python3.7/site-packages/flask/app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/brizz/Server/contextualise/contextualise/topic.py", line 136, in view
occurrences["text"] = mistune.html(occurrence.resource_data.decode())
AttributeError: module 'mistune' has no attribute 'html'

the last of the traceback:

File "/home/brizz/Server/contextualise/contextualise/topic.py", line 136, in view
        "notes": [],
    }
    for occurrence in topic_occurrences:
        if occurrence.instance_of == "text" and occurrence.scope == session["current_scope"]:
            if occurrence.resource_data:
                occurrences["text"] = mistune.html(occurrence.resource_data.decode())
        elif occurrence.instance_of == "image":
            occurrences["images"].append(
                {"title": occurrence.get_attribute_by_name(
                    "title").value, "url": occurrence.resource_ref, }
            )
AttributeError: module 'mistune' has no attribute 'html'

I tried uninstalling/reinstalling mistune with pip. ..no luck.

I created a new map, and just typed '123' in the topic edit--and reached the same page. So I'm wondering if maybe I screwed up install process somewhere?

Any help/guidance you can provide would be much appreciated.

brettkromkamp commented 4 years ago

@brizzbane Could you check which version of Mistune you have installed with pip list | grep 'mistune'?

If it is anything other than 2.0.0a4 then uninstall it with pip uninstall mistune and install the latest version (2.0.0a4) with pip install mistune==2.0.0a4.

That should fix the problem. Please let me know either way.

brizzbane commented 4 years ago

Yea I just came back to say I checked requirements.txt file... and my mistune version was wrong. I'm not sure how that happened... I did have some errors when running the initial install (pip install -e .) --related to needing apt-get isntall libpq-dev.. so I re-ran pip install -e . a few times.

I did:

pip uninstall mistune
pip install mistune==2.0.0a4

and that fixed it.

Thank you so much for your super quick reply!

brettkromkamp commented 4 years ago

@brizzbane You're welcome. If you have any questions (or hit any other bugs), just let me know :)

brizzbane commented 4 years ago

@brettkromkamp --since you offered :P

...how do you link to another topic (say "blah") w/in contextualise, (using markdown). I'm assuming linking:

[blah](http://127.0.0.1:5000/topic/s/view/blah/1)

isn't the right way to do it. I want to link within the original topic's text (not have link on the side, or below that shows that it may be related). ...so I will write about many different topics, and want to link to those other topics within the main text...

I'm super newb to this. ...If I am asking this question, is contextualise maybe 'too much' for what I'm wanting to do? (I love TiddlyWiki, ....but I also LOVE Python, and contextualise's multi-user capabilities..)

I've been looking for a minute now through docs/and the demo of contextualise. I would have just viewed the source of the topic to see how you do it--but I can't, since I'm not a user.

Sorry for so much text. Is my question clear?

brettkromkamp commented 4 years ago

You almost had it right [link-title](topic-identifier).

As an example, if you take a look at this page: https://www.contextualise.dev/topics/view/1/home

The second link (the one to "topic maps"... in Markdown it's just: [topic maps](topic-maps) with "topic maps" being the link text and "topic-maps" being the identifier of the topic I am linking to: https://www.contextualise.dev/topics/view/1/topic-maps.

At some point I will add auto-complete/type-ahead for topic identifiers in the Markdown editor. Just haven't got around to it.

You can see the topic identifier for a topic by either looking at the URL bar: the topic identifier is the last part of the URL: https://www.contextualise.dev/topics/view/1/topic-maps

Or, you can expand the topic properties panel (see screen snippet, below) by clicking on the "Properties" link next to the date just below the topic name.

contextualise-topic-identifier

brizzbane commented 4 years ago

lol--was just going to reply with this below ... and then your reply appeared. thank you!

@brizzbane You're welcome. If you have any questions (or hit any other bugs), just let me know :)

an example of what I am wondering how to do, look here:

https://contextualise.dev/topics/view/1/home

at the above site what is the proper way to link to "topic-maps". I'm hoping that it isn't just a hard link to exact url? ...that there is some way to actually link so that if topics-maps was renamed, the link would reflect that change w/out you having to update the text in view/1/home ...

---just wanted to be clear, understood your response, I guess I just wanted to reply and to say--I was looking at that exact page that you referenced, trying to figure out how you made that link.

Thanks for your help :). :+1:

brettkromkamp commented 4 years ago

Renaming the topic will not break the link in the Markdown. Topic names are independent of the topic's identifier. However, once you have created a topic (with an accompanying identifier), you cannot modify the identifier. In programming terms, the topic identifier is a constant.

With regards to renaming a topic, if you used the topic name as the link text and you want that to be reflected in the text then you would have to update the text manually. Where you wouldn’t have to manually update is with the “Related topic” links as it is using the actual association objects themselves. If this doesn’t make sense, let me know.

brettkromkamp commented 4 years ago

By the way, Contextualise (and topic maps-based systems in general) are more formal than (back)links-based systems like Roam and TiddlyWiki. So, Contextualise might not be as straightforward as those applications. Also, to get the most out of Contextualise, you really do need to have (at least) a basic understanding of how topic maps work otherwise it could be a frustrating experience.

If you haven’t already, take a look at the Knowledge Graph Radar, for other applications in this space: https://github.com/brettkromkamp/knowledge-graph-radar#applications-and-tools

Again, any questions... don't hesitate to ask :)

brettkromkamp commented 4 years ago

@brizzbane Here are a couple of good resources explaining topic maps:

brettkromkamp commented 4 years ago

@brizzbane If you have any questions with regards to using Contextualise, just let me know.