3

I've tried converting with pretty much all of them, mostly from a mediawiki excerpt, and none produced a perfect result. I've found strict markdown to be the closest, but it's still off; the links come out empty, and — would it be too much to ask? — the footnotes are not included and formatted.

For instance, this excerpt from Wikipedia:

enter image description here

… comes out as:

**Democracy** ( **, literally "rule by people"), in modern usage, has
three senses all for a system of government where the citizens exercise
power by [voting]. In a [direct democracy], the citizens as a whole form
a governing body, and vote directly on each issue, e.g. on the passage
of a particular tax law. In a [representative democracy] the citizens
elect representatives from among themselves. These representative meet
to form a governing body, such as a [legislature]. In a [constitutional
democracy] the powers of the majority are exercised within the framework
of a representative democracy, but the constitution limits the majority
and protects the minority, usually through the enjoyment by all of
certain individual rights, e.g. freedom of speech, or freedom of
association.[1][2] Democracy is sometimes referred to as "rule of the
majority".[3] Democracy is a system of processing conflicts in which
outcomes depend on what participants do, but no single force controls
what occurs and its outcomes.

[1] [Oxford English Dictionary][]: *Democracy*.

[2] 

[3] 

  [voting]: Vote "wikilink"
  [direct democracy]: direct_democracy "wikilink"
  [representative democracy]: representative_democracy "wikilink"
  [legislature]: legislature "wikilink"
  [constitutional democracy]: constitutional_democracy "wikilink"
  [Oxford English Dictionary]: Oxford_English_Dictionary "wikilink"

… rendering as:

Democracy ( **, literally "rule by people"), in modern usage, has three senses all for a system of government where the citizens exercise power by voting. In a direct democracy, the citizens as a whole form a governing body, and vote directly on each issue, e.g. on the passage of a particular tax law. In a representative democracy the citizens elect representatives from among themselves. These representative meet to form a governing body, such as a legislature. In a constitutional democracy the powers of the majority are exercised within the framework of a representative democracy, but the constitution limits the majority and protects the minority, usually through the enjoyment by all of certain individual rights, e.g. freedom of speech, or freedom of association.1[2] Democracy is sometimes referred to as "rule of the majority".[3] Democracy is a system of processing conflicts in which outcomes depend on what participants do, but no single force controls what occurs and its outcomes.

1[]: Democracy.

[2]

[3]

Ideally, I'd like it to yield that:

Democracy (Greek: δημοκρατία dēmokraa thetía, literally "rule by people"), in modern usage, has three senses all for a system of government where the citizens exercise power by voting. In a direct democracy, the citizens as a whole form a governing body, and vote directly on each issue, e.g. on the passage of a particular tax law. In a representative democracy the citizens elect representatives from among themselves. These representative meet to form a governing body, such as a legislature. In a constitutional democracy the powers of the majority are exercised within the framework of a representative democracy, but the constitution limits the majority and protects the minority, usually through the enjoyment by all of certain individual rights, e.g. freedom of speech, or freedom of association.1 2 Democracy is sometimes referred to as "rule of the majority".3 Democracy is a system of processing conflicts in which outcomes depend on what participants do, but no single force controls what occurs and its outcomes.

1. Oxford English Dictionary: Democracy.

2. Watkins, Frederick (1970). Encyclopædia Britannica (Hardcover). 7 (Expo '70 ed.). William Benton. pp. 215–223. ISBN 0-85229-135-3.

3. "Democracy – Definition of Democracy by Merriam-Webster".

And I haven't even broached the topic of math notation yet!

2 Answers 2

4

The links come out empty because pandoc is a syntax converter, and does not have Wikipedia's templates built in—those templates are not part of MediaWiki syntax.

Consider that the excerpt text starts with two templates: '''Democracy''' ({{lang-gr|δημοκρατία}} ''{{lang|grc|dēmokraa thetía}}'', literally "rule by people")

If we ignore the templates (because they're undefined anyway) that text effectively just looks like this:

'''Democracy''' ( '''', literally "rule by people")

and that gets converted to the following:

**Democracy** ( **, literally "rule by people")

... which is correct.

This also means it doesn't understand the citation templates further down in the excerpt. If we remove the templates, we instead get this conversion which generates markdown accurate enough to the best of its knowledge—which is correct, including that it interprets [[Vote|voting]] as a link to the url "Vote".

So if you want to convert MediaWiki text to Markdown, you'll need to put in a bit of work patching up the parts the pandoc converter doesn't know how to manage.

2
  • Thanks, @doppelgreener. Looks like that "bit of work" is mechanical enough to be automated into a filter, no? Commented Jul 5, 2018 at 9:16
  • @AndréLevy Handling lang and cite templates looks like a job for filters going by the filter documentation, yeah. Commented Jul 5, 2018 at 9:17
1

I'm afraid you're out of luck, since Stack Exchange use a custom markdown, forked from the strict if I'm not mistaken.

However, you can see the full source code here, as far as I can tell it's still what being used all around SE.

So with that source code you can probably build whatever it is you try to build.

1
  • Uphill battle for me, @ShadowWizard… Was hoping a… wizard might know their way around markdown and python to whip up a filter faster than I ever could 😁 Commented Jul 5, 2018 at 9:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .