From 463ad479316ff2059e449847fa3ee6f01503a79f Mon Sep 17 00:00:00 2001 From: Kaushal Modi Date: Wed, 8 Nov 2017 13:12:45 -0500 Subject: [PATCH] Add test for links to Org targets http://orgmode.org/manual/Internal-links.html --- test/site/content-org/all-posts.org | 68 +++++++++++---- .../content/posts/link-heading-custom-id.md | 2 +- .../content/posts/links-to-org-targets.md | 86 +++++++++++++++++++ 3 files changed, 137 insertions(+), 19 deletions(-) create mode 100644 test/site/content/posts/links-to-org-targets.md diff --git a/test/site/content-org/all-posts.org b/test/site/content-org/all-posts.org index 3c9579e..c564b7f 100644 --- a/test/site/content-org/all-posts.org +++ b/test/site/content-org/all-posts.org @@ -1442,7 +1442,30 @@ This is a *special* case where: The passing case for this test would be that the =unexpected_tag= does not leak into the post's front-matter. * Links :links: -** Within the same post +** Links with target attribute +:PROPERTIES: +:EXPORT_FILE_NAME: links-with-target-attribute +:EXPORT_HUGO_BLACKFRIDAY: :hrefTargetBlank nil +:END: +#+ATTR_HTML: :target _blank :rel noopener +[[http://orgmode.org/manual/Hyperlinks.html][This link (to Hyperlinks chapter in Org manual)]] will open in a new tab +as it is annotated with ~target="_blank"~. + +#+ATTR_HTML: :target _self +[[http://orgmode.org/manual/Hyperlinks.html][Here's the same link]] but with ~target="_self"~ annotation. So +clicking it will open that link in this same tab! + +#+ATTR_HTML: :width 10% :target _self +[[http://orgmode.org/img/org-mode-unicorn-logo.png][http://orgmode.org/img/org-mode-unicorn-logo.png]] + +Above is a link to an image. The =width= attribute of /10%/ though +must apply *only* to the image, and not to the link, and the =target= +attribute must apply *only* to the link, and not to the image. + +[[http://orgmode.org/manual/Hyperlinks.html][Here's the same link again]], but this time there is no =#+ATTR_HTML= +annotation. So the behavior will depend on the browser (typically an +external link will open in a new tab automatically). +** Within the same post (Internal links) :internal_links: *** Link to a heading CUSTOM_ID :PROPERTIES: :EXPORT_FILE_NAME: link-heading-custom-id @@ -1464,29 +1487,38 @@ not leak into the post's front-matter. :CUSTOM_ID: link-heading-2 :END: - Link to [[#link-heading-1][Heading 1]] -** Links with target attribute +*** Links to Org targets :noexport: :PROPERTIES: -:EXPORT_FILE_NAME: links-with-target-attribute -:EXPORT_HUGO_BLACKFRIDAY: :hrefTargetBlank nil +:EXPORT_FILE_NAME: links-to-org-targets :END: -#+ATTR_HTML: :target _blank :rel noopener -[[http://orgmode.org/manual/Hyperlinks.html][This link (to Hyperlinks chapter in Org manual)]] will open in a new tab -as it is annotated with ~target="_blank"~. +*Note*: This test is marked as =noexport= because the Org generated + link IDs are random and thus would fail the tests. So let this test + serve just as an example and not as a part of the automated test + suite. -#+ATTR_HTML: :target _self -[[http://orgmode.org/manual/Hyperlinks.html][Here's the same link]] but with ~target="_self"~ annotation. So -clicking it will open that link in this same tab! +To export this test, you'll need to temporarily remove the =noexport= +tag. +----- +From [[http://orgmode.org/manual/Internal-links.html][(org) Internal links]], -#+ATTR_HTML: :width 10% :target _self -[[http://orgmode.org/img/org-mode-unicorn-logo.png][http://orgmode.org/img/org-mode-unicorn-logo.png]] +#+BEGIN_SRC org +- one item +- <>another item +Here we refer to item [[target]]. +#+END_SRC -Above is a link to an image. The =width= attribute of /10%/ though -must apply *only* to the image, and not to the link, and the =target= -attribute must apply *only* to the link, and not to the image. +will output below (/lorem-ipsum/ added to increase page content so +that the link jump is evident): -[[http://orgmode.org/manual/Hyperlinks.html][Here's the same link again]], but this time there is no =#+ATTR_HTML= -annotation. So the behavior will depend on the browser (typically an -external link will open in a new tab automatically). +- one item +- <>another item + +/Scroll to the end of the below 'lorem-ipsum' block to find the test +link./ + +#+INCLUDE: "./all-posts.org::#lorem-ipsum" :only-contents t + +*Here we refer to item [[target]].* * Equations :equations: ** Inline equations :PROPERTIES: diff --git a/test/site/content/posts/link-heading-custom-id.md b/test/site/content/posts/link-heading-custom-id.md index b675d7d..bf891e3 100644 --- a/test/site/content/posts/link-heading-custom-id.md +++ b/test/site/content/posts/link-heading-custom-id.md @@ -1,7 +1,7 @@ +++ title = "Link to a heading CUSTOM_ID" date = 2017-07-28 -tags = ["links"] +tags = ["links", "internal-links"] draft = false +++ diff --git a/test/site/content/posts/links-to-org-targets.md b/test/site/content/posts/links-to-org-targets.md new file mode 100644 index 0000000..7aec0c1 --- /dev/null +++ b/test/site/content/posts/links-to-org-targets.md @@ -0,0 +1,86 @@ ++++ +title = "Links to Org targets" +tags = ["links", "internal-links"] +draft = false ++++ + +**Note**: This test is marked as `noexport` because the Org generated + link IDs are random and thus would fail the tests. So let this test + serve just as an example and not as a part of the automated test + suite. + +To export this test, you'll need to temporarily remove the `noexport` +tag. + +--- + +From [(org) Internal links](http://orgmode.org/manual/Internal-links.html), + +```org +- one item +- <>another item +Here we refer to item [[target]]. +``` + +will output below (_lorem-ipsum_ added to increase page content so +that the link jump is evident): + +- one item +- another item + +_Scroll to the end of the below 'lorem-ipsum' block to find the test +link._ + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque et +quam metus. Etiam in iaculis mi, sit amet pretium magna. Donec ut dui +mi. Maecenas pharetra sapien nunc, ut mollis enim aliquam quis. Nam at +ultricies metus. Nulla tempor augue in vestibulum tristique. Phasellus +volutpat pharetra metus quis suscipit. Morbi maximus sem dolor, id +accumsan ipsum commodo non. + +Fusce quam ligula, gravida ac dui venenatis, bibendum commodo +lorem. Duis id elit turpis. Integer sed diam nibh. Donec tempus +lacinia odio, a laoreet velit dictum id. Suspendisse efficitur euismod +purus et porttitor. Aliquam sit amet tellus mauris. Mauris semper +dignissim nibh, faucibus vestibulum purus varius quis. Suspendisse +potenti. Cras at ligula sit amet nunc vehicula condimentum quis nec +est. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices +posuere cubilia Curae; Donec iaculis, neque sit amet maximus rhoncus, +nisl tortor convallis ante, ut mollis purus augue ut justo. Praesent +felis urna, volutpat sit amet posuere dictum, luctus quis nibh. Proin +et tristique ipsum, in aliquam ante. + +Aenean eget ex mauris. Cras ut tempor quam. Curabitur eget nulla +laoreet, bibendum neque porta, tempus nulla. Ut tellus nisi, semper eu +ligula pretium, aliquam accumsan dolor. Nunc fermentum cursus arcu eu +suscipit. Nam dolor tellus, efficitur sed condimentum at, fringilla +eget nisi. Nulla luctus metus felis. Suspendisse potenti. Cras lacinia +orci nec dui sodales commodo. Donec tellus arcu, congue porta ultrices +non, pretium et sapien. Proin mattis risus dignissim feugiat +tristique. Donec nibh lorem, facilisis id posuere ut, varius ac +urna. Etiam ultrices dignissim mauris, quis venenatis ex semper ut. + +Curabitur id fermentum erat, rhoncus scelerisque est. Sed pulvinar, +nulla sed sollicitudin scelerisque, ipsum erat sollicitudin dolor, ut +commodo arcu justo vel libero. Curabitur turpis dolor, fermentum ut +elit a, vehicula commodo nunc. Sed sit amet blandit nulla, quis +sodales massa. Donec lobortis, urna vel volutpat ullamcorper, mauris +est efficitur nulla, et suscipit velit dui at metus. Aliquam id sem +sed metus tristique scelerisque nec vitae odio. Phasellus a +pellentesque libero, vel convallis metus. Sed nec fringilla magna, non +varius ex. Sed interdum eleifend ligula, quis porta enim ultrices +a. Donec hendrerit diam ac elementum tincidunt. + +Pellentesque eget nisl rhoncus, malesuada justo nec, suscipit +quam. Nam sodales mauris eu bibendum suscipit. Vivamus sodales dui +lorem, scelerisque pellentesque diam fermentum sed. Etiam fermentum +nisl id nisl blandit, sit amet semper erat ultricies. Nulla tincidunt +nulla metus, eu imperdiet lorem malesuada sagittis. Maecenas accumsan +risus sed ante eleifend, vitae pretium leo porta. Suspendisse vitae +eros vitae dui ornare condimentum id sit amet mauris. Etiam tincidunt +consequat risus, eu posuere mi. Donec ut nunc eu massa porttitor +suscipit nec nec neque. Suspendisse vitae tincidunt justo, sed +molestie velit. Nullam pellentesque convallis ante, vel posuere libero +blandit in. + +**Here we refer to item [2](#org6cdb293).**