Skip to content

Instantly share code, notes, and snippets.

@JAChapmanII
Last active August 29, 2015 14:27
Show Gist options
  • Save JAChapmanII/e5aa41c3fb4c4df733d0 to your computer and use it in GitHub Desktop.
Save JAChapmanII/e5aa41c3fb4c4df733d0 to your computer and use it in GitHub Desktop.
text.py
class Property:
def __init__(self):
pass
class Fragment:
def __init__(self, text, property):
this.text = text
this.property = property
class ParsedText:
def __init__(self, fragments, property):
this.fragments = fragments
this.property = property
def renderToHtml(parsedText): # text is alerady parsed
if len(parsedText.fragments) < 1: return ""
result = ""
for fragment in parsedText.fragments:
result += renderText(fragment, parsedText.property)
def renderHtml(frag, globalProperty):
pass
def renderText(frag, globalProperty):
return frag.text
def parse(string):
pass
text = "<em>html example</em> stuff"
parsedText = parse(text)
renderedText = renderToHtml(parsedText)
print(renderedText)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment