lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hello Peter,

Peter Matulis <pmatulis@gmail.com> writes:

> Hi, I am very new to Lua

Welcome :)

> but I do have two tiny Pandoc Lua filters that
> work. They are extremely similar and I would like to combine them. I'm just
> not sure how to introduce the conditional aspect.
>
> 1. This script simply exchanges the '.md' file extension for the '.html'
> extension:
>
>
> function Link (link)
>   link.target = link.target:gsub('(.+)%.md', '%1.html')
>   return link
> end
>
>
> 2. This script does the same except it handles the case where the link
> contains an anchor:
>
>
> function Link (link)
>   link.target = link.target:gsub('(.+)%.md%#(.+)', '%1.html#%2')
>   return link
> end

As far as I can tell, the first version should also work for the second
use case. A pattern may match anywhere in the string (unless "start of
string" or "end of string" are explicitly matched in the pattern).

BTW, we are also happy to answer pandoc-related issues over at the
pandoc-discuss mailing list:
https://groups.google.com/forum/#!forum/pandoc-discuss

Cheers,
Albert


--
Albert Krewinkel
GPG: 8eed e3e2 e8c5 6f18 81fe  e836 388d c0b2 1f63 1124