LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-13-2020, 03:13 PM   #1
walterbyrd
Member
 
Registered: Apr 2004
Posts: 734

Rep: Reputation: 46
use sed to convert text to markdown?


Markdown will concatenate any concurrent lines of text that don't have two spaces after them. This is considered a "feature." Dokuwiki has a similar "feature."

I think that is about the only trick to converting text to markdown.

If I could make sure two spaces are appended to every line, and change the extension from .txt to .md, I could call my text files markdown.

Easy enough to do in vim. Just :%s/\s*$/ / - I think.

Could I convert a series of text files, to markdown, using sed?
 
Old 04-13-2020, 03:47 PM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,838

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
what works in vi will work in sed too. Almost the same (just you don't need % at the beginning).
 
1 members found this post helpful.
Old 04-13-2020, 03:57 PM   #3
walterbyrd
Member
 
Registered: Apr 2004
Posts: 734

Original Poster
Rep: Reputation: 46
I did not think it would be that easy.

But this worked:

Code:
$sed 's/\s*$/  /' test.txt > test.md
 
Old 04-14-2020, 12:50 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,838

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
Long time ago they (I mean sed and vi) shared the same codebase - related to this functionality.
If your problem is solved please mark the thread solved. If you have additional questions please ask....
 
  


Reply

Tags
sed



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: How To Add Markdown Support To Gedit Using `Markdown Preview` Plugin LXer Syndicated Linux News 0 02-19-2020 11:50 PM
LXer: Convert Markdown files to word processor docs using pandoc LXer Syndicated Linux News 0 05-22-2019 07:06 PM
[SOLVED] Is there a Markdown text mode viewer? dedec0 Linux - Software 19 04-11-2018 11:51 AM
LXer: ReText 3.0 Released (Text Editor For Markdown And reStructuredText) LXer Syndicated Linux News 0 03-09-2012 03:41 PM
LXer: ReText: A Text Editor with Support for reStructuredText and Markdown LXer Syndicated Linux News 0 11-24-2011 08:21 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration