diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2021-08-20 17:13:41 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2021-08-20 17:13:41 +0200 |
commit | 485441d3523857b1394f4ea8c679b372aed18704 (patch) | |
tree | 85efaff830f88beedd587ff6bf6a68e8cb1efbfe | |
parent | Make use of pythons regex strings. (diff) | |
download | vimwiki-scripts-485441d3523857b1394f4ea8c679b372aed18704.tar.gz vimwiki-scripts-485441d3523857b1394f4ea8c679b372aed18704.tar.xz |
Add options["mode"] == "tex".
-rwxr-xr-x | do.py | 19 |
1 files changed, 15 insertions, 4 deletions
@@ -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)) |