Your use of grep in a void context looks like a mistake. You realize that this does not change the content of
@foots, don't you? I expect you want the list returned by grep to be the iterator in the following for loop:
+
for ( grep { $_->prev_sibling_text =~ m<([,.])\s*$> } @foots ) {
A mistake, or another rung on the learning curve. Or both. Thanks.
As for cases where the following sibling has no text (note: there are "prev_sibling()" and "next_sibling()"
methods for elt objects), it may be a matter of understanding your document structure to determine whether you
need to insert a new elt as a next sibling in order to move the punctuation text into that, or whether you can
just assign text content (the punctuation) to the next sibling, whatever it may be.
This is my problem, and this is what I don't quite
understand. Suppose I had data like this:
<a>Text text <b>Footnote code</b></a>
How, with XML::Twig do I add text between the
</b> and </a> tags? Maybe I don't understand
XML terminology well enough, but I kind of thought that adding an
element woud mean doing something like this:
<a>Text text <b>Footnote code</b><a>The new text</a></a>
In other words, how do I specify that the child I want to add to
the original <a> element is just a text element?
Or maybe you should review the "local typographical
rules" to see if maybe the footnote does not need to be placed before
punctuation when no text follows. Frankly, I think the
"rule" you stated is suspect -- having footnotes after punctuation
seems like a common practice.)
This is all in French, and French typography rules want the
footnote reference before the punctuation. This is a little-known
rule, even amongst French authors, which is partly why I'm building this filter.
In any case, are you sure that looking just for final period or comma is sufficient? What about question/
exclamation marks, quotation marks, parens, and any combination thereof?
Exactly. This is phase one of figuring out how to do this. Next
comes all the fun dealing with the different punctuation
possibilities. Quotations marks (»), question marks, colons,
semicolons, and exclamation points all must be preceeded by a
non-breaking space.
sub jf { print substr($_[0], -1);
jf( substr($_[0], 0, length($_[0])-1))
if length $_[0] > 1; }
jf('gro.alubaf@yehaf');
| [reply] [d/l] [select] |