Turn github into your publishing platform
Gitdown is a simple tool for writing documentation hosted on a github repository. It uses ditaa to convert ascii diagrams into images, and produces markdown documents that can be uploaded to your repository along with code. I made Gitdown so that we could write technical white papers and user guides as plain text (including diagrams) and publish them with a single "git push" command. Gitdown is a simpler version of the tool we use to maintain the ØMQ Guide.
Gitdown is written and maintained by Pieter Hintjens. Please use the issue tracker for all comments and errata. This document was published on Thursday February, 2017 at 20:23:49, and generated by the magic of Gitdown from README.txt.
This is version 2011.03.24 of Gitdown. Changelog:
Copyright (c) 2010-2011 Pieter Hintjens Copyright (c) 1996-2011 iMatix Corporation
This is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
The code is in the bin subdirectory. Here is how I install it on a new box:
sudo cp bin/* /usr/local/bin export PERLLIB=$PATH # goes into .bash_profile
Gitdown includes Ditaa/0.9 and assumes that Ditaa goes into /usr/local/bin/ditaa0_9.jar.
Another option is to leave the files in the git directory and install a wrapper script. Assuming the directory ~/bin exists and is in your path, you can do the following:
to install the file ~/bin/gitdown, which will set things up to run correctly.
Gitdown assumes that these tools are already installed on your box, which is easy if you're running Linux:
To use Gitdown, edit a text document much like this README.txt. Then:
gitdown myfile.txt git add myfile.md images/ git commit -m "Hey, Gitdown is totally crazy!" git push origin master
The images directory holds images for all documents in the current directory. You can write documents anywhere on the git tree but if they are not at the root you must tell Gitdown how to create a full image path by setting the SUBDIR symbol (see below).
Install apt-cyg - cygwin package manager:
lynx -source rawgit.com/transcode-open/apt-cyg/master/apt-cyg > apt-cyg install apt-cyg /bin
apt-cyg install ImageMagick
Download and install Java JDK from here, then restart your PC for the env vars to reflect
Copy the binaries to /usr/local/bin:
cp bin/* to /usr/local/bin
Add this to your ~/.bash_profile:
Gitdown exploits github.com's willingness to serve image blobs and Markdown documents that refer to them. This means you can publish a document with correctly-formatted links, together with images, in a single Git operation. It is a neat and comfortable way to work. Kudos to Stathis Sideris for making Ditaa. Gitdown also adds a preprocessing layer for symbolic insertion and simple macros like 'table of contents'. This code was recycled from htmlpp, a HTML preprocessor that looked a lot like Markdown.
The Gitdown workflow is:
This README acts as an example.
Gitdown is a pre-processor that adds these syntax elements on top of Markdown:
[diagram] Defines a ditaa diagram block [/diagram] # represents diagram number 1..n
.- comment Comment line .set name=value Sets Gitdown symbol .sub oldval=newval Replaces oldval by newval in every line .toc [top] Insert table of contents .pull srcfile[@tag][,opts] Pull a chunk of text, or the whole file, from srcfile .end Everything past this is ignored
$(xxx) Value of variable, anywhere in text $(xxx?zzz) Value of variable, or zzz if undefined %(text?zzz) Value of environment variable, or zzz if undef &abc(text) Intrinsic function with arguments
time() Format current time as hh:mm:ss date() Return current date value date("picture") Format current date using picture date("picture", date, lc) Format specified date using picture & language week_day([date]) Get day of week, 0=Sunday to 6=Saturday year_week([date]) Get week of year, 1 is first full week julian_date([date]) Get Julian date for date lillian_date([date]) Get Lillian date for date date_to_days(date) Convert yyyymmdd to Lillian date days_to_date(days) Convert Lillian date to yyyymmdd future_date(days[,date]) Calculate a future date past_date(days[,date]) Calculate a past date date_diff(date1[,date2]) Calculate date1 - date2 image_height("image.ext") Get image height (GIF, JPEG) image_width("image.ext") Get image width (GIF, JPEG) file_size("filename",arg) Get size of file: optional arg K or M file_date("filename") Get date of file file_time("filename") Get time of file as hh:mm:ss normalise("filename") Normalise filename to UNIX format system("command") Call a system utility lower("string") Convert string to lower case upper("string") Convert string to upper case
The top argument for .toc tells it the top header level in the text. Lower levels are shown horizontally. E.g. this file has level 2 headers in the text and uses
.toc 1to get these laid-out on a single row.
If the .pull command includes an optional @tag, the named chunk of text is pulled from the source file. A chunk of text is identified by '@tag' anywhere in the line before the chunk, and any other tag signalling the end. '@end' can be used to close any chunk. Tag names must be alphanumeric. If @tag is omitted, the entire file is included.
The opts argument for .pull can be: 'code' to indicate the results should be indented 4 spaces. An opts of 'left' removes any left margin.
These symbols have special meaning:
These symbols are predefined by gitdown for you:
This is an extract of the most useful Markdown syntax.
# Header 1 or follow by ===== on next line ## Header 2 or follow by ----- on next line ### Header 3 #### Header 4
> Blockquote can continue over multiple lines
List item can continue over multiple lines
code block indented 4 spaces
automatic link, e.g. image link text inline link [text] implicit reference link [text]: url defined later in document
emphasis usually, italics
strong usually, bold
Code fixed-space font
This documentation was generated from gitdown/README.txt using Gitdown