diff options
author | Jonas Smedegaard <dr@jones.dk> | 2024-03-29 15:05:37 +0100 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2024-03-29 15:05:37 +0100 |
commit | 2b5f8d156053634fa845ad06b986fc73514e9b5d (patch) | |
tree | 02d0d9f97d19cd022b92afbdd9ec843117b84079 | |
parent | b1e19a9d8c9019d90f5450b14b536dc448830a9d (diff) |
isolate subroutine mmd2mmd
-rwxr-xr-x | bin/hedgedoc2quarto | 16 |
1 files changed, 13 insertions, 3 deletions
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 |