Mike Slinn
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, categorized under Jekyll.

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

Installation

  1. Install libmagic.
    Ubuntu & WSL
    Shell
    $ sudo apt install libmagic-dev
    Mac
    Shell
    $ 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

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

Output

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

<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