Pandoc...omCode(3pm)

πŸ“¦
version 0.38 Β· 3 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

Pandoc::Filter::ImagesFromCode β€” the filter that literally turns your code blocks into images, bestie ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so picture this: this Pandoc::Filter takes CodeBlock elements and just... glow-up them into Image elements. Iconic behavior tbh πŸ’…

The content of every transformed code section and the resulting image files get written out to actual files. Like, real files on disk. No cap.

And the vibes? The title attribute gets mapped to the image title, and the caption attribute gets mapped to an image caption β€” if available, of course πŸŽ€


✨ CONFIGURATION ✨

Here's where you set the parameters of your little transformation era. Every single one, no skipping πŸ‘‘

  • from β€” the file extension of the input files that get extracted from code blocks. Defaults to code.
  • to β€” the file extension of the image files we create. Can be a plain fixed string, or a code reference πŸ‘€ β€” that code ref receives the document output format (like latex or html) as its argument, so you can produce different image formats depending on what you're outputting. Flexible queen.
  • name β€” a code reference that maps the CodeBlock element to a filename (no directory, no extension, just the name hun). By default it uses the element's id β€” but only if that id contains characters no other than a-zA-Z0-9_-. Otherwise? It's the MD5 hash of the element's content. Secure AND cute πŸ”
  • dir β€” the directory where input and output files go, relative to the current directory. This directory (default .) gets prepended to all image references in the target document. Keep your stuff tidy bestie 🧚
  • run β€” the command that transforms input files into output files. You can use variable references shaped like $...$ to refer to the current values of from, to, name, dir, infile and outfile. Example:
run => ['ditaa', '-o', '$infile$', '$outfile$'],
  • capture β€” captures the output of the command and writes it to outfile. Disabled by default. Off unless you say otherwise πŸ’€
  • force β€” applies the transformation even if the input and output file already exist and are unchanged. Disabled by default. Like, it'll redo the work anyway, stubborn but make it fashion πŸ’€

Heads up bestie: capture and force are both disabled by default, so don't come crying to me when your output didn't get captured or your unchanged files got skipped πŸ™ˆ

Mwah πŸ’‹ this page is part of the User Contributed Perl Documentation, running perl v5.38.2, dated 2024-08-03. Slay, go transform some code blocks 🫢

πŸ“¦ where this page comes from