Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
[docs] Anchors in Markdown?
In the sleffort (slog effort) to convert new docs from Textile to Markdown, most of the pages I edited employ an in-page ToC, for example. No problem with Textile, but how do you set such anchors with Markdown? Or do we lose those ToCs and the affordance they provide to page usability.
Offline
Re: [docs] Anchors in Markdown?
Try this (untested) – make your anchor in the document:
<a name="banana"></a>
…and then link to it:
[soft, yellow fruit](#banana)
Any good?
Offline
Re: [docs] Anchors in Markdown?
Something else to try – again, untested, and my Markdown is very rusty.
Some implementations of Markdown generate implicit anchors with headers, so this:
## Ingredients
…would have an ID/anchor of #ingredients
. I think that linked text without an explicit target auto-links to its namesake anchor:
[Ingredients][]
…links to #ingredients
. Your mileage may vary.
Last edited by gaekwad (2016-09-05 15:33:09)
Offline
Re: [docs] Anchors in Markdown?
Sorry, I wasn’t clear. How do you target a header?
So if my ToC link item is:
[Attributes](#atts)
How to I target that to an <h2>
, for example.
Offline
Re: [docs] Anchors in Markdown?
Ah, cross-posting. I’ll try that.
Offline
Re: [docs] Anchors in Markdown?
Yep, that works. Thanks. That also ensures an exact match between ToC item and header label, which could be beneficial.
Offline
Re: [docs] Anchors in Markdown?
ToC:
# Fruit
* [Apple](#a)
* [Banana](#b)
* [Cherry](#c)
Target headers:
## Apple <a id="a"></a>
## Banana <a id="b"></a>
## Cherry <a id="c"></a>
Offline
Re: [docs] Anchors in Markdown?
Crossed in transit again. Glad it worked!
Offline
Re: [docs] Anchors in Markdown?
Oh, fark! There’s all kinds of footnotes and tables… This will take a year just to convert the little progress I actually made with docs before.
Do we really need to do this?
Offline
Re: [docs] Anchors in Markdown?
What can we do, Wion-san? Divvy up the work between some worker elves?
Offline
Re: [docs] Anchors in Markdown?
Hi.
You don’t need to make an anchor – Jekyll does that automatically for each heading within a doc. All you need to do is:
# Article
On this page:
* [Syntax](#syntax)
* [Attributes](#attributes)
* [Something else](#something-else)
## Syntax
Blah
## Attributes
Blah blah
## Something else
Blah blah blah
Hope that helps.
Offline
Re: [docs] Anchors in Markdown?
Destry wrote #301069:
Do we really need to do this?
If you mean convert to Markdown? Then yes we do. GitHub are dropping Textile from Jekyll anytime now (initially they said by May 2016 but it seems to have a stay of execution). This GitHub announcement came out of the blue without prior discussion. I know it’s annoying but it’s out of our hands.
Offline