From 29cee1399c977def72f1c8e1e13d83a841b75c89 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Sun, 31 Mar 2024 19:26:24 +0200 Subject: tighten regex; strip special comment marker '%%QUARTO%%' --- bin/hedgedoc2quarto | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'bin') 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"; } -- cgit v1.2.3