Hello everyone,
I'm looking for advice on how to parse and replace text on pattern matching.
Goal
I write notes in Markdown and want to build a tool that parses my notes and replaces texts when cretin defined patterns are found. I would also love to have the ability to extend my Markdown notes with custom functions. Perhaps if I have something like <date>
it would replace that string with today's date.
I also would like to do it all in rust so I can compile and not worry about having dependencies. So for example, I would like to avoid using something like sed for the text replacement or any other system commands.
Example
# These are my notes
I wrote these notes on <date>.
## Math class
The Algebra 101 class is located in room 243.
## Science class
Prof. Jigi-wigly is teaching Climate 201 in room 322.
Class will start in <date-2021-11-03>.
- I would like to replace the pattern
<date>
with today's date. - Lets pretand my school has a site https://www.myschool.com/class/#CLASS.html and https://www.myschool.com/class/#ROOMNUMBER.html
- I would like it to find all patterns of classes and room numbers and replace it with a link.
-
The Algebra 101 class is located in room 243.
becomesThe [Algebra 101](https://www.myschool.com/class/Algebra_101.html) class is located in [room 243](https://www.myschool.com/class/room_243.html).
-
- I would like it to find all patterns of classes and room numbers and replace it with a link.
The Question
I know this can be done with regular expressions but I want to know if there's a more elegant way to do it. Nom would be cool except it seems to me like it would be overkill. I found lalrpop a few minutes ago, I'm still not sure if it's a good match for what I'm doing or like nom, if it's over kill. There are many other parser but not sure which would be the simplest for my use case.
I'm defining overkill as over-complicating a simple problem. Maybe I'm wrong to think nom and lalrpop are overkill.
What library/method would you use?