Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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');

In reply to Re^2: Moving a tag within text with XML::Twig by skillet-thief
in thread Moving a tag within text with XML::Twig by skillet-thief

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2024-04-26 02:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found