Modifying Markdown files

20 views
Skip to first unread message

Mark Levison

unread,
Aug 3, 2023, 12:56:35 PM8/3/23
to TextSoap
I'm trying to transform Markdown files (for Obsidian) from:

---

tags: Books

---


![cover|150](http://books.google.com/books/content?id=8BVIKsDbdKYC&printsec=frontcover&img=1&zoom=1&edge=curl&source=gbs_api)


**Author**:: Stephen Tanner

**Title**:: Afghanistan

**Category**::History

**Status**:: 📥


to:

---

tags: Books


![cover|150](http://books.google.com/books/content?id=8BVIKsDbdKYC&printsec=frontcover&img=1&zoom=1&edge=curl&source=gbs_api)


Author: Stephen Tanner

Title: Afghanistan

Category:History

Status: 📥

----


The basic stuff makes sense, the hard part is writing an if statement to remove the second '---' and insert a new one after status.

I wrote an if statement that starts:
CleanShot 2023-08-03 at 11.40.17@2x.png
Which I assume will delete the 2nd '----'. I can't seem to terminate the if. Is there an endIf I'm missing.

Also how would I add the new '---' after status?

Cheers
Mark

Mark Munz

unread,
Aug 3, 2023, 2:12:08 PM8/3/23
to text...@googlegroups.com
First, The Endif is implied/invisible. Think of it like this:

If / Conditional action
    Action
    Action
    <endif>
Action

In actuality, it's implied when you're using TextSoap, but explicit when it's saved.

To get rid of the second line, I would use an action like this:
image.png
^ is anchored to the start of a line.
Then it captures ---\n , anything on the next line ending with a return.
Then it matches the second ---\n .
The result is text we captured, which is first two lines.

Next, to insert --- after Status, you might do something like this:
image.png

The example show a before and after with and without **, so I made it more general.
^ anchor from the start of the line
Capture the line that contains "Status" including its return
Replace with that, plus the ---\n you want.


--
You received this message because you are subscribed to the Google Groups "TextSoap" group.
To unsubscribe from this group and stop receiving emails from it, send an email to textsoap+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/textsoap/53c951d8-41e8-41b9-9218-572af89bdeb7n%40googlegroups.com.


--
Mark Munz
unmarked software
https://textsoap.com/

Mark Levison

unread,
Aug 3, 2023, 7:50:45 PM8/3/23
to TextSoap
Thanks for the rapid reply. Next mad question is there elegant (even inelegant) to grab the line ![cover|150]

And move it below the newly established "---\n". FWIW This isn't the end of the file, just end of a block.

Cheers
Mark
Reply all
Reply to author
Forward
0 new messages