Can Files Be Linked Within a TXT File?

  • Thread starter Thread starter mech-eng
  • Start date Start date
  • Tags Tags
    File files
Click For Summary

Discussion Overview

The discussion centers around the possibility of linking various file types, such as PDF and HTML, within a plain text (TXT) file. Participants explore different methods and applications that may facilitate this linking, including comparisons with HTML and markdown files.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant inquires about the ability to link files within a TXT file, specifically asking if clicking a link in a TXT file can open another file.
  • Another participant suggests creating an HTML file or a markdown file as alternatives, noting that browsers can open these files with links if the appropriate plugins are available.
  • A different reply emphasizes that simply typing a URL in a TXT file may allow some applications to follow the link, depending on the text editor used.
  • It is mentioned that while browsers can read TXT files with URLs, the functionality may vary, particularly with local files using the "file:///" protocol.
  • One participant points out that some browsers can interpret markdown files, allowing links to be created by enclosing URLs in angle brackets.

Areas of Agreement / Disagreement

Participants express differing views on the feasibility and methods of linking files within TXT files, with no consensus reached on a definitive solution. Various approaches are proposed, but the effectiveness of these methods remains uncertain.

Contextual Notes

Limitations include the dependency on specific applications or browser capabilities to follow links, as well as the potential issues with local file protocols not functioning as expected.

mech-eng
Messages
826
Reaction score
13
TL;DR
I am trying to link files
Is there anyway that pdf, html or any other type of files can be linked into a txt file? That is, I would like to click to a link in a txt that will open another file.
 
Computer science news on Phys.org
Instead of a text file, you can create an HTML file that references the others and then the browser can open them at a click provided it has a browser plugin that supports the filetype.

Alternatively, you could create a markdown file and then convert it to HTML and use the browser once again. Markdown files have a decidedly simpler syntax and are easy to write in a text editor such as VS Code.

I mention VS code because it has a markdown preview mode that can display the markdown file and then will follow links listed in the markdown text to open the relevant web page or pdf file.

One more point is that all file references should be in URL format even if they are local ie use file:// for local files. Although it seems that the local URL doesn't work in VS code preview like http.
 
mech-eng said:
Is there anyway that pdf, html or any other type of files can be linked into a txt file?
Yes, simply type the URL in the file e.g.
Code:
https://www.physicsforums.com/threads/linking-files-into-a-txt-file.996247/#post-6419210

mech-eng said:
That is, I would like to click to a link in a txt that will open another file.
It is not files that follow links, it is the application you use to read the file. Are you asking 'is there an application that will follow links in txt files'? Some advanced text editors (like VS Code already mentioned) can do this.
 
When you select a URL (that is not a link), most browsers will offer an option in the context menu (right-click) to open the URL (Firefox: "Open Link"; Chrome: "Go to [...]"). Although, it doesn't work for local files ("file:///" protocol)

Browsers can read txt files, thus it works with URLs in these files too!

If your browser has an extension (Chrome) or add-on (Firefox) to read a markdown file (basically a text file with extension .md instead of .txt), all you have to do is enclose the URL in angle brackets like so <scheme://www.example.com/> to create a link.
 
  • Like
Likes   Reactions: jedishrfu

Similar threads

  • · Replies 15 ·
Replies
15
Views
3K
  • · Replies 15 ·
Replies
15
Views
2K
  • · Replies 16 ·
Replies
16
Views
5K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 3 ·
Replies
3
Views
6K
  • · Replies 2 ·
Replies
2
Views
1K
Replies
4
Views
2K
  • · Replies 3 ·
Replies
3
Views
1K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 13 ·
Replies
13
Views
3K