Engine for LaTeX songbooks http://www.patacrep.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

37 lines
1.1 KiB

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import plasTeX
def split_linebreak(texlist):
return_list = []
current = []
for token in texlist:
if token.nodeName == '\\':
return_list.append(current)
current = []
else:
current.append(token.textContent.encode('utf-8'))
if current:
return_list.append(current)
return return_list
class beginsong(plasTeX.Command):
args = '{titles}[ args:dict ]'
def invoke(self, tex):
plasTeX.Command.invoke(self, tex)
# Parsing title
titles = []
for tokens in split_linebreak(self.attributes['titles'].allChildNodes):
titles.append("".join(tokens))
self.attributes['titles'] = titles
# Parsing keyval arguments
args = {}
for (key, val) in self.attributes['args'].iteritems():
if type(val) == unicode:
args[key] = val.encode('utf-8')
else:
args[key] = val.textContent.encode('utf-8')
self.attributes['args'] = args