-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
MediaWiki preformatted text as GitHub Flavour Markdown #1993
Comments
Representing mediawiki syntax with pandoc AST or markdown syntax looks tricky to me. An interesting thing that I noticed, that the
I haven't yet figured out why is that. |
I'd noticed that too - and assumed it was a quirk with the GitHub comment rendering versus their rendering when viewing a markdown file, or on GitHub pages via Jekyll. Strange isn't it? |
Yep, it's strange. In fact most markdown implementations do not render this newlines. see But the linebreak can be forced by inserting the spaces at the end of the line. Spaces also work for GFM, see . Would it help you (seems better than I am just trying to understand if it is an issue with pandoc's GFM writer. If it is, then appending spaces is one possible solution that can fix the writer. |
Trailing spaces does seem more elegant than If you can get this to look good in multiple markdown flavours, that's great. I've only focussed on the GFM output and display (but long term hope to just use CommonMark instead). |
Hmm. Here is an interesting thing I found github/markup#208 (comment) Basically it says that GFM is only used in comments, PRs and other things like that. |
Here is a better link https://help.github.com/articles/github-flavored-markdown/
|
More accurately, I think, there are two kinds of github-flavored markdown. +++ Konstantin Zudov [Mar 05 15 08:34 ]:
|
So this explains a lot. Pandoc generated GFM, renders correctly when you past it into a comment. If you want to generate the file which would be viewed as a plain markdown file you shouldn't use GFM. |
@jgm Indeed, for example README's support the tables, fenced blocks, etc. This line confused me a little:
I guess they just call markdown used in README's "standard" |
You can always use So, can this issue be closed? |
I will try using I want to turn MediaWiki markup into whatever GFM GitHub is using to show I'm not wanting to use GFM as shown in GitHub issues comments (if this is subtly different). |
As I said, that is tricky because MediaWiki isn't really compatible with markdown and it becomes even harder to make it alike when you can't control the stylesheet of the rendered html. |
Trying @jgm's suggestion,
Output recorded here in order to show the GitHub rendering: https://github.com/peterjc/peterjc.github.io/blob/preformatting/preformatted_gh_hlb.md The key difference is two trailing spaces on the lines in the problematic block, exactly the suggestion from @zudov This appears to solve my problem, closing issue. Thank you everyone for your input. |
This solve problems displaying MediaWiki's preformatted blocks (sometimes used for code or terminal snippets). See also jgm/pandoc#1993
I've found a problem with what MediaWiki terms "Preformatted text" where each line starts with a space http://www.mediawiki.org/wiki/Help:Formatting once converted to GitHub Flavour Markdown (GFM) and viewed on GitHub.com or with GitHub Pages / Jekyll (on github.io).
This test case is using the example from http://www.mediawiki.org/wiki/Help:Formatting saved as
preformatted.mediawiki
I converted it to GitHub Flavour Markdown using pandoc version 1.13.1,
For now, you can view these files here:
In MediaWiki we get a three line paragraph in a box.
In GFM we get three boxes all on the same line.
Note that how line breaks are handled is one of the differences in GFM to plain markdown.
It is unclear to me how best to map MediaWiki performatted block to GitHub Flavoured Markdown (GFM). My interpretation of the role of these blocks is a way to pre-set the line breaks, while still using formatting (italics etc). Presumably it was intended for poetry etc but our wiki instance renders it in a box, and so it has also been used for code/terminal output snippets.
Adding explicit
<br />
tags works quite well, but does not give any block-level visual styling (which MediaWiki did give us -- and may be the author's purpose in picking this markup, but may not reflect the original meaning of the performatted block):Leaving blank lines in the raw markdown results in vertically separated lines, not great:
Using a GFM literal block fails to render any markup like italics etc, so that won't do in general (but would work on the specific wiki pages where I noticed this problem, since it was being used for terminal output snippets etc):
The best idea I've had so far (for general usage) is to combine a block quote with manual line breaks:
The text was updated successfully, but these errors were encountered: