Esempio n. 1
0
def process(tree, profile, level=0):
    """
	Processes simplified tree, making it suitable for output as HTML structure
	@type tree: ZenNode
	@type profile: dict
	@type level: int
	"""
    if level == 0:
        # preformat tree
        tree = zen_coding.run_filters(tree, profile, '_format')
        zen_coding.max_tabstop = 0

    for item in tree.children:
        if item.type == 'tag':
            process_tag(item, profile, level)
        else:
            process_snippet(item, profile, level)

        # replace counters
        item.start = zen_coding.unescape_text(
            zen_coding.replace_counter(item.start, item.counter))
        item.end = zen_coding.unescape_text(
            zen_coding.replace_counter(item.end, item.counter))
        zen_coding.upgrade_tabstops(item)

        process(item, profile, level + 1)

    return tree
Esempio n. 2
0
def process(tree, profile, level=0):
	"""
	Processes simplified tree, making it suitable for output as HTML structure
	@type tree: ZenNode
	@type profile: dict
	@type level: int
	"""
	if level == 0:
		# preformat tree
		tree = zen_coding.run_filters(tree, profile, '_format')
		zen_coding.max_tabstop = 0
		
	for item in tree.children:
		if item.type == 'tag':
			process_tag(item, profile, level)
		else:
			process_snippet(item, profile, level)
	
		# replace counters
		item.start = zen_coding.unescape_text(zen_coding.replace_counter(item.start, item.counter))
		item.end = zen_coding.unescape_text(zen_coding.replace_counter(item.end, item.counter))
		zen_coding.upgrade_tabstops(item)
		
		process(item, profile, level + 1)
		
	return tree
Esempio n. 3
0
def process(tree, profile, level=0):
    """
	Processes simplified tree, making it suitable for output as HTML structure
	@type tree: ZenNode
	@type profile: dict
	@type level: int
	"""
    if level == 0:
        # preformat tree
        tree = zen_coding.run_filters(tree, profile, "_format")

    for i, item in enumerate(tree.children):
        if item.type == "tag":
            process_tag(item, profile, level)
        else:
            process_snippet(item, profile, level)

            # replace counters
        item.start = zen_coding.replace_counter(item.start, i + 1)
        item.end = zen_coding.replace_counter(item.end, i + 1)
        process(item, profile, level + 1)

    return tree
Esempio n. 4
0
def add_comments(node, i):
	
	"""
	Add comments to tag
	@type node: ZenNode
	@type i: int
	"""
	id_attr = node.get_attribute('id')
	class_attr = node.get_attribute('class')
	nl = zen_coding.get_newline()
		
	if id_attr or class_attr:
		comment_str = ''
		padding = node.parent and node.parent.padding or ''
		if id_attr: comment_str += '#' + id_attr
		if class_attr: comment_str += '.' + class_attr
		
		node.start = node.start.replace('<', '<!-- ' + comment_str + ' -->' + nl + padding + '<', 1)
		node.end = node.end.replace('>', '>' + nl + padding + '<!-- /' + comment_str + ' -->', 1)
		
		# replace counters
		node.start = zen_coding.replace_counter(node.start, i + 1)
		node.end = zen_coding.replace_counter(node.end, i + 1)
Esempio n. 5
0
def add_comments(node, i):
    """
	Add comments to tag
	@type node: ZenNode
	@type i: int
	"""
    id_attr = node.get_attribute('id')
    class_attr = node.get_attribute('class')
    nl = zen_coding.get_newline()

    if id_attr or class_attr:
        comment_str = ''
        padding = node.parent and node.parent.padding or ''
        if id_attr: comment_str += '#' + id_attr
        if class_attr: comment_str += '.' + class_attr

        node.start = node.start.replace(
            '<', '<!-- ' + comment_str + ' -->' + nl + padding + '<', 1)
        node.end = node.end.replace(
            '>', '>' + nl + padding + '<!-- /' + comment_str + ' -->', 1)

        # replace counters
        node.start = zen_coding.replace_counter(node.start, i + 1)
        node.end = zen_coding.replace_counter(node.end, i + 1)