Beautifying TeX source file using perl

Discussion in 'Perl' started by rgompa, Mar 29, 2008.

  1. rgompa

    rgompa

    Joined:
    Mar 27, 2008
    Messages:
    1
    Likes Received:
    0
    I wanted to write a program in perl to clean up source file in TeX.
    Source file is an ascii file in which there are special character that indicate special functions. For example, rest of the line after % will be ignored by TeX; any word that start with \ is a command which may not or may have any number of arguments enclosed in {}. Here is my plan for now:

    original text:
    this is a great project. % this is just my opinion.
    % You may disagree.
    What do you think?

    changed text:
    this is a great project.
    %%%%%%%%%%%%
    %% this is just my opinion.
    %% You may disagree.
    %%%%%%%%%%%%
    What do you think|?


    Original text:
    Please help me. \yourkindness{will be}{rewarded} by someone. %May not be me.

    changed text:
    Please help me.
    \yourkindness
    {will be}
    {rewarded}
    %%%%%%%%%%%%
    %% My not be me.
    %%%%%%%%%%%%

    Original text:
    I would like to convey my \thanks in advance.

    Changed text:
    I would like to convey my
    \thanks
    in advance.

    Each line in changed text should have atmost 100 characters and
    it should not break any word from the orignal text.


    Are there any programs already out there with these features?

    Will you please give me some suggestions how I can write such a program
    in perl?

    Thanks.
     
    rgompa, Mar 29, 2008
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.