|
@@ -59,7 +59,7 @@ class Builder(object): |
|
|
value = self._pop() |
|
|
value = self._pop() |
|
|
return Parameter(key, value, showkey) |
|
|
return Parameter(key, value, showkey) |
|
|
else: |
|
|
else: |
|
|
self._write(self._handle_token()) |
|
|
|
|
|
|
|
|
self._write(self._handle_token(token)) |
|
|
|
|
|
|
|
|
def _handle_template(self): |
|
|
def _handle_template(self): |
|
|
params = [] |
|
|
params = [] |
|
@@ -81,7 +81,7 @@ class Builder(object): |
|
|
name = self._pop() |
|
|
name = self._pop() |
|
|
return Template(name, params) |
|
|
return Template(name, params) |
|
|
else: |
|
|
else: |
|
|
self._write(self._handle_token()) |
|
|
|
|
|
|
|
|
self._write(self._handle_token(token)) |
|
|
|
|
|
|
|
|
def _handle_entity(self): |
|
|
def _handle_entity(self): |
|
|
token = self._tokens.pop(0) |
|
|
token = self._tokens.pop(0) |
|
@@ -103,7 +103,7 @@ class Builder(object): |
|
|
title = self._pop() |
|
|
title = self._pop() |
|
|
return Heading(title, level) |
|
|
return Heading(title, level) |
|
|
else: |
|
|
else: |
|
|
self._write(self._handle_token()) |
|
|
|
|
|
|
|
|
self._write(self._handle_token(token)) |
|
|
|
|
|
|
|
|
def _handle_attribute(self): |
|
|
def _handle_attribute(self): |
|
|
name, quoted = None, False |
|
|
name, quoted = None, False |
|
@@ -122,7 +122,7 @@ class Builder(object): |
|
|
return Attribute(name, self._pop(), quoted) |
|
|
return Attribute(name, self._pop(), quoted) |
|
|
return Attribute(self._pop(), quoted=quoted) |
|
|
return Attribute(self._pop(), quoted=quoted) |
|
|
else: |
|
|
else: |
|
|
self._write(self._handle_token()) |
|
|
|
|
|
|
|
|
self._write(self._handle_token(token)) |
|
|
|
|
|
|
|
|
def _handle_tag(self, token): |
|
|
def _handle_tag(self, token): |
|
|
type_, showtag = token.type, token.showtag |
|
|
type_, showtag = token.type, token.showtag |
|
@@ -146,10 +146,9 @@ class Builder(object): |
|
|
return Tag(type_, tag, contents, attrs, showtag, False, |
|
|
return Tag(type_, tag, contents, attrs, showtag, False, |
|
|
open_pad, token.padding) |
|
|
open_pad, token.padding) |
|
|
else: |
|
|
else: |
|
|
self._write(self._handle_token()) |
|
|
|
|
|
|
|
|
self._write(self._handle_token(token)) |
|
|
|
|
|
|
|
|
def _handle_token(self): |
|
|
|
|
|
token = self._tokens.pop(0) |
|
|
|
|
|
|
|
|
def _handle_token(self, token): |
|
|
if isinstance(token, tokens.Text): |
|
|
if isinstance(token, tokens.Text): |
|
|
return Text(token.text) |
|
|
return Text(token.text) |
|
|
elif isinstance(token, tokens.TemplateOpen): |
|
|
elif isinstance(token, tokens.TemplateOpen): |
|
@@ -165,5 +164,6 @@ class Builder(object): |
|
|
self._tokens = tokenlist |
|
|
self._tokens = tokenlist |
|
|
self._push() |
|
|
self._push() |
|
|
while self._tokens: |
|
|
while self._tokens: |
|
|
self._write(self._handle_token()) |
|
|
|
|
|
|
|
|
node = self._handle_token(self._tokens.pop(0)) |
|
|
|
|
|
self._write(node) |
|
|
return self._pop() |
|
|
return self._pop() |