Roave / DocbookTool

:books: Docbook Tool for static documentation generation from Markdown files
52 stars 4 forks source link

Confluence feature - Replace relative links to markdown within scope with confluence page links (if available) #305

Closed asgrim closed 2 months ago

asgrim commented 1 year ago

Given a link like [Reporting Overview](./another-file.md), assuming another-file.md also has a confluencePageId, we could replace the link with a Confluence link, e.g. https://<confluence-url>/pages/viewpage.action?pageId=<linkedConfluencePageId>.

ciaranmcnulty commented 1 year ago

It would be great if anchors can also work (i.e. links to specific headings) - I assume it'd be a case of adding IDs and preserving hash segments in URLs

asgrim commented 1 year ago

Note: Confluence already creates the anchors themselves, for every heading, automatically - but the links TO the anchors are structured very differently (they auto generate an id=... attribute for each heading, based on the heading content).

ciaranmcnulty commented 1 year ago

So we'd need to do something like:

asgrim commented 1 year ago

So we'd need to do something like:

* explicitly add a markdown anchor

* replace the link during conversion to link to an ID based on the heading contents
  ?

Yep, but just the second one - Confluence automatically adds anchors to all headings; we just need to replace the links with the correct fragment when pushing to Confluence

ciaranmcnulty commented 1 year ago

I mean that if someone has added a markdown anchor (which there actually seems like there are >1 format for) we'd need to resolve it to a heading, then rewrite the link to the heading text. I agree we'd not need to add an ID to the heading itself.