aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/literasc.py
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2013-12-25 17:59:16 +0000
committerDavid Robillard <d@drobilla.net>2013-12-25 17:59:16 +0000
commit8b1275387c758c1ee894647517e5fb30adaa3ea4 (patch)
tree8f498ea7f856c3acf20c30caeea89ba37036ceec /plugins/literasc.py
parent74c991974146ab389d66052de904a84b44adf3ad (diff)
downloadlv2-8b1275387c758c1ee894647517e5fb30adaa3ea4.tar.xz
Bookify examploscope documentation.
Fix book generator to include single-star C comments in code blocks.
Diffstat (limited to 'plugins/literasc.py')
-rwxr-xr-xplugins/literasc.py22
1 files changed, 18 insertions, 4 deletions
diff --git a/plugins/literasc.py b/plugins/literasc.py
index b7b65cd..7638e6f 100755
--- a/plugins/literasc.py
+++ b/plugins/literasc.py
@@ -36,16 +36,30 @@ def format_c_source(filename, file):
for line in file:
code += line
+ # Skip initial license comment
+ if code[0:2] == '/*':
+ code = code[code.find('*/') + 2:]
+
for c in code:
if prev_c == '/' and c == '*':
- output += format_code('c', chunk[0:len(chunk)-1])
- in_comment = True
in_comment_start = True
n_stars = 1
- chunk = ''
+ elif in_comment_start:
+ if c == '*':
+ n_stars += 1
+ else:
+ if n_stars > 1:
+ output += format_code('c', chunk[0:len(chunk)-1])
+ chunk = ''
+ in_comment = True
+ else:
+ chunk += '*' + c
+ in_comment_start = False
elif in_comment and prev_c == '*' and c == '/':
- if n_stars > 2:
+ if n_stars > 1:
output += format_text(chunk[0:len(chunk)-1])
+ else:
+ output += format_code('c', '/* ' + chunk[0:len(chunk)-1] + '*/')
in_comment = False
in_comment_start = False
chunk = ''