This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo(object): | |
def __hash__(self): | |
return hash('.'.join([self.__class__.__module__, self.__class__.__name__])) | |
def __eq__(a, b): | |
return a.__hash__() == b.__hash__() | |
class Bar(Foo): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
DocData | |
A Meta-Data handler for lightweight markup languages. | |
Note: This was an experiment which was rejected in favor of a different API. | |
See the better implementation here: <https://github.com/waylan/docdata> | |
An implementation of Meta-Data as defined by MultiMarkdown. However, it can | |
work with any lightweight markup language and the various keys can have |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unittest | |
import os | |
import markdown | |
import codecs | |
import difflib | |
try: | |
import tidylib | |
except ImportError: | |
tidylib = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try: | |
from html.parser import HTMLParser | |
except ImportError: | |
from HTMLParser import HTMLParser | |
from enchant.checker import SpellChecker | |
class HTMLSpellChecker(HTMLParser): | |
""" | |
Check the spelling of an HTML document using the given SpellChecker. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*.pyc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
backtick `* | |
escape \\. | |
stem *** | |
st ** | |
em * | |
stem ___ | |
st __ | |
em _ | |
linkstart ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# | |
# HTMLTree | |
# | |
# An HTML Node Tree toolkit. | |
# | |
# -------------------------------------------------------------------- | |
# | |
# Copyright (c) 2015 by Waylan Limberg. All rights reserved. | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
A crazy Idea! | |
Just maybe, the way to parse HTML within a Markdown document is to run the document | |
through an HTML Parser first. Some parsers, like the HTMLParser included in the | |
Python Standard lib will properly parse the plain text not wrapped in HTML tags | |
as plain text and simply return it unaltered. The problem is with Markdown's | |
autolinks (`<foo@bar.com>` and `<http://example.com>`). | |
However, as of Python 2.7.3 and 3.2.2, the HTMLParser can now handle invalid HTML |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bs4.element import Tag, NavigableString | |
class Doc(Tag): | |
""" | |
Dumby Document Root. | |
This class provides a document root object without a parser. | |
The document will need to be built mannually by adding Tags, | |
NavigableStrings, Comments and the like. This class assumes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import shlex | |
import re | |
# Testing shlex with Unicode. | |
# | |
# The shlex module does not support Unicode input. Which workaround is faster? | |
# Sample string. Using an Attribute List from Maruku's syntax: | |
# http://maruku.rubyforge.org/proposal.html#attribute_lists | |
t = u'.foo #bar class=foo ref title="Foo \xc3 bar."' |
OlderNewer