How to substitute "plain text footnotes" with tex \footnote

Hi,
(i hope this is the right sub forum)
i have a lot of plain texts like this one (just longer and with dozens of footnotes:
Lorem ipsum dolor sit amet, consectetur adipiscing elit [01].
Footnotes:
[01] blah blah
Can anyone point me in the right direction, so i can change them to:
Lorem ipsum dolor sit amet, consectetur adipiscing elit \footnote{blah bla}.
I'd prefer a bash script, Perl or python, but anything else is appreciated as well. Just don't want to do it manually.
thank you,
rich_o

As a first approach i came up with this:
#!/usr/bin/env python
# TODO: allow different footnote numbering schemes, i.e. (01) or [ 001 ]
# TODO: allow different footnote markups, i.e <fn></fn>
# TODO: error-/exceptions-handling
import re
f = open('testfile.txt', 'r')
text = f.readlines()
f.close()
# first footnote entry at end of text
index = next((i for i in range(len(text) - 1, -1, -1) if text[i].startswith('[01]')), None)
# get all footnotes
footnotes = dict()
lastfn = ''
for i in text[index:]:
try:
results = re.split('\[(\d{1,3})]', i.strip())
footnotes[results[1]] = results[2].strip()
lastfn=results[1]
except: # catch footnotes covering more than one line
# FIXME: exception is very unreliable!
footnotes[lastfn] = ' '.join([footnotes[lastfn], i.strip()])
newtext = ''.join(text[:index])
# replace
for i in footnotes:
p = ''.join(['\[', i, '\]'])
pat = re.compile(p)
new = ''.join(['\{', footnotes[i], '}'])
newtext = re.sub(pat, new, newtext)
print(newtext)
It's working, but needs some work to be reliable under other circumstances
Last edited by rich_o (2010-12-09 16:33:58)

Similar Messages

  • How can i use text expander with the new Mavericks,

    how can i use text expander with the new Mavericks,

    I regret upgrading to mavericks for the same reason
    ftamez wrote:
    how can i use text expander with the new Mavericks,
    Now I have been searching - and you have to buy an app and it will cost you $34.99 (what a rip off)

  • How to get plain text out of a multi line text field in Client Side Object Model?

    I am trying to read plain text from a MultiLineTextField in a List. This is how my code looks so far:
    //Get connection
    ClientContext context = new ClientContext("URL");
    Web site = context.Web;
    context.Load(site);
    context.ExecuteQuery();
    //Get list collection
    ListCollection lists = context.Web.Lists;
    context.Load(lists);
    context.ExecuteQuery();
    //Get specific list
    List menu = lists.GetByTitle("menu");
    CamlQuery camlQuery = new CamlQuery();
    camlQuery.ViewXML = "<View/>";
    ListItemCollection dishes = menu.GetItems(camlQuery);
    context.Load(menu);
    context.Load(dishes);
    context.ExecuteQuery();
    //Iterate through all dishes
    foreach(ListItem dish in dishes)
    Console.WriteLine("Dish: {0}:", dish.FieldValues["Name"]);
    Console.WriteLine("Price: {0}:", dish.FieldValues["Price"]);
    //Here I get my problem
    Console.WriteLine("Ingredients: {0}:", dish.FieldValues["Ingredients"]);
    In the last line where I try to read the ingredients, I am reading from a MultiLineTextField which is set to RichText. It is also supposed to stay in RichText format, as hyperlinks are supposed to be added there. The problem is that the output not only contains
    div-tags but also some weird question marks I never added to the field. I am trying to solve this issue for a couple of days now but it seems that there are only two possible solutions.
    Set the field from RichText to PlainText, which is not an option in my case.
    Use Regex to remove the div-tags. Please do not suggest this option. Mainly because I do not consider this to be a clean solution for this issue. Plus, I tried it and it removes the tags but those weird question marks stay.
    There seems to be a third option I found
    here. It is also mentioned in this
    question and it seems to work. But I can not get it to work for me. This is how it looks:
    string myString = item.FieldMultiLineText[Field_Name];
    So I wonder what is item supposed to be here? I suppose it is not a
    ListItem because in my case it does not offer a FieldMultiLineText-property.
    A short, informative code snippet would be great if you decide to help me with this issue.
    Thanks in advance.
    Algorithmen und Datenstrukturen in C#:
    TechNet Wiki

    Thank you for your reply. Unfortunately ListItem does not contain a definition for the Fields method.
    Algorithmen und Datenstrukturen in C#:
    TechNet Wiki
    You need to use the Microsoft.SharePoint class library and then use the sharepoint version of all the list objects you are using. See below.
    //Get connection
    ClientContext context = new ClientContext("URL");
    Web site = context.Web;
    context.Load(site);
    context.ExecuteQuery();
    //Get list collection
    SPListCollection lists = context.Web.Lists;
    context.Load(lists);
    context.ExecuteQuery();
    //Get specific list
    SPList menu = lists.GetByTitle("menu");
    CamlQuery camlQuery = new CamlQuery();
    camlQuery.ViewXML = "<View/>";
    SPListItemCollection dishes = menu.GetItems(camlQuery);
    context.Load(menu);
    context.Load(dishes);
    context.ExecuteQuery();
    //Iterate through all dishes
    foreach(SPListItem dish in dishes)
    Console.WriteLine("Dish: {0}:", dish.FieldValues["Name"]);
    Console.WriteLine("Price: {0}:", dish.FieldValues["Price"]);
    //Here I get my problem
    SPFieldMultiLineText multilineField = dish.Fields.GetField("Ingredients") as SPFieldMultiLineText;
    string ingredients = "";
    if (multilineField != null)
    ingredients = multilineField.GetFieldValueAsText(dish["Ingredients"]);
    Console.WriteLine("Ingredients: {0}:", ingredients);}
    I hope this helps
    Alex

  • Rejection Applicant: How to add plain text to the mail E Mail Letter?

    Dear All:
    I'm working with a ECC6 version.
    In transaction PB60, when we do the candidate rejection activity, the E Mail letter generates a mail with empty body text, and an attachment with the letter in PDF format. The letter is OK, but I would like to know how to add some plain text to this E Mail letter. An empty mail is not a good practise.
    I searched across the forums and SAP documentation, but I could not find any clue.
    I would appreciate any help regarding to this matter.
    Best regards
    Jordi

    Here you go !  ( you need to create Text in t-code SO10 for ID = PAML " )
    Two Default texts under  ID = PAML :
    *MAIL-APP-INTERVIEW     *EN     TEXT     PAML     SYSTEM
    MAIL-APPLICANT     EN     TEXT     PAML     SYSTEM
      Personnel Management->Applicant Activities->Mail Connection ->Create standard texts for mail connection
    Create standard texts for mail connection
    In this step you can create the standard texts to be used in mails.
    Example
    u2022     Request for return of applicant file
    u2022     Notification of date of job interview
    Requirements
    u2022     You should have assigned a standard text to the activity.
    u2022     You should also have set the variables which are to be used.
    u2022     Finally, you should also have made the settings for supplying the variable with values.
    Standard settings
    The standard system contains two examples of standard texts. You can use these examples as references to help you create your own standard texts. The standard texts have the following names:
    u2022     MAIL-APPLICANT (note on an applicant activity)
    u2022     MAIL-APP-INTERVIEW (note on appointment for interview)
    Please note that the standard texts are stored under text ID PAML.
    Activities
    Now create the standard texts you require under text ID PAML.
    Further notes
    Every mail is made up of a heading and contents. In the first line of the standard text you enter the heading of the mail and from the second line on, the contents.
    The standard default settings for style and layout are used for mails.
    The SAP System treats standard texts as application data. This is why there is no automatic connection to the transport system. If you want to copy texts from one client to another within the same system, please use the functions of the transaction to create the texts. If you want to send the texts to a different system, please enter the transport manually as follows:
    PgmID   Obj     Objectname
    R3TR    TEXT   TEXT,XYZ,PAML,E
                     |    |   |   --- Language (e.g. E for English)
                     |    |   -
    Text ID (e.g. PAML for standard mails)
                     |    -
    Text name (probably not XYZ)
    Text object (TEXT ist fixed)
    Good luck
    Saquib Khan

  • How to set plain-text for outgoing messages?

    I just upgraded from a Pre "minus" to a Pre 2 with WebOS 2.1 . I now have mail recipients complaining that my messages are in HTML. How to I revert to plain-text for sending messages?
    Post relates to: Pre p100eww (Sprint)

    Hi jason ,
    For setting Heder text for your ALV table
    ip_confing type ref to CL_SALV_WD_CONFIG_TABLE.
    "set alv table header
      ip_config->if_salv_wd_table_settings~r_header->set_text( 'Test ALV Header functionality' ).
    first you have to hide the DDIC text and then try to set your own text .
    "modify columns
      LOOP AT lt_columns INTO ls_column.
        lr_column = ls_column-r_column.
        CASE ls_column-id.
          WHEN 'MANDT'.
            "hide this field
            lr_column->set_visible( cl_wd_abstr_table_column=>e_visible-none ).
           WHEN 'SEQNR'.
            "set header to different string
            lr_column->r_header->set_ddic_binding_field( if_salv_wd_c_column_settings=>ddic_bind_none )." use this line to hide ddic text
            lr_column->r_header->set_text( 'Position' ).     
        endcase.
      endloop.
    Regards
    Chinnaiya P

  • How to add plain text editor in OA Framework page

    Hi,
    I have created a page in which i have added rich text editor item but in place of rich text editor we only want to use plain text editor in page with no extra features.
    How can we use plain text editor in page in place of rich one.Is there any property i need to change or i need to add any other item??
    I have tried message style text by increasing its length and height in visual properties but there comes a vertical bar which i do not want.
    Thanks for help in advance!
    Prateek
    Message was edited by:
    Prateek

    Try to see if OARawTextBean helps
    Thanks
    Tapash

  • How to send plain text body in HTTP Post method ?

    Hi Exeperts,
    I have a scenario http post - ptoxy. Sender sending the data in http post in plain text body (only field values will be in the body).
    how should i capture this plain text for receiver to map..
    is any udf or xsl code ?
    please guide me for achieving this requirement .
    find the attachment for http post body value.
    Regards
    Ravi

    Hi Mark,
    Thanks for your reply,
    Please share you have any udf  for this .
    can you explain me how should i map to target side.
    what are the configuration should i done in communication channel level
    Regards
    Ravinder.s

  • How to save plain text attachments

    I often get email with plain text attachments (e.g., source code).
    Mail tries to be smart and displays the attachments in the body of the mail.
    But I wold like to save them as usual. I can't even control-click on them
    Does anyone have an idea what I can do?
    TIA,
    Gabriel.

    I guess I should've said that up front:
    Yes, I can highlight the text and save it in TextEdit, but that's way too tedious , because I get a lot of emails with several text attachments, and I have a hard time figuring out the boundaries between text attachments ...
    Best regards,
    Gabriel.

  • How to create a text Component With Certain Properties

    I need to create a text component with the following properties:
    Has Capability to be italic, right/left aligned, have different background / foreground colors, and most importantly, the ability to have a fixed width and a height that is set by the amount of text in it (ie line wrapping expands the field vertically).
    It should be a simple exercise, but I cannot seem to figure out how to do it.

    Here is the correct syntax :
    private static JEditorPane constructPane(String text, int normWidth, int normHeight, boolean rightAlign, boolean italic,boolean isWhite) {
              JEditorPane pane = new JEditorPane();
              pane.setEditable(false);
              pane.setContentType("text/html");
              pane.setText(
                   "<html><head></head><body>"
                   + (italic?"<i>":"")
                   + "<table><COLGROUP><COL width=\""+normWidth+"\"><THREAD><tr><td valign=\"top\" align="+(rightAlign?"\"right\"":"\"left\"")+">"
                   + text+"</td></tr></table>"
                   + (italic?"</i>":"")
                   + "</body></html>");
              pane.setSize(normWidth,normHeight);
              if(isWhite)
                   pane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(1,0,1,0,Color.WHITE),BorderFactory.createEmptyBorder(0,1,0,1)));
                   pane.setForeground(Color.WHITE);
              else {
                   pane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(1,0,1,0,Color.BLACK),BorderFactory.createEmptyBorder(0,1,0,1)));
                   pane.setForeground(Color.BLACK);
              return pane;
         }

  • Wondering how to create a text box with variables...

    Hi everyone,
    I was wondering how to create a text box, that at the beginning of the presentation, the audience fills in regarding what they think constitutes the role they have been chosen for.
    I would like that same box to then appear at the end of the presentation, with the text they typed in at the beginning, so they can reflect on what they think now, and what they thought then. I understand this is done using variables, but i'm not 100% sure.
    I hope I've worded this okay!

    This screenshot shows the properties panel, Style tab for the TEB. I relabeled it to My_TEB, used the X button  to create a user variable v_choice that will replace the generic Text_Entry_Box_1/
    This is the properties panel of a Shape, I went in Edit mode (double clicking)to make the Character section appear, where you find the X button. It opens the dialog box 'Insert Variable' and you can choose the var associated with the TEB. The Maximum Length will define how many characters will be displayed, the value of a variable has maximum 256 characters.

  • How to compare the texted password with the encrypted password of dba_users

    Hi,
    I have Oracle 10g in my system. I know dba_users table has information of all the created users of the oracle, along with their encrypted passwords.If I want to make a login page based on this table ,how could I compare the password in that case?
    In above situation, I am getting the username with the regular texted password for authentication check. How can we checked this texted password with the encrypted password of dba_users, for the respective username?
    Your input would be appreciated.

    Try use the username/password from login page to create an connection to database.

  • Plain Text Warning with Notes

    Whenever I write a note in Mail and I attempt to add a To-Do, change the font, or add any amount of formatting to it, I get a dialog that says:
    "Convert this note to rich text format?
    Changing the style or formatting requires that this note be converted to rich text format. Rich text notes may not be editable on iPhone and other devices."
    I get this on every note I create. I just got an iPhone and I'm wondering if syncing it with mail has forced it to create notes in plain text. If I go to Preferences > Composing Rich Text is selected as the default formatting.
    Any ideas?

    I did not change anything as far as fonts or amy default settings. I actually deleted the mail plist to try to reset mail. J still got the message on every note.
    Posted from my iPhone

  • How to print a text file with pagebreak.......

    hi to all,
    i am new in java and i want to do print a text file with page break. that text file is converted from html view page with help of htmlconveter class and i want to set page break in the text file.ASCII 12 is not work properly.its not break a page in proper manner.plz reply soon.

    hi to all,
    i am new in java and i want to do print a text file with page break. that text file is converted from html view page with help of htmlconveter class and i want to set page break in the text file.ASCII 12 is not work properly.its not break a page in proper manner.plz reply soon.

  • How to print Arabic text along with the English in smartform ( ECC6 version

    Hi All,
    our is ECC6 version, Non unicode, ABAP stack ( not dual stack )
    is it possible to print in Arabic language in the above version ?
    if yes, then please let me know how to print Arabic text and English text in the same smartfrom.
    i tried in the following procedures :
    1) i created standard text (SO10) in arabic language.
    i called in the smartform ( include text - i )
    langage AR
    but system throws error message saying, required language is not installed.
    2) if i use READ_TEXT function module.
    text getting printed in diff format but not in arabic.
    waiting for your replies..

    ECC6 and Non-Unicode? I think you'll need multiple code pages, I doubt there's a mixed Arabic/Latin1 available. And I don't think SAP supports new MDMP systems any more. If you need to support multiple languages you really need to go Unicode. It's probably easier to do the Unicode conversion than to try to support multiple code pages and you have to make the switch eventually.

  • How to convert plain text into html?

    Hi
    I'm looking for a nice method which converts any plain text to html. For example, text: "Me and you\nand a dog named boo."Conversion result should be:
    <html>
    <body>
    Me and you<br>
    and a dog named boo.
    </body>
    </html>I know, I could write such a code myself using regex. But I just wonder whether something like this already exists in the java api?
    Greetings from Switzerland
    Mickey

    Use a StringReader to read the lines and add the lines between <html><pre> ... </pre></html>

Maybe you are looking for