I need to create a script that processes a couple of html files to convert these type of lines:
<link rel="stylesheet" href="assets/css/main.css">
.. into this:
{stylesheets file='assets/css/main.css'}
<link rel="stylesheet" href="{$asset_url}">
{/stylesheets}
I also need to convert javascript codes inside of the html files in the same way. This:
<script type="text/javascript" src="vendor/revolution/revolution.extension.migration.min.js"></script>
.. into this:
{javascripts file='vendor/revolution/revolution.extension.migration.min.js'}
<script src="{$asset_url}"></script>
{/javascripts}
I know some of basic tricks in bash with regex, e.g. search and replace, but I do not have enough knowledge to do this alone.
I would appreciate your help a lot.
Thank you in advance.
EDIT :
link and script are always located on one line, but their arguments aren't always in the same order.
If regex seems to be a bad idea for html, which tool do you suggest to me?