2

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.

1
  • Both are normal markdown, the '#' ones are not specific to github-flavored. Commented Mar 3, 2014 at 15:20

2 Answers 2

4

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.