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
-
Install
libmagic.
Ubuntu & WSL$ yes | sudo apt install libmagic-dev
macOS$ brew install libmagic -
Add the following to
Gemfile:
Gemfilegroup :jekyll_plugins do gem 'jekyll_archive_display' end
-
Add the following to
_config.yml:
_config.ymlplugins: - archive_display
-
From your Jekyll site's top-level directory, type:
Shell$ bundle - 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