wintermeyer
wintermeyer

Reputation: 8318

Convert Markdown to Github flavored Markdown

What is the easiest way to convert the first kind of Markdown into the second kind of Markdown?

Headline 1
==========

Some text

Subheadline 1
-------------

More text

Headline 2
==========

Even more text

into

# Headline 1 #

Some text

## Subheadline 1 ##

More text

# Headline 2 #

Even more text

Linux or Mac OS X tools are preferred.

Upvotes: 2

Views: 1243

Answers (2)

John MacFarlane
John MacFarlane

Reputation: 8947

If you don't care about the #s at the ends of lines, you can do

pandoc -f markdown -t markdown --atx-headers

See the pandoc documentation section on this for more.

Upvotes: 4

Jongware
Jongware

Reputation: 22478

Do you have access to a multi-line capable GREP? The following works inside TextPad (which, admittedly, is a Windows program):

Search for

^(.+)\n=+$

replace with

# \1 #

and similar lines for heading #2. Notation of hard return in the find expression and of Insert Numbered Group in the replacement may differ per software.

Upvotes: 0

Related Questions