How to link to internal link with ampersand? - url

I am trying to make an internal link to a heading called "word & word".
Since I am using Jekyll, the content is in Markdown files and the heading I want to link to looks like this:
### word & word
I know that I can not use & in URLs.
Therefore this would not be an option:
#word-&-word
I also tried:
#word-%26-word
and
#word-&-word
#word-%26amp;-word
#word-%20amp%3B-word
However, both versions are not working.
What would be the appropriat way to fix this?

Kramdown is striping non alphanumeric from header id's and replacing spaces by -.
You can just check this behavior with :
- mandatory
{:toc}
### word & word
Resulting link in generated table of content is #word--word
See kramdown documentation

Related

markdown link to header

I'm using GitLab to write a read.me file.
I tried to create a link to a header. According to the wiki an id should be automatically created:
see here
I created a header using:
### 1. This is my Header
and tried to create a link to it:
[link](#1--this-is-my-header)
but it is not working.
What am I doing wrong?
In the Documentation you link to we learn that...
The IDs are generated from the content of the header according to the
following rules:
All text is converted to lowercase.
All non-word text (e.g., punctuation, HTML) is removed.
All spaces are converted to hyphens.
Two or more hyphens in a row are converted to one.
If a header with the same ID has already been generated, a unique incrementing number is appended, starting at 1.
Note rule 4: "Two or more hyphens in a row are converted to one." However, the example you tried has two hyphens in a row (after the 1). Remove one of them and you should have it.
[link](#1-this-is-my-header)
From time to time I have encountered a unique header which is converted into an ID in some non-obvious way. A quick way to work out the ID is to use your browser's view source and/or inspect tools to view the HTML source code. For example, you might find the following HTML for your example:
<h3 id="1-this-is-my-header">1. This is my Header</h3>
Then just use the contents of the id attribute with a hash to link to that header: #1-this-is-my-header.
Markdown IDs are generated using some rules i've been able to google: (text to lowercase, non-word punctuation removed, spaces converted to hyphens, two or more hyphens in a row converted to one, naming collisions have incremented number appended, ...)
I found an easy way to figure out what the anchor link should be. Use your browser's HTML inspector to inspect the header you want to link to. The header tag's ID should be what you use. So for example my heading looks like this in the HTML inspector:
<h2 id="markdown-header-changing-plsql-parameters-and-shared-developers-lifecycle">
Changing PL/SQL parameters and shared developer's lifecycle
</h2>
And I can link to it in markup like so:
[See instructions below](#markdown-header-changing-plsql-parameters-and-shared-developers-lifecycle)
And now "See instructions below" is linked to my header anchor.
There is a simpler way than the inspector, at least in GitLab-flavored mardown : hover over the header and a "chain" icon appears : right-click on it and copy the link.
header with clickable chain

Creating a dynamic hyperlink in Word with XDocReport

I need to create a hyperlink using XDocReport where both the URL and display name are provided using Velocity tags. There is some reference to this on the XDocReport web site, but no real guidance.
Other things I have tried, like http://blog.softartisans.com/2013/12/31/kb-creating-dynamic-links-with-mergefields-in-microsoft-word/, do not work.
Manage hyperlink with XDocReport is like mergefield. XDocReport wiki page about hyperlink with docx can be found here, but I agree, it should be improved.
If you cannot manage hyperlink with XDocReport and docx, I suggest :
use the XDocReport macro . There is a link checkbox to insert hyperlink instead of inserting mergefield.
download docxandvelocity-XXX-sample.zip or get Git project fr.opensagres.xdocreport.samples.docxandvelocity. You will find samples with hyperlinks.
Based on #MarkSalamon suggested link: http://blog.softartisans.com/2013/12/31/kb-creating-dynamic-links-with-mergefields-in-microsoft-word/ , it failed in my case too.
After debugging the opensagres library, it seems that instead of inserting a merge field inside the Hyperlink, the library is expecting there just a simple Freemarker placeholder. So it's enough to create the hyperlink from Word, and at the url definition part, you can specify there: ${url} .
That's it, the library is going to detect that there is a Freemarker syntax and replace the url with back-end data. So you don't have to do the trick with ALT+F9 and replace with merge field codes.
In my case this worked with opensagres version: 2.0.2

How to differentiate a link from text?

I have lines of text and I have to find whether these lines contain some link . how can I do it?Firstly I thought of finding www in the text but some links might not have www . Secondly I thought of finding http in text but again all links do not contain http. what to do?
Here is a regexp adapted from http://mathiasbynens.be/demo/url-regex entry by #diegoperini (Ruby syntax; you might need to change some details like Unicode \uXXXX to whatever your system uses):
(?:(?:https?|ftp):\/\/)?(?:\S+(?::\S*)?#)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?

Bold part of a url in markdown

I want to bold part of a url written in markdown.
URL: http://google.com
Intended result: http://google.com
In this example, I want to bold the word "google" inside the whole url. Here, I capitalized what I wanted to bold.
Related question: is there a way to prevent urls from turning into links?
I am processing this with a marked.js. I'm looking for something that will work in http://dillinger.io/
===== Part 2 =====
URL: http://google.com
Intended result: http://google.*com*
How do I also bold the .com part in addition to the google part?
This seems to work
[http://**example**.com](http://example.com).
Using http://daringfireball.net/projects/markdown/dingus the above gives the HTML result:
http://<strong>example</strong>.com
That is exactly what you want.
I'm using markdown and jekyll, and the markdown doc says you can't have any formatting between "ticks." I even tried it with a block and the asterisks still print as characters, because you can't put spaces in a URL and the formatting requires spaces to work. Even HTML commands print as characters ().

Linking on a Redmine Wiki

I'm writing a wiki on Redmine for the program my company just developed. I've been reading Redmine Wiki formatting pages but I simply can't find how to link to headers on a page that hold spaces.
For example:
This works [[Setup#Oracle|Oracle Setup]]
This does not work [[Setup#Oracle DB|Oracle DB Setup]]
The second I have a header with a space, hyphen, underscore... ANYTHING more than one word, Redmine is unable to link.
Any ideas how to link correctly?
Hyphens worked for me using the textile formatting.
[[Wiki#Test-link-target|a link]]
If you open the wiki page you should see a little paragraph symbol next to each header that appears when you hover your mouse there. That should give you the (semi-)permalink you can use. You can always look at the wiki pages source for the link names.
One problem I remember when working on the Markdown filter was that each text formatter would create it's table of contents separately. So the anchor links for textile might be different than the ones for plain text or Markdown.

Resources