Quantcast
Channel: Convert markdown code block markers to criticMarkup syntax - Stack Overflow
Viewing all articles
Browse latest Browse all 3

Convert markdown code block markers to criticMarkup syntax

$
0
0

I need to convert multiple markdown code blocks to markdown comment blocks using sed. I want to replace the tags but not the text. (my markdown editor has bad support for comments).

I have:

```FooMore fooEven more foo```

I need to convert this to something like

{>>FooMore fooEven more foo<<}

i.e. syntax used in CriticMarkup.

EDIT: My method. I first replaced all 2nd ocurances with >>}, then in the new file, replaced all 1st occuranges with {>>.

For the first step, I used Perl:

perl -e '$count = 0; s/\`\`\`/(++$count % 2 == 0)?">>}":$&/ge;' oldfile.md > newfile.md

to replace every second backtick, using this method.

Then I followed by a simple sed:

sed -i 's/\`\`\`/{>>/g' newfile.md

but backticks are all still there.


Viewing all articles
Browse latest Browse all 3

Trending Articles