Hello all, the title makes this sound simple, and maybe it should be.
This is by code:
This is what I am trying to do. I have a file like this:
Quote:
First there was nothing. Then there was Calvin[1].
That contains a body of text with footnotes markers, that are of exactly that format [i]. Square brackets are not used otherwise in the text... at least no patters of the form [integer] exist except for footnote markers.
I have a another file of the footnote text, like this
Quote:
[1] A memorable quote from Bill Waterson's Calvin and Hobbes.
What that code I wrote is attempting to do is:
Create a copy of the body text to mess with.
Count the number of footnotes that exist.
Initiate a For loop that will generate an $i for every integer up to $n, the number of footnotes.
grep the line starting with [$i] and save stick it into a temp file.
use awk to grab only the text portion of the footnote (skipping the [$i] number at the beginning of the line) and store that in variable r.
Finally, search the main file for the [$i] marker and add the footnote, alone with \footnote{} markup for latex.
Repeat hundreds of times (-;
I am not all that great with scripting, but this is my thought process and what I have tried. Right now... nothing happens. I execute the script, and it just hangs, and I have to break the script.
In case you are wondering, I am just trying to typeset Marx's Das Kapital for posterity and easier reading. I do not plan on printing or distributing... just taking a freely available reading material and making it pretty.
i am very new to UNIX
plz help me in this scenario
i have two text files as below
file1.txt
name=Rajakumar.
Discipline=Electronics and communication.
Designation=software Engineer.
file2.txt
name=Kannan.
Discipline=Mechanical.
Designation=CADD Design Engineer.
... (6 Replies)
Hi,
I want to replace the srting '; with ABCD'; in a file from line 1 to line 65. Is there any single command to do it without using awk
Thanks for quick reply
https://www.unix.com/images/misc/progress.gif (3 Replies)
To trim 3rd field in for all the lines of a file and replace the modified string in that particular field.
For example i have a file called Temp.txt having content
Temp.txt
-----------------
100,234,M1234
400,234,K1734
300,345,T3456
----------------
So the modified file output should... (4 Replies)
Can someone tell me how I can do this?
e.g:
Say file1.txt contains:
today is monday
the 22 of
NOVEMBER
2010
and file2.txt contains:
the
11th
month
of
How do i replace the word NOVEMBER with (5 Replies)
Hi
I am not the best scripter in the world and have run into a issue which you might be able to guide me on...
I have two files.
File1 :
A123, valueA, valueB
B234, valueA, valueB
C345, valueA, valueB
D456, valueA, valueB
E567, valueA, valueB
F678, valueA, valueB
File2:
C345,... (5 Replies)
Hi experts,
In my text file I have the following alot of lines like below.
input.k is as follows.
2684717 -194.7050476 64.2345581 150.6500092 0 0
2684718 -213.1575623 62.7032242 150.6500092 0 0
*INCLUDE
$# filename... (3 Replies)
Hi,
I want to achieve something similar to what described in another post:
The difference is I want to add the line if the pattern is not found.
File 1:
A123, valueA, valueB
B234, valueA, valueB
C345, valueA, valueB
D456, valueA, valueB
E567, valueA, valueB
F678, valueA, valueB
... (11 Replies)
I don't know if it's been asked before but seems i gave up seeking.
i have 2 files :
file1.txt
Monday XXXX
Tuesday XXXX
XXXX Wednesday
Thursday XXXX
XXXX is in every lines of file1.txt and i want to replace them with each line in file2.txt:
home
school
cinema
so output file is:
... (19 Replies)
HI
Can any one guide me how to achieve this task. I have 2 files
env.txt
#Configuration.Properties values
identity_server_url = http://identity.test-hit.com:9783/identity/service/user/register
randon_password_length = 6
attachment_file_path = /pass/temp/attachments/... (1 Reply)
Hi Everyone,
I have a requirement in ksh where i have a set of files in a directory. I need to search each and every file if a particular string is present in the file, delete that line and replace that line with another string expression in the same file.
I am very new to unix. Kindly help... (10 Replies)
Discussion started by: Pradhikshan
10 Replies
LEARN ABOUT DEBIAN
html::formattext::withlinks
HTML::FormatText::WithLinks(3pm) User Contributed Perl Documentation HTML::FormatText::WithLinks(3pm)NAME
HTML::FormatText::WithLinks - HTML to text conversion with links as footnotes
SYNOPSIS
use HTML::FormatText::WithLinks;
my $f = HTML::FormatText::WithLinks->new();
my $html = qq(
<html>
<body>
<p>
Some html with a <a href="http://example.com/">link</a>
</p>
</body>
</html>
);
my $text = $f->parse($html);
print $text;
# results in something like
Some html with a [1]link
1. http://example.com/
my $f2 = HTML::FormatText::WithLinks->new(
before_link => '',
after_link => ' [%l]',
footnote => ''
);
$text = $f2->parse($html);
print $text;
# results in something like
Some html with a link [http://example.com/]
my $f3 = HTML::FormatText::WithLinks->new(
link_num_generator => sub {
return "*" x (shift() + 1);
},
footnote => '[%n] %l'
);
$text = $f3->parse($html);
print $text;
# results in something like
Some html with a [*]link
[*] http://example.com/
DESCRIPTION
HTML::FormatText::WithLinks takes HTML and turns it into plain text but prints all the links in the HTML as footnotes. By default, it
attempts to mimic the format of the lynx text based web browser's --dump option.
METHODS
new
my $f = HTML::FormatText::WithLinks->new( %options );
Returns a new instance. It accepts all the options of HTML::FormatText plus
base
a base option. This should be set to a URI which will be used to turn any relative URIs on the HTML to absolute ones.
doc_overrides_base
If a base element is found in the document and it has an href attribute then setting doc_overrides_base to true will cause the
document's base to be used. This defaults to false.
before_link (default: '[%n]')
after_link (default: '')
footnote (default: '[%n] %l')
a string to print before a link (i.e. when the <a> is found), after link has ended (i.e. when then </a> is found) and when printing out
footnotes.
"%n" will be replaced by the link number, "%l" will be replaced by the link itself.
If footnote is set to '', no footnotes will be printed.
link_num_generator (default: sub { return shift() + 1 })
link_num_generator is a sub that returns the value to be printed for a given link number. The internal store starts numbering at 0.
with_emphasis
If set to 1 then italicised text will be surrounded by "/" and bolded text by "_". You can change these markers by using the
"italic_marker" and "bold_marker" options.
unique_links
If set to 1 then will only generate 1 footnote per unique URI as oppose to the default behaviour which is to generate a footnote per
URI.
anchor_links
If set to 0 then links pointing to local anchors will be skipped. The default behaviour is to include all links.
skip_linked_urls
If set to 1, then links where the text equals the href value will be skipped. The default behaviour is to include all links.
parse
my $text = $f->parse($html);
Takes some HTML and returns it as text. Returns undef on error.
Will also return undef if you don't pass it undef. Returns an empty string if passed an empty string.
parse_file
my $text = $f->parse_file($filename);
Takes a filename and returns the contents of the file as plain text. Returns undef on error.
error
$f->error();
Returns the last error that occured. In practice this is likely to be either a warning that parse_file couldn't find the file or that
HTML::TreeBuilder failed.
CAVEATS
When passing HTML fragments the results may be a little unpredictable. I've tried to work round the most egregious of the issues but any
unexpected results are welcome.
Also note that if for some reason there is an a tag in the document that does not have an href attribute then it will be quietly ignored.
If this is really a problem for anyone then let me know and I'll see if I can think of a sensible thing to do in this case.
AUTHOR
Struan Donald. <struan@cpan.org>
<http://www.exo.org.uk/code/>
Ian Malpass <ian@indecorous.com> was responsible for the custom formatting bits and the nudge to release the code.
Simon Dassow <janus@errornet.de<gt> for the anchor_links option plus a few bugfixes and optimisations
Kevin Ryde for the code for pulling the base out the document.
Thomas Sibley <trs@bestpractical.com> patches for skipping links that are their urls and to change the delimiters for bold and italic
text..
COPYRIGHT
Copyright (C) 2003-2010 Struan Donald and Ian Malpass. All rights reserved.
LICENSE
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
SEE ALSO perl(1), HTML::Formatter.
perl v5.10.1 2010-12-20 HTML::FormatText::WithLinks(3pm)