Made imports cleaner.
This commit is contained in:
parent
c837bcf69b
commit
e5084dba74
|
@ -2,3 +2,4 @@ __pycache__
|
|||
/test.py
|
||||
/*.egg-info
|
||||
/dist
|
||||
/.spyproject
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
# This file is part of the textoutpc project, which is MIT-licensed.
|
||||
#******************************************************************************
|
||||
|
||||
from ..base import *
|
||||
from ..base import TextoutBlockTag as _TextoutBlockTag
|
||||
|
||||
__all__ = ["TextoutAlignTag"]
|
||||
|
||||
class TextoutAlignTag(TextoutBlockTag):
|
||||
class TextoutAlignTag(_TextoutBlockTag):
|
||||
""" Main tag for aligning paragraphs.
|
||||
Example uses:
|
||||
|
||||
|
|
|
@ -4,11 +4,12 @@
|
|||
# This file is part of the textoutpc project, which is MIT-licensed.
|
||||
#******************************************************************************
|
||||
|
||||
from ..base import *
|
||||
from ..base import TextoutBlockTag as _TextoutBlockTag, \
|
||||
TextoutInlineTag as _TextoutInlineTag
|
||||
|
||||
__all__ = ["TextoutCodeTag", "TextoutInlineCodeTag", "TextoutNoEvalTag"]
|
||||
|
||||
class TextoutCodeTag(TextoutBlockTag):
|
||||
class TextoutCodeTag(_TextoutBlockTag):
|
||||
""" The basic code tag, for displaying code.
|
||||
Example uses:
|
||||
|
||||
|
@ -33,7 +34,7 @@ class TextoutCodeTag(TextoutBlockTag):
|
|||
def end_lightscript(self):
|
||||
return '```\n'
|
||||
|
||||
class TextoutInlineCodeTag(TextoutInlineTag):
|
||||
class TextoutInlineCodeTag(_TextoutInlineTag):
|
||||
""" Inline code tag, doesn't display a box, simply doesn't evaluate
|
||||
the content and uses monospace font.
|
||||
Example uses:
|
||||
|
@ -59,7 +60,7 @@ class TextoutInlineCodeTag(TextoutInlineTag):
|
|||
def end_lightscript(self):
|
||||
return '`'
|
||||
|
||||
class TextoutNoEvalTag(TextoutInlineTag):
|
||||
class TextoutNoEvalTag(_TextoutInlineTag):
|
||||
""" Inline code tag, simply doesn't evaluate the content.
|
||||
Example uses:
|
||||
|
||||
|
|
|
@ -4,13 +4,12 @@
|
|||
# This file is part of the textoutpc project, which is MIT-licensed.
|
||||
#******************************************************************************
|
||||
|
||||
from ..base import *
|
||||
from urllib.parse import urlparse
|
||||
from ..base import TextoutBlockTag as _TextoutBlockTag
|
||||
from html import escape as _htmlescape
|
||||
|
||||
__all__ = ["TextoutImageTag", "TextoutAdminImageTag"]
|
||||
|
||||
class TextoutImageTag(TextoutBlockTag):
|
||||
class TextoutImageTag(_TextoutBlockTag):
|
||||
""" The main tag for displaying an image.
|
||||
Example uses:
|
||||
|
||||
|
|
|
@ -4,14 +4,14 @@
|
|||
# This file is part of the textoutpc project, which is MIT-licensed.
|
||||
#******************************************************************************
|
||||
|
||||
from ..base import *
|
||||
from ..base import TextoutInlineTag as _TextoutInlineTag
|
||||
import re as _re
|
||||
|
||||
__all__ = ["TextoutLabelTag", "TextoutTargetTag"]
|
||||
|
||||
_labelexpr = _re.compile('^[a-z0-9-]{1,16}$', _re.I)
|
||||
|
||||
class TextoutLabelTag(TextoutInlineTag):
|
||||
class TextoutLabelTag(_TextoutInlineTag):
|
||||
""" The label tag, defines an anchor at a point of the post.
|
||||
Example uses:
|
||||
|
||||
|
@ -33,7 +33,7 @@ class TextoutLabelTag(TextoutInlineTag):
|
|||
name = self.tweak("label_prefix", "") + self._label
|
||||
return '<a name="{}"></a>'.format(name)
|
||||
|
||||
class TextoutTargetTag(TextoutInlineTag):
|
||||
class TextoutTargetTag(_TextoutInlineTag):
|
||||
""" The goto tag, links to an anchor defined in the post.
|
||||
Example uses:
|
||||
|
||||
|
|
|
@ -4,12 +4,12 @@
|
|||
# This file is part of the textoutpc project, which is MIT-licensed.
|
||||
#******************************************************************************
|
||||
|
||||
from ..base import *
|
||||
from ..base import TextoutInlineTag as _TextoutInlineTag
|
||||
from html import escape as _htmlescape
|
||||
|
||||
__all__ = ["TextoutLinkTag", "TextoutProfileTag"]
|
||||
|
||||
class TextoutLinkTag(TextoutInlineTag):
|
||||
class TextoutLinkTag(_TextoutInlineTag):
|
||||
""" The main link tag.
|
||||
Example uses:
|
||||
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
# This file is part of the textoutpc project, which is MIT-licensed.
|
||||
#******************************************************************************
|
||||
|
||||
from ..base import *
|
||||
from ..base import TextoutBlockTag as _TextoutBlockTag
|
||||
|
||||
__all__ = ["TextoutProgressTag"]
|
||||
|
||||
class TextoutProgressTag(TextoutBlockTag):
|
||||
class TextoutProgressTag(_TextoutBlockTag):
|
||||
""" Progress tag, used to display the progress on anything.
|
||||
Usage:
|
||||
|
||||
|
|
|
@ -4,13 +4,13 @@
|
|||
# This file is part of the textoutpc project, which is MIT-licensed.
|
||||
#******************************************************************************
|
||||
|
||||
from ..base import *
|
||||
from ..base import TextoutBlockTag as _TextoutBlockTag
|
||||
from html import escape as _htmlescape
|
||||
from ...smileys import htmlsmileys as _htmlsmileys
|
||||
|
||||
__all__ = ["TextoutQuoteTag"]
|
||||
|
||||
class TextoutQuoteTag(TextoutBlockTag):
|
||||
class TextoutQuoteTag(_TextoutBlockTag):
|
||||
""" The main tag for quoting someone.
|
||||
Example uses:
|
||||
|
||||
|
|
|
@ -4,13 +4,12 @@
|
|||
# This file is part of the textoutpc project, which is MIT-licensed.
|
||||
#******************************************************************************
|
||||
|
||||
from ..base import *
|
||||
from ..base import TextoutInlineTag as _TextoutInlineTag
|
||||
import string as _string
|
||||
from html import escape as _htmlescape
|
||||
|
||||
__all__ = ["TextoutRotTag"]
|
||||
|
||||
class TextoutRotTag(TextoutInlineTag):
|
||||
class TextoutRotTag(_TextoutInlineTag):
|
||||
""" Tag which un-rot13 a content.
|
||||
Demonstration tag for content processing.
|
||||
Example uses:
|
||||
|
|
|
@ -4,12 +4,12 @@
|
|||
# This file is part of the textoutpc project, which is MIT-licensed.
|
||||
#******************************************************************************
|
||||
|
||||
from ..base import *
|
||||
from ..base import TextoutBlockTag as _TextoutBlockTag
|
||||
from html import escape as _htmlescape
|
||||
|
||||
__all__ = ["TextoutShowTag"]
|
||||
|
||||
class TextoutShowTag(TextoutBlockTag):
|
||||
class TextoutShowTag(_TextoutBlockTag):
|
||||
""" Tag which shows the HTML code that is produced by textout().
|
||||
Example uses:
|
||||
|
||||
|
|
|
@ -4,13 +4,13 @@
|
|||
# This file is part of the textoutpc project, which is MIT-licensed.
|
||||
#******************************************************************************
|
||||
|
||||
from ..base import *
|
||||
from ..base import TextoutBlockTag as _TextoutBlockTag
|
||||
from html import escape as _htmlescape
|
||||
from ...smileys import htmlsmileys as _htmlsmileys
|
||||
|
||||
__all__ = ["TextoutSpoilerTag"]
|
||||
|
||||
class TextoutSpoilerTag(TextoutBlockTag):
|
||||
class TextoutSpoilerTag(_TextoutBlockTag):
|
||||
""" Hide content at first glance, force people to click to read content.
|
||||
These elements can contain 'secret' elements such as solutions, source
|
||||
code, or various other things.
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
# This file is part of the textoutpc project, which is MIT-licensed.
|
||||
#******************************************************************************
|
||||
|
||||
from ..base import *
|
||||
from ..base import TextoutInlineTag as _TextoutInlineTag
|
||||
from ...color import get_color
|
||||
|
||||
__all__ = ["TextoutTextTag"]
|
||||
|
@ -30,7 +30,7 @@ _fonts = {
|
|||
# Tag definition.
|
||||
# ---
|
||||
|
||||
class TextoutTextTag(TextoutInlineTag):
|
||||
class TextoutTextTag(_TextoutInlineTag):
|
||||
""" Main tag for setting text formatting.
|
||||
Example uses:
|
||||
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
# This file is part of the textoutpc project, which is MIT-licensed.
|
||||
#******************************************************************************
|
||||
|
||||
from ..base import *
|
||||
from ..base import TextoutBlockTag as _TextoutBlockTag
|
||||
|
||||
__all__ = ["TextoutTitleTag"]
|
||||
|
||||
class TextoutTitleTag(TextoutBlockTag):
|
||||
class TextoutTitleTag(_TextoutBlockTag):
|
||||
""" The title tag.
|
||||
Example uses:
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
# This file is part of the textoutpc project, which is MIT-licensed.
|
||||
#******************************************************************************
|
||||
|
||||
from ..base import *
|
||||
from ..base import TextoutBlockTag as _TextoutBlockTag
|
||||
import re as _re
|
||||
import urllib.parse as _urlparse
|
||||
from html import escape as _htmlescape
|
||||
|
@ -15,7 +15,7 @@ _hexcode = _re.compile('[a-zA-Z0-9_]+')
|
|||
_numcode = _re.compile('^/[0-9]+$')
|
||||
_dailypath = _re.compile('^/video/([a-z0-9]+)$')
|
||||
|
||||
class TextoutVideoTag(TextoutBlockTag):
|
||||
class TextoutVideoTag(_TextoutBlockTag):
|
||||
""" The video tag, puts a preview of the video whose URL is given.
|
||||
Only a few 'big' services are supported for now.
|
||||
Example uses:
|
||||
|
|
|
@ -7,12 +7,12 @@
|
|||
See the `Translator` class documentation for more information.
|
||||
"""
|
||||
|
||||
import regex as _re, string as _string
|
||||
import string as _string
|
||||
from copy import deepcopy as _deepcopy
|
||||
from html import escape as _htmlescape
|
||||
from .tags import TextoutInlineTag, TextoutBlockTag, \
|
||||
TextoutParagraphTag, get_tag
|
||||
from .stream import *
|
||||
from .tags import TextoutBlockTag as _TextoutBlockTag, \
|
||||
TextoutParagraphTag as _TextoutParagraphTag, get_tag as _get_tag
|
||||
from .stream import TextoutStream as _TextoutStream
|
||||
from .smileys import htmlsmileys as _htmlsmileys
|
||||
from .urls import htmlurls as _htmlurls
|
||||
|
||||
|
@ -56,7 +56,7 @@ class _TagData:
|
|||
# `full` is the full tag beginning mark.
|
||||
|
||||
self.name = name
|
||||
self.type = self.BLOCK if isinstance(tag, TextoutBlockTag) \
|
||||
self.type = self.BLOCK if isinstance(tag, _TextoutBlockTag) \
|
||||
else self.INLINE
|
||||
self.full = full
|
||||
|
||||
|
@ -293,26 +293,6 @@ class Translator:
|
|||
def put_newline(self):
|
||||
""" Put a newline. """
|
||||
|
||||
# As in `flush_text()`, the last queue is composed of booleans.
|
||||
# We want to set all of the booleans to True until the first text
|
||||
# group, to which we want to add the current text.
|
||||
# If there is no content preprocessing and we have to output it,
|
||||
# we want to start the tags first: `dat == None` will be our signal!
|
||||
|
||||
for dat in self.queue:
|
||||
if isinstance(dat.last, bool):
|
||||
dat.last = True
|
||||
continue
|
||||
dat.last += code
|
||||
break
|
||||
else:
|
||||
dat = None
|
||||
|
||||
# If we ought to put a newline, that means that the paragraph content
|
||||
# is starting and that we might have to put the start of paragraph.
|
||||
|
||||
self.start_tags()
|
||||
|
||||
# The newline depends on the output type and the context, of course.
|
||||
|
||||
if self.output_type == 'html' and not self.raw_mode:
|
||||
|
@ -331,8 +311,6 @@ class Translator:
|
|||
def push_tag(self, dat):
|
||||
""" Push a tag onto the tag stack. """
|
||||
|
||||
tag = dat.tag
|
||||
|
||||
# If the tag does not process its content but replaces the content,
|
||||
# that means the content is ignored.
|
||||
|
||||
|
@ -575,14 +553,14 @@ class Translator:
|
|||
# By default, everything is in a paragraph.
|
||||
# Other blocks will supplant this by being further in the queue.
|
||||
|
||||
self.push_tag(_TagData(TextoutParagraphTag(None, None,
|
||||
self.push_tag(_TagData(_TextoutParagraphTag(None, None,
|
||||
self.output_type, self.tweaks), None, ''))
|
||||
|
||||
# We want to get our elements out of the element stream (Lephe
|
||||
# told me that the `TextoutStream` class was actually a lexer,
|
||||
# but as I don't know the theory behind this...).
|
||||
|
||||
for element in TextoutStream(self.inp):
|
||||
for element in _TextoutStream(self.inp):
|
||||
# If it is a string or a newline, let's just put it.
|
||||
# Otherwise, the element is some tag data or at least something
|
||||
# that requires some special processing.
|
||||
|
@ -677,7 +655,7 @@ class Translator:
|
|||
# Get the initialized tag with the name and value.
|
||||
# If the tag is unknown, output the full thing and just go on.
|
||||
|
||||
tag = get_tag(tagdata.name, tagdata.value, self.output_type,
|
||||
tag = _get_tag(tagdata.name, tagdata.value, self.output_type,
|
||||
self.tweaks)
|
||||
if not tag:
|
||||
self.put_text(tagdata.full)
|
||||
|
@ -691,7 +669,7 @@ class Translator:
|
|||
# Push a paragraph tag if the block is a superblock.
|
||||
|
||||
if dat.type == dat.BLOCK and dat.super:
|
||||
self.push_tag(_TagData(TextoutParagraphTag(None, None,
|
||||
self.push_tag(_TagData(_TextoutParagraphTag(None, None,
|
||||
self.output_type, self.tweaks), None, ''))
|
||||
|
||||
# End of file, it seems! Let's close the tags, flush the text
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
""" Autolinking (URL extraction from raw text) in HTML. """
|
||||
|
||||
import regex as _re
|
||||
from html import escape as _htmlescape
|
||||
|
||||
__all__ = ["htmlurls", "lightscripturls"]
|
||||
|
||||
|
|
Loading…
Reference in New Issue