diff options
author | Jonas Smedegaard <dr@jones.dk> | 2024-03-31 19:26:24 +0200 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2024-03-31 20:59:50 +0200 |
commit | 29cee1399c977def72f1c8e1e13d83a841b75c89 (patch) | |
tree | faaf3d664342a86b4298f2c1e3d7fc81d46d908e /bin | |
parent | 13f1c4b7086981bddc7913837eeb1888f574ede0 (diff) |
tighten regex; strip special comment marker '%%QUARTO%%'
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/hedgedoc2quarto | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/bin/hedgedoc2quarto b/bin/hedgedoc2quarto index 6640b26..c0bde3b 100755 --- a/bin/hedgedoc2quarto +++ b/bin/hedgedoc2quarto @@ -36,12 +36,17 @@ die 'Too many arguments: expected INFILE and OUTFILE' if $bogus; @ARGV = ($infile) if $infile; my $content = do { local $/ = undef; <> }; -$content - =~ s/^(?'fence'[``~]{3,})\s*\Kmermaid\n(?'type'gantt)\n(?'code'.*?\n)\k'fence'$/ +$content =~ s/^ + (?'fence'[``~]{3,})\s* + \Kmermaid\n + (?'type'gantt)\n + (?'code'.*?\n) + \k'fence' + $/ "{mermaid}\n\%\%| fig-width: 100\%\n" . &mmd2mmd( $+{type}, $+{code} ) . $+{fence} - /gsme; + /gsmex; if ($outfile) { open( FH, '>', $outfile ) or die $!; @@ -53,9 +58,9 @@ else { sub mmd2mmd ( $type, $code ) { - if ( $type eq 'gantt' ) { - $code = "tickInterval 1month\n$code"; - } + + # strip special comment marker '%%QUARTO%%' + $code =~ s/^\s*+\K%%QUARTO%%//gm; return "$type\n$code"; } |