You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 13, 2024. It is now read-only.
This could be a partial replacement for #90. If Lua is integrated as suggested there all this could of course easi{ly,er} be done in Lua, except that Lua would only count bytes, not characters
It would be good to have macros for finding the position of a substring and extracting a substring, and reasonably also the length of some text in the classic awk/perl style.
!index[(INDEX)](TEXT)(SUBSTR)
!substr(TEXT)(OFFSET)[(LENGTH)]
!len(TEXT)
!def(x)(foo bar baz bap)
!index(!x)(ba)
--> 5
!index(2)(!x)(ba)
--> 9
!index(-1)(!x)(ba)
--> 13
!substr(!x)(5)
--> bar baz bap
!substr(!x)(-2)
--> ap
!substr(!x)(5)(6)
--> bar ba
!substr(!x)(5)(-5)
--> bar ba
!substr(!x)(!index(!x)(ba))(!eval(-!index(-1)(!x)(ba)))
--> "bar baz "
!substr(!index(!foo)(!bar))(!eval(!len(!bar)+3))
I stole the idea for the INDEX argument to !index, which with negative indices also makes an !rindex unnecessary, from the LaTeX xstring package. (Don't worry, I'm fully aware that all of those xstring macros can be implemented using the three proposed above and existing pp macros! :-)
The text was updated successfully, but these errors were encountered:
Sorry for the late reply... Please keep in mind that pp is not supported anymore, it's hard to deploy. For new projects I suggest ypp which is is based on a Lua interpreter and way easier to compile and install and binaries are easier to produce (thanks to zig) and deploy (see hey).
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
This could be a partial replacement for #90. If Lua is integrated as suggested there all this could of course easi{ly,er} be done in Lua, except that Lua would only count bytes, not characters
It would be good to have macros for finding the position of a substring and extracting a substring, and reasonably also the length of some text in the classic awk/perl style.
I stole the idea for the INDEX argument to
!index
, which with negative indices also makes an!rindex
unnecessary, from the LaTeX xstring package. (Don't worry, I'm fully aware that all of those xstring macros can be implemented using the three proposed above and existing pp macros! :-)The text was updated successfully, but these errors were encountered: