Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top