SlideShare a Scribd company logo
Easy Blogging With Emacs
Time after time I write technical blogs and articles that describe and summarise my
experiences. Nowadays all the blogging sites and tools offer WYSIWYG editors. And it
makes blogging so easy, right? Not for me! I always find WYSIWYG editing tedious and
frustrating.
Table Of Contents
• Why WYSIWYG sucks
• Org-mode of Emacs
• Installing Emacs
• Using org-mode for writing documents
• Publishing the document
• Converting the document to PDF
Why WYSIWYG Sucks
One reason is that you have to make manually every single change (no styles like CSS for
example), which makes the process tedious, error prone and inconsistent. If you decide
later to change some styles, you have to go all over the document and modify all
occurrences one by one… Oh man, better don't touch it at all!
But the worst thing about WYSIWYG is that actually its last name is WYGIANWYW (What
You Get Is Almost Never What You Want). I have struggled many times with the editor
because it would never understand correctly what I wanted and would display a totally
broken formatting (long live undo that comes quickly to the rescue).
So, I'd rather write plain text HTML than use WYSIWYG editing, unless the structure and
formatting of the document is very simple. Maybe not everybody finds WYSIWYG so
difficult and annoying, but the technical blogs (articles, documents, etc.) that I write are a
bit long and with complex structure, and WYSIWYG would never be suitable for me. I have
also tried different wiki systems, which in a sense are better than WYSIWYG, but still they
are a bit simple and do not support all the features that I need.
Org­Mode Of Emacs
After trying different tools and systems, I decided that the orgmode of Emacs is the best
for my needs. Quoting from its webpage:
"Org mode is for keeping notes, maintaining TODO lists, planning projects, and
authoring documents with a fast and effective plain-text system."
So, among other things, org-mode can be used for authoring documents, that is writing
blogs, articles etc.
It has a wiki-like syntax that is lightweight but also complex (not-simple). Combined with the
editing power of Emacs it becomes a powerful tool for writing blogs, articles and other
docs. Then, it can be converted automatically to other formats, like HTML, LaTeX, PDF, etc.
I will try to describe how I use it for my needs (writing blogs, articles, etc.)
Installing Emacs
On Ubuntu it can be installed like this: sudo apt-get install emacs On other Linux systems
it should be very easy too. If you are using Windows, then look at the instructions on this
page.
The latest versions of Emacs include org-mode by default, so there is no need to do
anything special for installing it. Just use the extension .org for the file and the org editing
mode will be enabled automatically.
Using Org­Mode For Writing Documents
Emacs is an advanced editing tool and org-mode has lots of features, however not all of
them are needed. For what we want to do (writing technical blogs and docs), we need some
very basic and simple things.
I will list the ones that I use most frequently:
• Paragraphs are marked by empty lines:
Paragraph1
Paragraph1 continued
Paragraph2
Paragraph2 continued
• Headings are marked by stars at the beginning of a line:
* Heading1
** Heading2
*** Heading3
** Heading2
* Heading1
** Heading2
• Ordered and unordered lists:
+ item-1
1. item-1.1
2. item-1.2
3. item-1.3
+ item-2
- item-2.1
- item-2.2
- item-2.3
+ item-3
• item-1
1. item-1.1
2. item-1.2
3. item-1.3
• item-2
1. item-2.1
2. item-2.2
3. item-2.3
• item-3
• Inline markup:
*bold*, /italic/, _underlined_, =code= and ~verbatim~
bold, italic, underlined, code and verbatim
• Hyperlink:
[[http://info.btranslator.org][B-Translator]]
B-Translator
• Preformatted:
#+BEGIN_EXAMPLE
Some example from a text file.
# +END_EXAMPLE
Some example from a text file.
It is so simple, intuitive and familiar, that you don't even need a tutorial and can start using
it right away.
You can find more about the markup that can be used, on the documentation of org-mode
(or try info org on the terminal).
As an example, you can see the org code of this document itself on gist: easy-blogging-with-
emacs.org
Publishing The Document
In order to publish the document, I do these steps:
1. First, convert it to HTML (with the emacs command: C-c C-e h).
2. Then open the generated HTML file in a browser.
3. And then copy/paste the content of the article from the browser to the editor of the
blog site.
I don't know why, but a copy/paste like this usually works very well. I use Blogger for my
blogs, but I think that it should work on other blog sites and WYSIWYG editors as well.
After the copy/paste, I still have to do some minor manual corrections, but this is much
easier than writing the whole thing on the WYSIWYG editor.
Pay attention to these lines that are at the beginning of the org file:
#+OPTIONS: num:nil toc:t ^:nil f:nil TeX:nil LaTeX:nil
#+STYLE: <link href="css/org.css" rel="stylesheet" type="text/css"/>
They control the look of the generated HTML file. The first one defines some
settings/options, like: don't number headers, generate a TOC, turn off TeX syntax for
subscripts, etc. More details and other options you can find on the documentation for
export settings.
The second line tells it which CSS file to use, so that the generated HTML looks nice and
beautiful. For a quick start, just download and use my org.css file, and later you can
customise it for yourself. For example, it defines the style of preformatted text like this:
pre {
padding: 10px;
border: 1pt solid #AEBDCC;
border-radius: 5px;
background-color: #000000;
color: #eeeeee;
font-family: Ubuntu Mono, monospace, courier;
}
Converting The Document To PDF
Org-mode can convert directly to PDF. However there is no way (as far as I know) to modify
how the generated PDF file looks like. It always has the same standard look of an old
scientific paper (I guess that the conversion to PDF is done by converting first to LaTeX).
I prefer to take another approach for generating PDF docs:
1. First I generate the HTML file (where I can control how it looks by customising the
CSS file).
2. Then I copy/paste from the browser to LibreOffice (yes, this copy/paste works well
too, preserving all the formatting and styles from HTML).
3. Finally save it as PDF. LibreOffice has a built-in PDF converter.
However, before the third step I do again some minor manual modifications. I also define
styles for headings, preformatted text, text body, etc.
One of the things that I change in LibreOffice/PDF document is the style of the
preformatted text. In the HTML version it is white font on a black background, and this is
good because it looks like a terminal. However PDF documents sometimes can be printed
and that style doesn't look nice on paper (and also it would consume lots of ink), so I change
it to black font on white background.
To apply the new style on a preformatted text, I select it, then from the list of styles (on
top-left) select "Clear formatting", then select the style "Preformatted Text". I have to do
this for all the preformatted texts. I do the same thing for headings as well.
In order to not re-define the styles for each document, I open an old document, replace its
content with the new content, and then save it with a new name. This will ensure that the
styles of the new document are the same as the styles of the old one. Maybe LibreOffice
has some other means for defining the styles and using them on each document, but I am
not so familiar with LibreOffice and this trick works anyway.
If you want to use my styles, you can download the .odt document from here and use it as a
template for your own docs.
Author: Dashamir Hoxha <dashohoxha@gmail.com>
Date: 12 July 2013
HTML generated by org-mode 6.33x in emacs 23

More Related Content

What's hot

Html notes with Examples
Html notes with ExamplesHtml notes with Examples
Html notes with Examples
isha
 

What's hot (20)

Html
HtmlHtml
Html
 
Lesson 1: Introduction to HTML
Lesson 1: Introduction to HTMLLesson 1: Introduction to HTML
Lesson 1: Introduction to HTML
 
HTML TAGS
HTML TAGSHTML TAGS
HTML TAGS
 
Html
HtmlHtml
Html
 
Basics of HTML 5 for Beginners
Basics of HTML 5 for Beginners Basics of HTML 5 for Beginners
Basics of HTML 5 for Beginners
 
HTML Introduction, HTML History, HTML Uses, HTML benifits
HTML Introduction, HTML History, HTML Uses, HTML benifitsHTML Introduction, HTML History, HTML Uses, HTML benifits
HTML Introduction, HTML History, HTML Uses, HTML benifits
 
Week 5 Lecture
Week 5 LectureWeek 5 Lecture
Week 5 Lecture
 
Introduction to html
Introduction to htmlIntroduction to html
Introduction to html
 
Html basics
Html basicsHtml basics
Html basics
 
Web design - HTML (Hypertext Markup Language) introduction
Web design - HTML (Hypertext Markup Language) introductionWeb design - HTML (Hypertext Markup Language) introduction
Web design - HTML (Hypertext Markup Language) introduction
 
Week 6 Lecture
Week 6 LectureWeek 6 Lecture
Week 6 Lecture
 
Html tutorials
Html tutorialsHtml tutorials
Html tutorials
 
Notepad
NotepadNotepad
Notepad
 
Html notes with Examples
Html notes with ExamplesHtml notes with Examples
Html notes with Examples
 
Basic html structure
Basic html structureBasic html structure
Basic html structure
 
Html introduction by ikram niaz
Html introduction by ikram niazHtml introduction by ikram niaz
Html introduction by ikram niaz
 
Lesson4.9 a u4l2 html
Lesson4.9 a u4l2 htmlLesson4.9 a u4l2 html
Lesson4.9 a u4l2 html
 
Notepad ++
Notepad ++Notepad ++
Notepad ++
 
Web designing using html
Web designing using htmlWeb designing using html
Web designing using html
 
Css presentation lecture 1
Css presentation lecture 1Css presentation lecture 1
Css presentation lecture 1
 

Viewers also liked (8)

IT Strategy of Albanian Customs
IT Strategy of Albanian CustomsIT Strategy of Albanian Customs
IT Strategy of Albanian Customs
 
European union common border crossings management project
European union common border crossings management projectEuropean union common border crossings management project
European union common border crossings management project
 
Easy Blogging With Emacs -- Cheatsheet
Easy Blogging With Emacs -- CheatsheetEasy Blogging With Emacs -- Cheatsheet
Easy Blogging With Emacs -- Cheatsheet
 
European commission report 2013
European commission report 2013European commission report 2013
European commission report 2013
 
Easy Blogging With Emacs
Easy Blogging With EmacsEasy Blogging With Emacs
Easy Blogging With Emacs
 
Autobiography of Benjamin Franklin
Autobiography of Benjamin FranklinAutobiography of Benjamin Franklin
Autobiography of Benjamin Franklin
 
1. e freight-fundamentals
1. e freight-fundamentals1. e freight-fundamentals
1. e freight-fundamentals
 
Customs and Border Management
Customs and Border ManagementCustoms and Border Management
Customs and Border Management
 

Similar to Easy Blogging With Emacs

Web Development From the Ground Up, a Series for Novice ...
Web Development From the Ground Up, a Series for Novice ...Web Development From the Ground Up, a Series for Novice ...
Web Development From the Ground Up, a Series for Novice ...
webhostingguy
 

Similar to Easy Blogging With Emacs (20)

Web Development From the Ground Up, a Series for Novice ...
Web Development From the Ground Up, a Series for Novice ...Web Development From the Ground Up, a Series for Novice ...
Web Development From the Ground Up, a Series for Novice ...
 
Slides 2 - HTML
Slides 2 - HTMLSlides 2 - HTML
Slides 2 - HTML
 
Markup For Dummies (Russ Ward)
Markup For Dummies (Russ Ward)Markup For Dummies (Russ Ward)
Markup For Dummies (Russ Ward)
 
HTML & CSS.ppt
HTML & CSS.pptHTML & CSS.ppt
HTML & CSS.ppt
 
EPUB - a workshop for beginners
EPUB - a workshop for beginnersEPUB - a workshop for beginners
EPUB - a workshop for beginners
 
Joomla tempates talk
Joomla tempates talkJoomla tempates talk
Joomla tempates talk
 
Oreilly
OreillyOreilly
Oreilly
 
GDI Seattle Intro to HTML and CSS - Class 1
GDI Seattle Intro to HTML and CSS - Class 1GDI Seattle Intro to HTML and CSS - Class 1
GDI Seattle Intro to HTML and CSS - Class 1
 
Html tutorials
Html tutorialsHtml tutorials
Html tutorials
 
Class1slides
Class1slidesClass1slides
Class1slides
 
(Fast) Introduction to HTML & CSS
(Fast) Introduction to HTML & CSS (Fast) Introduction to HTML & CSS
(Fast) Introduction to HTML & CSS
 
Unit 5 application layer
Unit 5 application layerUnit 5 application layer
Unit 5 application layer
 
HTML-INTRO.pptx
HTML-INTRO.pptxHTML-INTRO.pptx
HTML-INTRO.pptx
 
Html
HtmlHtml
Html
 
Html
HtmlHtml
Html
 
Week 2-intro-html
Week 2-intro-htmlWeek 2-intro-html
Week 2-intro-html
 
2a web technology html basics 1
2a web technology html basics 12a web technology html basics 1
2a web technology html basics 1
 
Mdst 3559-02-01-html
Mdst 3559-02-01-htmlMdst 3559-02-01-html
Mdst 3559-02-01-html
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
HTML Bootcamp
HTML BootcampHTML Bootcamp
HTML Bootcamp
 

More from Dashamir Hoxha

Certificate -- Dashamir Hoxha -- edX/BerkeleyX -- CS169.1x Software as Service
Certificate -- Dashamir Hoxha -- edX/BerkeleyX -- CS169.1x Software as ServiceCertificate -- Dashamir Hoxha -- edX/BerkeleyX -- CS169.1x Software as Service
Certificate -- Dashamir Hoxha -- edX/BerkeleyX -- CS169.1x Software as Service
Dashamir Hoxha
 
Certificate -- Dashamir Hoxha -- edX/BerkeleyX -- CS188.1x Artificial Intelli...
Certificate -- Dashamir Hoxha -- edX/BerkeleyX -- CS188.1x Artificial Intelli...Certificate -- Dashamir Hoxha -- edX/BerkeleyX -- CS188.1x Artificial Intelli...
Certificate -- Dashamir Hoxha -- edX/BerkeleyX -- CS188.1x Artificial Intelli...
Dashamir Hoxha
 
Certificate -- Dashamir Hoxha -- edX/BerkeleyX -- CS169.2x Advanced Software ...
Certificate -- Dashamir Hoxha -- edX/BerkeleyX -- CS169.2x Advanced Software ...Certificate -- Dashamir Hoxha -- edX/BerkeleyX -- CS169.2x Advanced Software ...
Certificate -- Dashamir Hoxha -- edX/BerkeleyX -- CS169.2x Advanced Software ...
Dashamir Hoxha
 
Certificate -- Dashamir Hoxha -- edX/MITx -- 6.00x Introduction to Computer S...
Certificate -- Dashamir Hoxha -- edX/MITx -- 6.00x Introduction to Computer S...Certificate -- Dashamir Hoxha -- edX/MITx -- 6.00x Introduction to Computer S...
Certificate -- Dashamir Hoxha -- edX/MITx -- 6.00x Introduction to Computer S...
Dashamir Hoxha
 
phpWebApp presentation
phpWebApp presentationphpWebApp presentation
phpWebApp presentation
Dashamir Hoxha
 

More from Dashamir Hoxha (20)

Development Setup of B-Translator
Development Setup of B-TranslatorDevelopment Setup of B-Translator
Development Setup of B-Translator
 
Using Drupal Features in B-Translator
Using Drupal Features in B-TranslatorUsing Drupal Features in B-Translator
Using Drupal Features in B-Translator
 
Strategjia për IT-në e Doganës Shqiptare
Strategjia për IT-në e Doganës ShqiptareStrategjia për IT-në e Doganës Shqiptare
Strategjia për IT-në e Doganës Shqiptare
 
Certificate -- Dashamir Hoxha -- edX/BerkeleyX -- CS169.1x Software as Service
Certificate -- Dashamir Hoxha -- edX/BerkeleyX -- CS169.1x Software as ServiceCertificate -- Dashamir Hoxha -- edX/BerkeleyX -- CS169.1x Software as Service
Certificate -- Dashamir Hoxha -- edX/BerkeleyX -- CS169.1x Software as Service
 
Certificate -- Dashamir Hoxha -- edX/BerkeleyX -- CS188.1x Artificial Intelli...
Certificate -- Dashamir Hoxha -- edX/BerkeleyX -- CS188.1x Artificial Intelli...Certificate -- Dashamir Hoxha -- edX/BerkeleyX -- CS188.1x Artificial Intelli...
Certificate -- Dashamir Hoxha -- edX/BerkeleyX -- CS188.1x Artificial Intelli...
 
Certificate -- Dashamir Hoxha -- edX/BerkeleyX -- CS169.2x Advanced Software ...
Certificate -- Dashamir Hoxha -- edX/BerkeleyX -- CS169.2x Advanced Software ...Certificate -- Dashamir Hoxha -- edX/BerkeleyX -- CS169.2x Advanced Software ...
Certificate -- Dashamir Hoxha -- edX/BerkeleyX -- CS169.2x Advanced Software ...
 
Certificate -- Dashamir Hoxha -- edX/MITx -- 6.00x Introduction to Computer S...
Certificate -- Dashamir Hoxha -- edX/MITx -- 6.00x Introduction to Computer S...Certificate -- Dashamir Hoxha -- edX/MITx -- 6.00x Introduction to Computer S...
Certificate -- Dashamir Hoxha -- edX/MITx -- 6.00x Introduction to Computer S...
 
Udhëzuesi i Kturtle
Udhëzuesi i KturtleUdhëzuesi i Kturtle
Udhëzuesi i Kturtle
 
PPPoE With Mikrotik and Radius
PPPoE With Mikrotik and RadiusPPPoE With Mikrotik and Radius
PPPoE With Mikrotik and Radius
 
PPPoE With Mikrotik and Radius
PPPoE With Mikrotik and RadiusPPPoE With Mikrotik and Radius
PPPoE With Mikrotik and Radius
 
Using OpenFire With OpenLDAP
Using OpenFire With OpenLDAPUsing OpenFire With OpenLDAP
Using OpenFire With OpenLDAP
 
phpWebApp presentation
phpWebApp presentationphpWebApp presentation
phpWebApp presentation
 
phpWebApp article
phpWebApp articlephpWebApp article
phpWebApp article
 
Managing HotSpot Clients With FreeRadius
Managing HotSpot Clients With FreeRadiusManaging HotSpot Clients With FreeRadius
Managing HotSpot Clients With FreeRadius
 
The Digital Signature and the X.509/OpenPGP Authentication Models
The Digital Signature and the X.509/OpenPGP Authentication ModelsThe Digital Signature and the X.509/OpenPGP Authentication Models
The Digital Signature and the X.509/OpenPGP Authentication Models
 
Building a Gateway Server
Building a Gateway ServerBuilding a Gateway Server
Building a Gateway Server
 
An Algorithm for Incremental Multi-Resolution Modeling
An Algorithm for Incremental Multi-Resolution ModelingAn Algorithm for Incremental Multi-Resolution Modeling
An Algorithm for Incremental Multi-Resolution Modeling
 
SugarCE For Small And Medium Enterprises
SugarCE For Small And Medium EnterprisesSugarCE For Small And Medium Enterprises
SugarCE For Small And Medium Enterprises
 
B-Translator as a Software Engineering Project
B-Translator as a Software Engineering ProjectB-Translator as a Software Engineering Project
B-Translator as a Software Engineering Project
 
B-Translator as a Software Engineering Project
B-Translator as a Software Engineering ProjectB-Translator as a Software Engineering Project
B-Translator as a Software Engineering Project
 

Recently uploaded

Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
Bhaskar Mitra
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 

Recently uploaded (20)

IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutes
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John Staveley
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024
 
Agentic RAG What it is its types applications and implementation.pdf
Agentic RAG What it is its types applications and implementation.pdfAgentic RAG What it is its types applications and implementation.pdf
Agentic RAG What it is its types applications and implementation.pdf
 
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
 
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya HalderCustom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
In-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT ProfessionalsIn-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT Professionals
 

Easy Blogging With Emacs

  • 1. Easy Blogging With Emacs Time after time I write technical blogs and articles that describe and summarise my experiences. Nowadays all the blogging sites and tools offer WYSIWYG editors. And it makes blogging so easy, right? Not for me! I always find WYSIWYG editing tedious and frustrating. Table Of Contents • Why WYSIWYG sucks • Org-mode of Emacs • Installing Emacs • Using org-mode for writing documents • Publishing the document • Converting the document to PDF Why WYSIWYG Sucks One reason is that you have to make manually every single change (no styles like CSS for example), which makes the process tedious, error prone and inconsistent. If you decide later to change some styles, you have to go all over the document and modify all occurrences one by one… Oh man, better don't touch it at all! But the worst thing about WYSIWYG is that actually its last name is WYGIANWYW (What You Get Is Almost Never What You Want). I have struggled many times with the editor because it would never understand correctly what I wanted and would display a totally broken formatting (long live undo that comes quickly to the rescue). So, I'd rather write plain text HTML than use WYSIWYG editing, unless the structure and formatting of the document is very simple. Maybe not everybody finds WYSIWYG so difficult and annoying, but the technical blogs (articles, documents, etc.) that I write are a bit long and with complex structure, and WYSIWYG would never be suitable for me. I have also tried different wiki systems, which in a sense are better than WYSIWYG, but still they are a bit simple and do not support all the features that I need. Org­Mode Of Emacs After trying different tools and systems, I decided that the orgmode of Emacs is the best for my needs. Quoting from its webpage: "Org mode is for keeping notes, maintaining TODO lists, planning projects, and authoring documents with a fast and effective plain-text system." So, among other things, org-mode can be used for authoring documents, that is writing blogs, articles etc. It has a wiki-like syntax that is lightweight but also complex (not-simple). Combined with the editing power of Emacs it becomes a powerful tool for writing blogs, articles and other docs. Then, it can be converted automatically to other formats, like HTML, LaTeX, PDF, etc.
  • 2. I will try to describe how I use it for my needs (writing blogs, articles, etc.) Installing Emacs On Ubuntu it can be installed like this: sudo apt-get install emacs On other Linux systems it should be very easy too. If you are using Windows, then look at the instructions on this page. The latest versions of Emacs include org-mode by default, so there is no need to do anything special for installing it. Just use the extension .org for the file and the org editing mode will be enabled automatically. Using Org­Mode For Writing Documents Emacs is an advanced editing tool and org-mode has lots of features, however not all of them are needed. For what we want to do (writing technical blogs and docs), we need some very basic and simple things. I will list the ones that I use most frequently: • Paragraphs are marked by empty lines: Paragraph1 Paragraph1 continued Paragraph2 Paragraph2 continued • Headings are marked by stars at the beginning of a line: * Heading1 ** Heading2 *** Heading3 ** Heading2 * Heading1 ** Heading2 • Ordered and unordered lists: + item-1 1. item-1.1 2. item-1.2 3. item-1.3 + item-2 - item-2.1 - item-2.2 - item-2.3 + item-3 • item-1 1. item-1.1 2. item-1.2 3. item-1.3
  • 3. • item-2 1. item-2.1 2. item-2.2 3. item-2.3 • item-3 • Inline markup: *bold*, /italic/, _underlined_, =code= and ~verbatim~ bold, italic, underlined, code and verbatim • Hyperlink: [[http://info.btranslator.org][B-Translator]] B-Translator • Preformatted: #+BEGIN_EXAMPLE Some example from a text file. # +END_EXAMPLE Some example from a text file. It is so simple, intuitive and familiar, that you don't even need a tutorial and can start using it right away. You can find more about the markup that can be used, on the documentation of org-mode (or try info org on the terminal). As an example, you can see the org code of this document itself on gist: easy-blogging-with- emacs.org Publishing The Document In order to publish the document, I do these steps: 1. First, convert it to HTML (with the emacs command: C-c C-e h). 2. Then open the generated HTML file in a browser. 3. And then copy/paste the content of the article from the browser to the editor of the blog site. I don't know why, but a copy/paste like this usually works very well. I use Blogger for my blogs, but I think that it should work on other blog sites and WYSIWYG editors as well. After the copy/paste, I still have to do some minor manual corrections, but this is much easier than writing the whole thing on the WYSIWYG editor. Pay attention to these lines that are at the beginning of the org file: #+OPTIONS: num:nil toc:t ^:nil f:nil TeX:nil LaTeX:nil #+STYLE: <link href="css/org.css" rel="stylesheet" type="text/css"/> They control the look of the generated HTML file. The first one defines some settings/options, like: don't number headers, generate a TOC, turn off TeX syntax for subscripts, etc. More details and other options you can find on the documentation for
  • 4. export settings. The second line tells it which CSS file to use, so that the generated HTML looks nice and beautiful. For a quick start, just download and use my org.css file, and later you can customise it for yourself. For example, it defines the style of preformatted text like this: pre { padding: 10px; border: 1pt solid #AEBDCC; border-radius: 5px; background-color: #000000; color: #eeeeee; font-family: Ubuntu Mono, monospace, courier; } Converting The Document To PDF Org-mode can convert directly to PDF. However there is no way (as far as I know) to modify how the generated PDF file looks like. It always has the same standard look of an old scientific paper (I guess that the conversion to PDF is done by converting first to LaTeX). I prefer to take another approach for generating PDF docs: 1. First I generate the HTML file (where I can control how it looks by customising the CSS file). 2. Then I copy/paste from the browser to LibreOffice (yes, this copy/paste works well too, preserving all the formatting and styles from HTML). 3. Finally save it as PDF. LibreOffice has a built-in PDF converter. However, before the third step I do again some minor manual modifications. I also define styles for headings, preformatted text, text body, etc. One of the things that I change in LibreOffice/PDF document is the style of the preformatted text. In the HTML version it is white font on a black background, and this is good because it looks like a terminal. However PDF documents sometimes can be printed and that style doesn't look nice on paper (and also it would consume lots of ink), so I change it to black font on white background. To apply the new style on a preformatted text, I select it, then from the list of styles (on top-left) select "Clear formatting", then select the style "Preformatted Text". I have to do this for all the preformatted texts. I do the same thing for headings as well. In order to not re-define the styles for each document, I open an old document, replace its content with the new content, and then save it with a new name. This will ensure that the styles of the new document are the same as the styles of the old one. Maybe LibreOffice has some other means for defining the styles and using them on each document, but I am not so familiar with LibreOffice and this trick works anyway. If you want to use my styles, you can download the .odt document from here and use it as a template for your own docs. Author: Dashamir Hoxha <dashohoxha@gmail.com> Date: 12 July 2013 HTML generated by org-mode 6.33x in emacs 23