I'm searching sphinx .rst text files for
:variablerolename:`text may span newline`
There can be multiple, different :variablerolename:
pieces starting somewhere on a single line.
So, as input example, I have:
yada :role2:`texty text` yada :role:`text
line` yada filler
yada yada :role:`text of role` yada yada :role2:`start of text
rest of text`
more text :rolename:`Text after this role`
filler :otherrole:`This role
text` filler
Searching for answers I've gotten as far as
grep -P '(?s):[a-z].*:`.*`' filename
But I don't think this is properly matching multiple :role: blocks on a line because one line of output I get is
yada yada :role:`text of role` yada yada :role2:`start of text
but the rest of the role2 text up to the closing back quote isn't printed on the next line.
The output I want would be just the role name and the back quoted text, each instance alone on a line, without the pre and post text. So, something like:
:role2:`texty text`
:role:`text line`
:role:`text of role`
:role2:`start of text rest of text`
:rolename:`Text after this role`
:otherrole:`This role text`
I'll be passing the output of this on to |sort|uniq
so need single lines.
I'm limited to using what's available on RHEL 6.7 (so latest features might not be there)
- GNU bash, version 4.1.2
- GNU Awk 3.1.7
- grep (GNU grep) 2.20
- GNU sed version 4.2.1