Coverage for C:\Repos\leo-editor\leo\plugins\writers\ctext.py: 25%

20 statements  

« prev     ^ index     » next       coverage.py v6.4, created at 2022-05-24 10:21 -0500

1#@+leo-ver=5-thin 

2#@+node:tbrown.20140804103545.29975: * @file ../plugins/writers/ctext.py 

3#@@language python 

4#@@tabwidth -4 

5import leo.plugins.writers.basewriter as basewriter 

6#@+others 

7#@+node:tbrown.20140804103545.29977: ** class CTextWriter 

8class CTextWriter(basewriter.BaseWriter): 

9 #@+others 

10 #@+node:tbrown.20140804103545.29978: *3* recurse 

11 def recurse(self, nd, level=0): 

12 self.put(nd.b.strip() + '\n\n') 

13 for child in nd.children(): 

14 txt = self.cchar * 3 + self.cchar * level + ' ' + child.h.strip() + ' ' 

15 txt += self.cchar * max(0, 75 - len(txt)) 

16 self.put(txt + '\n\n') 

17 self.recurse(child, level + 1) 

18 #@+node:tbrown.20140804103545.29979: *3* write 

19 def write(self, root): 

20 

21 self.cchar = '#' 

22 if root.h.lower()[-4:] == '.tex': 

23 self.cchar = '%' 

24 if root.h.lower()[-4:] == '.sql': 

25 self.cchar = '-' 

26 if root.h.lower()[-3:] == '.js': 

27 self.cchar = '/' 

28 self.recurse(root, 0) 

29 return True 

30 

31 #@-others 

32#@-others 

33writer_dict = { 

34 '@auto': ['@auto-ctext',], 

35 'class': CTextWriter, 

36} 

37#@@language python 

38#@@tabwidth -4 

39#@-leo