Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal Links in MediaWiki? (pandoc 1.10.1) #756

Closed
Milofax opened this issue Feb 19, 2013 · 24 comments
Closed

Internal Links in MediaWiki? (pandoc 1.10.1) #756

Milofax opened this issue Feb 19, 2013 · 24 comments

Comments

@Milofax
Copy link

Milofax commented Feb 19, 2013

I try to create internal links in mediawiki that should point in the end to another wiki page. Therefore, I have different md-files that represent a wiki page each.
For wiki, I convert each md-file separately to mediawiki. I also use the pdf conversion which works fine (and where I convert the content at once).
I would like to have the behaviour that internal links as [OtherWikiPage] would be converted to Mediak Wiki like [[OtherWikiPage]]. At the moment, pandoc doesn't interpret it at all.
Is that possible?

Mathias

@jgm
Copy link
Owner

jgm commented Feb 19, 2013

At some point I plan to add optional support for [[Wikilinks]] to
pandoc markdown. But for now, no.

+++ Milofax [Feb 19 13 03:49 ]:

I try to create internal links in mediawiki that should point in the
end to another wiki page. Therefore, I have different md-files that
represent a wiki page each.
For wiki, I convert each md-file separately to mediawiki. I also use
the pdf conversion which works fine (and where I convert the content at
once).
I would like to have the behaviour that internal links as
[OtherWikiPage] would be converted to Mediak Wiki like
[[OtherWikiPage]]. At the moment, pandoc doesn't interpret it at all.
Is that possible?

Mathias

--
Reply to this email directly or [1]view it on GitHub.
[xJAuenYDiIoVt3LF3y6844hiWKTFiVtiQp9ZcWRxBnbMtzeNpS3ZKm2pNYLaoeR7.gif]

References

  1. Internal Links in MediaWiki? (pandoc 1.10.1) #756

@jgm
Copy link
Owner

jgm commented Feb 19, 2013

Note: You can always define link references at the end of your
document for each of your pages:

[OtherWikiPage]: /url-to-page-in-wiki "wikilink"

+++ Milofax [Feb 19 13 03:49 ]:

I try to create internal links in mediawiki that should point in the
end to another wiki page. Therefore, I have different md-files that
represent a wiki page each.
For wiki, I convert each md-file separately to mediawiki. I also use
the pdf conversion which works fine (and where I convert the content at
once).
I would like to have the behaviour that internal links as
[OtherWikiPage] would be converted to Mediak Wiki like
[[OtherWikiPage]]. At the moment, pandoc doesn't interpret it at all.
Is that possible?

Mathias

--
Reply to this email directly or [1]view it on GitHub.
[xJAuenYDiIoVt3LF3y6844hiWKTFiVtiQp9ZcWRxBnbMtzeNpS3ZKm2pNYLaoeR7.gif]

References

  1. Internal Links in MediaWiki? (pandoc 1.10.1) #756

@Milofax
Copy link
Author

Milofax commented Feb 20, 2013

I also thought about that but I also want to have these links working when I create a pdf out of the same files. I did a temporary solution by writing a script that does all the work in finding the links that refer to external sources (=WikiPages) and the pdf conversion doesn't break.

@jgm
Copy link
Owner

jgm commented Feb 20, 2013

+++ Milofax [Feb 20 13 03:33 ]:

I also thought about that but I also want to have these links working
when I create a pdf out of the same files.

I'm not sure why it wouldn't work for PDF...? Reference links work
for PDFs too. Of course you'd want to use relative paths.

@Milofax
Copy link
Author

Milofax commented Mar 13, 2013

Because I want to use the same Link e.g. [Link] for both formats. In wiki conversion this link should become [[Link]], in pdf, this is still an internal link to a Heading in the document that was made by several md-files, each one representing a wiki page. I know, there's a lot of convention involved. Does that make sense?

@marcbowes
Copy link

With org to mediawiki:

[[Link]]

becomes

''Link''

Any idea how I can get this to be a relative link? I'm building from org to HTML and mediawiki, so I'm not keen on using absolute URLs.

@mpickering
Copy link
Collaborator

@marcbowes, for the uneducated what should the result be? [[Link]] is parsed as Emph in Org mode. One possible way would be to use span elements with a filter. If you need help with the approach post back here.

@marcbowes
Copy link

Definitely would appreciate help on rel links still.

The actual mediawiki syntax is [[Link Title]]. I would expect to be able to type something similar in org, possible [[Link][Title]].

It seems the org-mode parser only treats the link as a link if it looks like a URI/file etc: https://github.com/jgm/pandoc/blob/master/src/Text/Pandoc/Readers/Org.hs#L1145

@mpickering
Copy link
Collaborator

It looks like it's an arbitrary choice to turn unrecognised links into Emph? If so then it might be better to turn them into Span elements with a custom class - that would at least make our lives much easier.

@tarleb am I correct in thinking this?

@tarleb
Copy link
Collaborator

tarleb commented Dec 7, 2014

am I correct in thinking this?

Pretty much, yes. It's not completely arbitrary, in that it mirrors emacs' export behavior, but could very well be changed to something different.

Issue #1741 and jgm/gitit#471 are related to this. The resolving commit now allows empty urls, making it possible to define new wiki links like this: [[][Link]. It sounds like that is still insufficient for the use case at hand, so changing the reader might be the right thing to do.

@tarleb
Copy link
Collaborator

tarleb commented Dec 7, 2014

One additional note, though: Org-mode uses the [[Link][Title]] syntax to define links to internal headlines. More specifically, it starts a search for Link in all headlines. The reader doesn't support it yet, and neither does the Emacs exporter (hence the current behavior). The search will probably never work for Pandoc converted files, but converting the above to anchor links might be a decent replacement. That's why I'd argue that the [[Link][Title]] syntax isn't a good choice for wiki links. Maybe just use [[./Link][Title]] instead? Or define a custom link type with #+LINK: wiki ./ and write [[wiki:Link][Title]].

@marcbowes
Copy link

That comes out as [[./Link|Title]] for me on both .12 and .13.1.

@tarleb
Copy link
Collaborator

tarleb commented Dec 8, 2014

Yes, I was wrong the first time: [[file:Link][Title]] would be the correct way to put it. Unfortunately, the org reader doesn't recognize it yet. I'll try to provide a fix later this week. After that, the afore mentioned link alias should look like this: #+LINK: wiki file:%s.

Thanks for pointing it out!

@marcbowes
Copy link

Would I have to add that to every page I author? How would this impact the HTML writer?

The entire list of my link use-cases (author in org, export to mw and html):

  1. I want to be able to link to a relative path,
  2. to a section in the page (anchor links)
  3. and to an absolute URL

@mpickering
Copy link
Collaborator

Due to my inexperience with org I'm struggling to conceptualise example how Albert's suggestion would work. My original idea was to write a filter to intercept links and rewrite then based on the output format.

@marcbowes
Copy link

Correction:

The wiki syntax for a subpage relative to the current page is [[/Subpage]], which looks like a link relative to the server root for HTML, but is actually relative to the current path in mediawiki.

@tarleb
Copy link
Collaborator

tarleb commented Dec 8, 2014

Not sure if I misunderstood something, but here is what it got:

  1. Linking to a relative path: This should be fixed by the end of the week. I consider defining wiki: as an alias for file:, so [[wiki:link][title]] would work without any extra definitions.
  2. Anchor links work when defined manually (<<anchor>> and [[#anchor][anchor link]]). Automatically generated ids for headers are still on my todo.
  3. Absolute URLs should work as expected. Not sure about subpage links.

@marcbowes
Copy link

Why do you propose wiki: in the link? I'm happy to decorate something there to make it work, but it should export correctly for HTML too, so something that is tied to a specific format seems strange. What about rel:?

Is there a way I can write some (non-Haskell) tests for this? e.g. something like an examples directory where I can put example input and expected (or proposed) output?

EDIT: doh, looks like the tests folder does that.

tarleb added a commit to tarleb/pandoc that referenced this issue Dec 14, 2014
Org links like `[[file:target][title]]` were not handled correctly,
parsing the link target verbatim.  The org reader is changed such that
the leading `file:` is dropped from the link target.

This is related to issues jgm#756 and jgm#1812.
@tarleb
Copy link
Collaborator

tarleb commented Dec 15, 2014

A fix has been pushed, ensuring the [[file:link][title]] syntax is handled correctly. Wiki links should pose less of a problem now. If you have other link related issues, please add a comment to #1812.

@marcbowes
Copy link

Thanks. Is there going to be a release to hackage any time soon or should I pursue building this myself?

@tarleb
Copy link
Collaborator

tarleb commented Dec 15, 2014

AFAIK the next release will include some bigger changes which might take a while to get right – my guess is 2–6 weeks. @mpickering might be able to give you a better estimate.

@jgm
Copy link
Owner

jgm commented Dec 26, 2014

We've had a release. @tarleb, can this issue be closed now, or are there still things that need fixing?

@tarleb
Copy link
Collaborator

tarleb commented Dec 26, 2014

This can be closed. There is #1812 in case my fix was insufficient.

@jgm jgm closed this as completed Dec 27, 2014
@marcbowes
Copy link

With this change the following happens (the / is dropped):

[[file:/RelativePath][RelativePath]]

becomes

[[RelativePath|RelativePath]]

In mediawiki, this means a link relative to the site root, not relative to the current page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants