sábado, 28 de febrero de 2015

Open source tools to document your software projects. Part 2: Pandoc

This is the second part of Open source tools to document your software projects if you want to read the fist part reviewing Markdown follow this link.

PANDOC

If you need to convert files from one markup format into another, pandoc is your swiss-army knife.[1]
Pandoc can convert documents in markdown, reStructuredText, textile, HTML, DocBook, LaTeX, MediaWiki markup, TWiki markup, OPML, Emacs Org-Mode, Txt2Tags, Microsoft Word docx, EPUB, or Haddock markup to HTML formats ( XHTML, HTML5, and HTML slide shows using Slidy, reveal.js, Slideous, S5, or DZSlides), Word processor  (Microsoft Word docx, OpenOffice/LibreOffice ODT, OpenDocument XML), Ebooks (EPUB version 2 or 3, FictionBook2), Documentation (DocBook, GNU TexInfo, Groff man pages, Haddock markup), Page layout formats(InDesign ICML), TeX formats(LaTeX, ConTeXt, LaTeX Beamer slides), PDF (via LaTeX), and Lightweight markup formats (Markdown, reStructuredText, AsciiDoc, MediaWiki markup, DokuWiki markup, Emacs Org-Mode, Textile), among others.

Getting pandoc

For Debian users pandoc is available from the official repositories. Get it with standard software applications
$ apt-get install pandoc -y

Using pandoc[2]

If the markdown formatted text is "pandoc.md" the following commands can be tested:

Markdown to HTML:
pandoc pandoc.md -o my_parsed_html.html
Markdown to an standalone HTML
pandoc -s pandoc.md -o my_parsed_html.html
Markdown to an standalone HTML with table of contents
pandoc -s --toc pandoc.md -o my_parsed_html.html
Markdown to  Latex
pandoc -s README -o example4.tex
Latex to Markdown
pandoc -s example4.tex -o example5.text
Markdown to PDF
pandoc -s example4.tex -o example5.text
To see more examples go to [2] or read the man page of pandoc. You can download the README file[3] and parse it to any other format by invoking pandoc and see the fancy output.

References

  1. from the creator of Pandoc at Pandoc webpage
  2. http://johnmacfarlane.net/pandoc/demos.html
  3. http://johnmacfarlane.net/pandoc/demo/README

martes, 24 de febrero de 2015

Open source tools to document your software projects. Part 1: Markdown

In the past weeks I've been preparing a set of three posts on tools for document your software projects. The main goal is to introduce the tool and not to make a complete wiki, so don't expect any detailed descriptions.

Do you document your software?


Most of the scientist when asked for their software project's documentation [1]

As a wannabe scientist I'm aware of the need of having reliable registers about all the work related to any scientific task, such as experiments, simulations, math, results, and so on. Most of the logs are taken either in paper or by type writting to digital documents (LaTex or equivalents). When the project involves software most of the scientist are not so familiar with tools as Doxygen or Sphinx(to mention a couple) due to the needed learning curve: "Ain't nobody got time for that!!". And all the "documenting" lies on tons of commented code lines which rarely will be seen when using the libraries and stuff. In the process of developing and documenting my software I became aware of several tools which could come in handy to other scientist/programmers. That is the motivation to review three tools

  1. Markdown
  2. Pandoc
  3. Doxygen

MARKDOWN  [2][3]


Markdown is intended to be as easy-to-read and easy-to-write as is feasible,and is a text-to-HTML conversion tool for web writers. Markdown allows you to write using an easy-to-read, easy-to-write plain text format, then convert it to structurally valid XHTML (or HTML).[3]
Created in 2004 by John Gruber and Aaron Swartz[2] Markdown provides a easy way to create HTML formatted filesout of plain text. Once the markdown file is parsed, one obtains a pretty good looking html wich can be embeded or distributed with your software in order to make more friendly the project, (or uploaded to your blog ;) ).
Every markdown file consist of plain text file with extension .md or .mkd (or without any extension since the processor that receives the plaintext file detects the markdown format. But is good to have an extension).

Markdown basics [4][5]

A good summary of Markdown syntax is [5]

Headers

# This is an <h1> tag
## This is an <h2> tag
###### This is an <h6> tag

Emphasis

*This text will be italic*
_This will also be italic_

**This text will be bold**
__This will also be bold__

*You **can** combine them*

Lists

Unordered

* Item 1
* Item 2
  * Item 2a
  * Item 2b

Ordered

1. Item 1
2. Item 2
3. Item 3
   * Item 3a
   * Item 3b

Links

http://github.com - automatic!
[GitHub](http://github.com)

Blockquotes

As Kanye West said:

> We're living the future so
> the present is our past.

Inline code

I think you should use an
`<addr>` element here instead.

A good markdown how-to is provided by github


A good example of a Markdown text is
Heading
 =======

 Sub-heading
 -----------

 ### Another deeper heading

 Paragraphs are separated
 by a blank line.

 Let 2 spaces at the end of a line to do a
 line break

 Text attributes *italic*, **bold**,
 `monospace`, ~~strikethrough~~ .

 A [link](http://example.com).
 <<<   No space between ] and (  >>>

 Shopping list:

   * apples
   * oranges
   * pears

 Numbered list:

   1. apples
   2. oranges
   3. pears

 The rain---not the reign---in
 Spain.

The parsed output is

Heading
Sub-heading
Another deeper heading
Paragraphs are separated by a blank line.
Let 2 spaces at the end of a line to do a
line break
Text attributes italicboldmonospacestrikethrough.
link.
Shopping list:
  • apples
  • oranges
  • pears
Numbered list:
  1. apples
  2. oranges
  3. pears
The rain—not the reign—in Spain.

Parsing the document


To parse markdown formatted text you need to have markdown installed on your system. Debian based should have markdown on their official repositories (Debian Jessie - Testing has it)

# apt-get install markdown

Should do the job (obviously as root user).

To parse the text

$ markdown mymark.md > mymarkparsed.html
The html file can be opened with your favorite web browser.

Some remarks

  • Given that Markdown does not count with any standard[2] several software organizations have developed markdown versions adding new features. One example is the git-flavoured markdown syntax as decribed on [5]
  • Once the markdown is parsed, one obtains a pretty good looking html wich can be embeded or distributed with your software in order to make more friendly the project.

References

  1. "Ain't no body got time for that"
  2. http://en.wikipedia.org/wiki/Markdown
  3. http://daringfireball.net/projects/markdown/
  4. http://daringfireball.net/projects/markdown/syntax
  5. https://guides.github.com/features/mastering-markdown/
  6. http://en.wikipedia.org/wiki/Markdown#Example

martes, 17 de febrero de 2015

Set the application to open magnet links on Google-Chrome

Motivation

As a Google-chrome user I wanted to know a way to set up the system to open the magnet links.
Firefox/Iceweasel users know that Firefox handles the default applications by itself, but Google-Chrome (and i think that Chromium) lies on xdg-open. So we need to tell xdg-open how to deal with magnet links

Finding your torrent application

To find your favorite torrent application you must go to 
/usr/share/applications/
And look for a file like 
your_favorite_torrent_app.desktop
In my case It was 
transmission-gtk.desktop
You must check that the file contains the following lines (for my case, transmission-gtk)

...
Exec=transmission-gtk %U
Icon=transmission
Terminal=false
TryExec=transmission-gtk
Type=Application
StartupNotify=true
MimeType=application/x-bittorrent;x-scheme-handler/magnet;
Categories=Network;FileTransfer;P2P;GTK;
X-Ubuntu-Gettext-Domain=transmission
X-AppInstall-Keywords=torrent
Actions=Pause;Minimize;
...

The lines in bold are the important.

Configuring xdg-open

If everything is alright you can call xdg-mime command as root
# xdg-mime default transmission-gtk.desktop x-scheme-handler/magnet
wich tells xdg-open that magnet links should be opened with transmission-gtk.

That's it, all you have to do is test that everything went ok by opening a fancy legal torrent magnet link.

References