I have turned on $wgFileExtensions for pdf and uploaded a pdf-file and now I'm trying to create a pipe link to the corresponding file page like this:
[[File:test.pdf|Test file]]
But link text is ignored so the the link text is just the same as the url:
File:test.pdf
But i try to link to a png-file like this:
[[File:test.png|Test file image]]
Then everything works fine and the link text is like expected:
Test file image
Do i need to add any changes in the config, to allow pipe links to added filetypes?
And how do i do that?
To link to a page in the File namespace, put a colon before, like this:
[[:File:test.pdf|Test file]]
Otherwise, MW will try to embed the file. This has nothing to do with the file type, and the only reason it “works” in the test.png example is probably that the file test.png does not exist on your wiki.
Another namespace that has a special behaviour is the Category namespace, where adding a link like [[Category:Birds in Africa]], will add the current page to the category, whereas a link to the category page would need to look like this: [[:Category:Birds in Africa]] (or, more likely [[:Category:Birds in Africa|Birds in Africa]]).
Related
i have a piece of code that let's the user see find a file how do i get it to display where it is save eg desktop/folder/file.
my current code is a basic file input that goes like
<input type="file"/>
i want my page to display where the file is saved also on a side not is there a way to display search file results. I look up programing work and my page will show everything that is programing work in its name.
i have not tried anything as i am unsure where to start.
I'm pretty sure you want to get the full file path of a file uploaded via an HTML input element, if not, let me know.
If so, such behavior is intentionally blocked by most browsers, except for firefox. See How to get full path of selected file on change of <input type=‘file’> using javascript, jquery-ajax?. If you want to raed the file, you can use the FileReader class. Alternatively, you can make an object URL to the file object, on the onchange event, simply
var url = URL.createObjectURL(event.target.files[0]);
to use for reading purposes.
I want to create a index in markdown, which are anchors to the chapters, like:
1. Greeting
2. Main Part
...
## 1. Greeting
some txt
## 2. Main Part
other txt
I've already done this:
1. [Greeting](#greeting)
...
## 1. Greeting {#greeting}
some txt
In markdown and md-preview it's working. For converting, I'm using Remarkable. I like the css-options, so the most online-tools will be useless.
If I trying to convert the md-file to pdf, the pdf-file contents the inline-links, but it doesn't linked correctly. So it will open the folder in which the file saved, if I click on the index-link.
Also, I tried to converting to html first, html to pdf second, but it's doesn't linking correctly either.
Some online-uses of markdown index (like github) will create own html-id to set anchors.
I'm looking for solution that works local over commmand line or other programm. The solution should be abe to convert md with custom css style and anchors / inline lines to pdf.
If you look at the generated HTML you see that the generated id is actually 1-greeting, so this worked for me:
1. [Greeting](#1-greeting)
...
## 1. Greeting
some txt
See also How to link to a named anchor in Multimarkdown?
I have a .txt file containing code that I cannot change the contents of. And I need to display it in two ways.
One way is inside a div as selectable, copy-able type (currently done with:
<pre><?php include '/file_location.txt';?></pre> ).
The other way is as a direct link to the .txt file so such link can have it's address copied and emailed to someone, saved as..., or any other function one might like a direct link for. (So just like <a href="/file_location.txt"> basically.)
The issue is that when php including the text file into a div any <%> strings interfere with the original source text. I need to preserve the integrity of the original .txt files (so I can't go changing all the left carrots into <).
So is there a good way to display the contents of the text file without issues with < > and still maintain it's original integrity for sake of direct-linking?
EDIT:
I currently have two separate files performing this function, one with html encodings and the raw unedited .txt file. I'd really like to get these two displays working with just one file so that each new bit of source code doesn't need to be converted to an html-friendly version and adding just its .txt file will grant both view options.
EDIT 2:
Using <textarea> instead of <pre> will not interfere with the < characters and i could CSS it to look how I want, but I don't like the idea of the user being able to resize it themselves.
You can use
<?php echo htmlspecialchars(file_get_contents("file.txt")) ?>
instead of
<?php include '/file_location.txt';?>
to display special HTML characters from a text file.
I am using this for my php files. I think it will be usefull for you too.
<?php
highlight_file("test.php");
?>
edit: I tried on a html file and it worked.
I would try to add <pre></pre> at the beginning/end of your .txt. I'm not sure if I fully understand your question, but I think this will not interfere with the <> tags.
I have two image files in my directory. One is called abc1.png and the other is called #abc1.png.
When I do
<img src="abc1.png" alt="Figure">
in my HTML file, it works fine. But when I do
<img src="#abc1.png" alt="Figure">,
the image doesn't show up. Why is it?
In HTML the # sign is a reference to a named anchor in the document. You are telling the browser to look for that. Instead, use the URI-encoded version of #:
<img src="%23abc1.png" alt="Figure">
Depending on your setup, you may have to double-encode it.
Is it possible to link to a line number in a html file? I want to link someone to part of a very large document which is on a webpage but the whole thing is in one tag so is not split into sections with IDs I can link to.
Here is the page I'm talking to, id like to link to "LEVEL 46" can I do this?
I would be just as happy with another workaround such as searching for the text or anything, I assume this could be made more complicated by it being in various wrappers, assuming it was just a plain .txt file could you do it?
Edit: im not writing the web page im trying to link to a part of someone elses, so i cannot add IDs etc
No it doesn't appear to be possible.
<a href="#a-place-in-the-document></a>
...
<h1 id="a-place-in-the-document">There's a link to here!</h1>
The link will have the page jump to the element with the specified ID.
For example: http://example.com#hello will link to http://example.com and immediately go to the element with ID of hello.
In the case where you can't have IDs (such as in text files on gamefaqs), you'd need to provide a search string, for people to quickly search and find whatever section you need (such as [LV46]), and have your readers to search for it.
You would need to convert all of your Headings into anchor tags.
So for your example the link would be:
<a href="#Level46">
The heading itself would be:
<h1 id="Level46">Level 46</h1>
Hope this helps.
If it is just a text file, or a collection of text files in a directory structure, you can create a parallel directory structure so people can browse
http://pdssbn.astro.umd.edu/holdings/
as
http://pdssbn.astro.umd.edu/byline/holdings/
and generate line numbers and/or anchors to individual lines on the fly, even if other non-text files are under the /holdings/ tree, with an Apache HTTPd AliasMatch like this
AliasMatch /byline/holdings/.*[.](asc|cat|lbl|tab|txt) /path/cgi-bin/pds_byline.cgi
and a symlink e.g. assuming your tree is under top/ e.g. top/holdings/,
ln -s . .../top/byline
and a simple script (cgi-bin/pds_byline.cgi above) that converts the text file to HTML on the fly. I have created a Git repo to do just that here; that is configured for Planetary Data System (PDS) data sets under http://pdssbn.astro.umd.edu/holdings/.
You would of course need access to the Apache HTTPd configuration files (/etc/httpd/conf/conf//.conf) to do this, to put in a
<Directory .../top/cgi-bin>
AllowOverride All
</Directory>
entry to use a .htaccess file in cgi-bin/, and the AliasMatch above, at a minimum. N.B. AliasMatch cannot go into the .htaccess file.
Caveat: this only creates anchors by line number; if the file changes over time then existing links to those line numbers will be broken; you could of course do the same thing instead looking for specific text strings like "Level 46" and inserting the relevant anchors on the fly.
<a name="destination" id="destination"></a>Destination anchors
Destination anchors
Source:
http://www.motive.co.nz/glossary/anchor.php#destination
Maybe you could define an anchor for the specific line as, for example, a section element. Then you could link to that anchor.
<section name"sec1">
<a href="sec1">