Mike Slinn

jekyll_archive_display

Published 2020-10-03. Last modified 2023-05-18.
Time to read: 1 minutes.

This page is part of the jekyll_plugins collection.

This Jekyll tag plugin ists the names and contents of each file in a tar file.

Installation

  1. Install libmagic.
    Ubuntu & WSL
    $ yes | sudo apt install libmagic-dev

    macOS
    $ brew install libmagic
  2. Add the following to Gemfile:
    Gemfile
    group :jekyll_plugins do 
      gem 'jekyll_archive_display'
    end 
  3. Add the following to _config.yml:
    _config.yml
    plugins:
      - archive_display
  4. From your Jekyll site's top-level directory, type:
    Shell
    $ bundle
  5. Restart Jekyll.

Syntax

HTML or markdown syntax
{% archive_display /relative/or/absolute/path/to/filename.tar %}

Output

For each text file within the tar file, the following HTML is generated:

Generated HTML
<div class='codeLabel'>{entry.full_name}{entry.mime_type}</div>
<pre data-lt-active='false'>{tar_entry.file_contents}</pre>
Sample CSS
.codeLabel {
  color: white;
  background-color: #666;
  margin-bottom: 0;
  padding-bottom: 0;
  padding-left: 1em;
}
.codeLabel+pre {
  margin-top: 0;
}
.codeLabel, pre {
  font-family: Monaco,"Bitstream Vera Sans Mono","Lucida Console",Terminal,monospace;
  font-stretch: semi-condensed;
}
pre {
  background: #78B4DB21;
  border: solid 1px #cecece;
  overflow: auto;
  padding: 4px;
  text-indent: initial;
  text-shadow: none;
}
pre {
  font-size: 11pt;
  margin-bottom: 30px;
  margin-left: 0;
  margin-right: 0;
}

Using the above CSS, text files within a tar file are displayed like this:

my_script.sh (text/x-shellscript; charset=us-ascii)
#!/bin/sh
echo "Hello, world"

Binary files are displayed like this:

usr/bin/ruby2.7 (application/x-sharedlib; charset=binary)
Binary file
* indicates a required field.

Please select the following to receive Mike Slinn’s newsletter:

You can unsubscribe at any time by clicking the link in the footer of emails.

Mike Slinn uses Mailchimp as his marketing platform. By clicking below to subscribe, you acknowledge that your information will be transferred to Mailchimp for processing. Learn more about Mailchimp’s privacy practices.