Project

General

Profile

« Previous | Next » 

Revision 6684

dict2redmine: RedmineDictWriter: Link citations to entry in sources list

View differences:

dict2redmine
36 36

  
37 37
##### Redmine
38 38

  
39
sp = ' ' # Unicode thin space
40

  
39 41
def redmine_bold(text): return '*'+text+'*'
40 42

  
41 43
def redmine_url(text, url):
......
46 48
    if url: return redmine_url(url_term(url), simplify_url(url))
47 49
    else: return ''
48 50

  
51
def redmine_add_links(page_name, text):
52
    # Link citations to entry in sources list
53
    text = re.sub(r'(?<=\[)(.*?)(?=\])', sp+'[['+page_name+r'#\g<0>]]'+sp, text)
54
        # sp prevents [[[, which Redmine would parse incorrectly
55
    return text
56

  
49 57
class RedmineTableWriter:
50 58
    '''Formats rows as a Redmine table'''
51 59
    
......
62 70
        self.term_col = term_col
63 71
        self.def_col = def_col
64 72
        self.header = header
73
        self.page_name = header[term_col]
65 74
        self.stream = stream
66 75
    
67 76
    def writerow(self, row):
77
        row = map(lambda f: redmine_add_links(self.page_name, f), row)
78
        
68 79
        term = row[self.term_col]
69 80
        def_ = row[self.def_col]
70 81
        self.stream.write('h3. '+term+'\n\n')

Also available in: Unified diff