LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General > LinuxQuestions.org Member Success Stories
User Name
Password
LinuxQuestions.org Member Success Stories Just spent four hours configuring your favorite program? Just figured out a Linux problem that has been stumping you for months?
Post your Linux Success Stories here.

Notices


Reply
  Search this Thread
Old 05-23-2011, 08:56 AM   #1
porphyry5
Member
 
Registered: Jul 2010
Location: oregon usa
Distribution: Slackware 14.1, Arch, Lubuntu 18.04 OpenSUSE Leap 15.x
Posts: 518

Rep: Reputation: 24
How to have "Hypertext" Links in Text Files


A text file can behave as if it has internal hyperlinks, just like html or pdf; not quite so convenient to use, but much easier to create and maintain. The best way to appreciate it is to try it. Open the attached LinkedText in your favorite text editor. You'll notice that the text begins with a list of single compound words. These are your links. Select one of them, fire up your editor's Find function, and do whatever it takes to find the next instance. So for most gui editors, 2click the link, Ctrl-F, Enter. And there you have it.

Creating such files is a snap with the attached script txtlnk.sh. Save it in your current working directory (CWD). Open any other convenient text file in CWD.

In your terminal,

sh txtlnk.sh

and at the prompt type the name of the file you just opened in your text editor.

In that file, select, by dragging the mouse, any line down to include at least some text on a subsequent line. Repeat that process for as many different link/anchor pairs you wish to create.
NOTE: It only works by dragging the mouse, and, regardless of how many lines are included in any selection, the link/anchor pair will be formed only from the text on the 1st line that is selected. But it is essential to drag beyond the first line part way into a subsequent line of text.

When done, type a couple of digits and select only the digits with the mouse. The anchors are created in place, the links are sorted and placed at the start of the text, and the file is saved. Relax, the original was previously saved as a ~ file.

Unlike html, you can have multiple anchors for the same link with this method. If the first one doesn't suit, just press F3 to get the next one.

Lastly, you might want images with your text. At the appropriate places in your converted text, on their own lines, type something like

path/to/your/image.jpg

Select such paths by dragging with the mouse, again extending the selection into the text on a subsequent line, and run the attached script pixlnk.sh. I prefer starting this script with a hotkey because it terminates as soon as it starts ImageMagick's display portion, and must be re-invoked each time you need it.

NOTE: These scripts require xsel and imagemagick, which may not be included in your distro.
WARNING: These are my 4th and 5th Bash scripts, so no doubt rather amateurish. In particular, my scripts always assume that you have done the right thing, and, as I am the sole user of my system, have no clue as to the exigencies of multi-user systems
Attached Files
File Type: txt LinkedText.txt (2.8 KB, 272 views)
File Type: txt pixlnk.sh.txt (402 Bytes, 57 views)
File Type: txt txtlnk.sh.txt (1.8 KB, 96 views)

Last edited by porphyry5; 05-27-2011 at 07:37 AM. Reason: Improved txtlnk.sh
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Text editior that can "see"/open hiddien files/folders?? like .fluxbox linus72 Linux - Software 4 08-11-2009 07:34 AM
Moving text files between Windows and Linux: Unicode and "executable" problems AchubaNanoiaBR Linux - Newbie 2 07-04-2009 04:15 PM
Apache: Making sure text files remain "unknown" kenneho Linux - Server 2 03-04-2009 09:34 AM
shell scripting: "formatting" issue with text files eur0dad Programming 3 08-17-2006 10:50 AM
problem with "hypertext link" impeteperry Ubuntu 0 08-02-2006 03:15 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General > LinuxQuestions.org Member Success Stories

All times are GMT -5. The time now is 03:34 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration