本文介绍了使用bash(最好是sed)命令删除markdown(md)文件中的图像和链接标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在git Wiki上有markdown(md)文件,我正在将其更改为html.我不想在html文件中包含图像和链接.我们在markdown中的图片如下所示:

I have markdown (md) files, on a git wiki, that I am changing to html. I don't want to include the images and links in the html file. Our images in markdown looks like this:

![Alt text](/path/to/img.jpg "Optional title")

我们的降价链接如下:

[I'm an inline-style link](https://www.google.com)

唯一的不同是!"特点.我正在编写一个shell脚本来做所有事情.什么是bash命令删除整个图像和链接标签?这是一个更基本的sed堆栈问题:

The only real different is the '!' character. I am writing a shell script to do everything. What is a bash command(s) to remove the entire image and link tag? Here is a more basic sed stack question:

如何删除方括号和其中的任何文本?/a>

How to remove square brackets and any text inside?

ps.您可以在回答中包含微笑吗?我累了,想回家.

ps. can you include a smile in your answer? I am tired and want to go home.

推荐答案

这应同时删除它们:

$ sed 's/\!\{0,1\}\[[^]]*\]([^)]*)//g' file.md

这也可以,但是...请在下面查看potong的评论:

This works too but... see potong's comment here below:

$ sed 's/!\?\[.*\](.*)//g' file.md

这篇关于使用bash(最好是sed)命令删除markdown(md)文件中的图像和链接标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

查看更多