From 2b5f8d156053634fa845ad06b986fc73514e9b5d Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Fri, 29 Mar 2024 15:05:37 +0100 Subject: isolate subroutine mmd2mmd --- bin/hedgedoc2quarto | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'bin/hedgedoc2quarto') diff --git a/bin/hedgedoc2quarto b/bin/hedgedoc2quarto index 21f8158..1aac608 100755 --- a/bin/hedgedoc2quarto +++ b/bin/hedgedoc2quarto @@ -35,9 +35,11 @@ die 'Too many arguments: expected INFILE and OUTFILE' if $bogus; @ARGV = ($infile) if $infile; my $content = <>; -$content =~ s/^(?'fence'[``~]{3,})\s*\Kmermaid\n(?'type'gantt)\n(?'code'.*?\n)\k'fence'$/{mermaid}\n%%| fig-width: 100%\n$+{type}\n$+{code}$+{fence}/gsm; - -$content =~ s/^gantt\K$/\ntickInterval 1month/gm; +$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; if ($outfile) { open(FH, '>', $outfile) or die $!; @@ -46,6 +48,14 @@ if ($outfile) { print $content; } +sub mmd2mmd( $type, $code ) { + if ( $type eq 'gantt' ) { + $code = "tickInterval 1month\n$code"; + } + + return "$type\n$code"; +} + =encoding UTF-8 =head1 AUTHOR -- cgit v1.2.3