Skip to content

Radoq10288/text-to-html

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

txt2html (text to html)

About

A program that accept a text (*.txt) file and convert it to html (*.html) file.

Requirement

An installation of MinGW is required to build, compile, and install this program in windows.

Note:
For those who are new to using MinGW, after installing it, please read this to set it properly.

How to build, compile, and install

To build, compile, and install txt2html in debug build, just run the following command:

$> make
...
$> make install

To build, compile, and install txt2html in release build, run the following command:

$> make release
...
$> make install

Installation note:
In linux, to use the program installed in this directory ~/local/bin, add the following to the .bashrc file.

export PATH=$PATH:~/local/bin

In windows, to use this program installed in similar directory (expecting that you installed the required MinGW), add the following to the Path environment variable.

C:\MinGW\msys\1.0\home\<your-user-name>\local\bin

How to use

To convert a text file to html file:

$> txt2html <filename of text file> --title "My Webpage"

Options:

  • --calibre-epub-xhtml = set txt2html to convert text files to xhtml format that can be use to create epub file using the calibre e-book management.
  • --title <title> = set the title tag of the html file.
  • --help = show some text that tells how to use the program.
  • --version = show the current version of the program.

Note:
If '--title' option is omitted, it will take a default title of 'My Webpage'.

Simple pattern to follow

To properly convert a text file to html, strictly follow this one very simple rule:

"Provide a single empty line between paragraph and provide two empty line after the last paragraph"

For a sample, copy & paste this three paragraph ramdom text I get somewhere out there, to any text editor and save it. And try to convert this to an html file.

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Velit scelerisque in dictum non consectetur a erat. Sit amet justo donec enim diam vulputate. Id aliquet lectus proin nibh nisl condimentum id venenatis a. Eget gravida cum sociis natoque penatibus et magnis dis. Habitant morbi tristique senectus et netus et. Interdum consectetur libero id faucibus nisl tincidunt eget nullam. Aliquam purus sit amet luctus. Fringilla ut morbi tincidunt augue interdum velit. Neque sodales ut etiam sit. Quam viverra orci sagittis eu volutpat odio facilisis mauris. Ornare suspendisse sed nisi lacus sed. Iaculis at erat pellentesque adipiscing commodo elit at imperdiet dui. Quam nulla porttitor massa id neque aliquam vestibulum morbi. Dignissim diam quis enim lobortis scelerisque fermentum dui faucibus. Turpis egestas integer eget aliquet.

In nisl nisi scelerisque eu ultrices vitae auctor eu. Dolor sit amet consectetur adipiscing elit duis. Tortor dignissim convallis aenean et tortor at. Iaculis at erat pellentesque adipiscing commodo. Viverra suspendisse potenti nullam ac tortor. Elementum nibh tellus molestie nunc non blandit massa enim. Ultricies integer quis auctor elit sed. Varius vel pharetra vel turpis nunc eget lorem dolor. Sit amet massa vitae tortor condimentum. Adipiscing elit ut aliquam purus sit amet luctus venenatis lectus. Nascetur ridiculus mus mauris vitae ultricies leo integer.

Urna nunc id cursus metus. Id leo in vitae turpis massa. Blandit turpis cursus in hac habitasse platea. Feugiat sed lectus vestibulum mattis ullamcorper. Diam sit amet nisl suscipit adipiscing bibendum est. Enim nunc faucibus a pellentesque sit amet porttitor eget dolor. Enim eu turpis egestas pretium aenean pharetra. Amet mattis vulputate enim nulla aliquet. Tristique et egestas quis ipsum suspendisse ultrices gravida dictum fusce. Risus commodo viverra maecenas accumsan lacus vel. Eu mi bibendum neque egestas congue quisque egestas diam in. Fermentum odio eu feugiat pretium nibh ipsum consequat.


Observe the empty lines between the paragraphs. It will be used by the program to identify where the opening <p> tag and closing </p> tag will be placed.


Issue

Error detected upon valgrind check for memory leaks due to 'uninitialized value was created by a stack allocation'.


About

This program is free and open-source with the license of GNU General Public License Version 2. Please see COPYING for details.