summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2021-08-20 17:13:41 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2021-08-20 17:13:41 +0200
commit485441d3523857b1394f4ea8c679b372aed18704 (patch)
tree85efaff830f88beedd587ff6bf6a68e8cb1efbfe
parentMake use of pythons regex strings. (diff)
downloadvimwiki-scripts-485441d3523857b1394f4ea8c679b372aed18704.tar.gz
vimwiki-scripts-485441d3523857b1394f4ea8c679b372aed18704.tar.xz
Add options["mode"] == "tex".
-rwxr-xr-xdo.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/do.py b/do.py
index 2506f6d..897f028 100755
--- a/do.py
+++ b/do.py
@@ -245,6 +245,7 @@ if mode == 'tex':
\\usepackage{{parskip}}
\\usepackage{{fancyhdr}}
\\usepackage{{hyperref}}
+ \\usepackage{{soul}}
''')
@@ -314,7 +315,10 @@ for match in tag_iter:
outstr += page1[pos:]
-options = { 'date': '\\today' if mode == 'tex' else f'{datetime.now():%Y-%m-%d}' }
+options = {
+ 'date': '\\today' if mode == 'tex' else f'{datetime.now():%Y-%m-%d}',
+ 'mode': 'vimwiki',
+ }
# split the text into paragraph blocks
lines = outstr.split('\n')
@@ -334,7 +338,7 @@ for line in lines:
# into variables
for i in range(len(paragraphs[0])):
line = paragraphs[0][i]
- if m := re.match('- (\w+)\s*::\s*(.*)', line):
+ if m := re.match('^(\w+)\s*::\s*(.*)', line):
if m[1] == 'date':
dt = dtparser.parse(m[2])
if mode == 'tex':
@@ -362,7 +366,10 @@ if mode == 'tex':
\\maketitle
% \\tableofcontents
""")
- output.write('\\begin{verbatim}\n')
+ if options['mode'] == 'tex':
+ pass
+ else:
+ output.write('\\begin{verbatim}\n')
elif mode == 'txt':
d = options['date']
output.write(f'\n{heading.center(40)}\n{d.center(40)}\n')
@@ -373,7 +380,11 @@ for paragraph in paragraphs:
# output.write(outstr + '\n')
if mode == 'tex':
- output.write('\\end{verbatim}\n\\appendix\n')
+ if options['mode'] == 'tex':
+ pass
+ else:
+ output.write('\\end{verbatim}\n')
+ output.write('\\appendix\n')
output.write('\n'.join(bilagor))