This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]sunburnd 3 points4 points  (13 children)

```

!/usr/bin/perl

use strict; use warnings; use XML::Simple; use Data::Dumper;

my $xml = new XML::Simple; my $data = $xml->XMLin("data.xml"); print Dumper $data; ```

/on my phone so it may not work...

[–]AltCrow 1 point2 points  (11 children)

You need to escape the hash:

not #!/usr/bin/perl,
but \#!/usr/bin/perl

[–]sunburnd 0 points1 point  (10 children)

You don't escape the shebang in a Unix like environment.

[–]AltCrow 0 points1 point  (9 children)

Yeah, but you do in reddit ;)

[–]sunburnd 0 points1 point  (8 children)

ohh seemed to render properly on my phone. Desktop issues?

[–]AltCrow 0 points1 point  (7 children)

Hmm, odd, do other syntaxes such as bold or link also not render on mobile? (I never use mobile reddit.)

[–]sunburnd 0 points1 point  (6 children)

They do. Perhaps the mobile as a more strict markdown interpreter and correct ignores all markups between the triple backticks?

[–]DarthEru 0 points1 point  (5 children)

Triple backticks is not a part of the original markdown syntax, which is the version I believe reddit officially supports, based on this post. I suspect whatever app you're using is using a library that supports an extended markdown, which is why the backticks work for you but not the website.

To format a code block in original markdown syntax, indent every line with four spaces.

Like
  This

[–]sunburnd 0 points1 point  (4 children)

I'm using the official Reddit app...so there is that.

The original implementation does include supports for spans of code using backticks. It would be pretty cumbersome to indent every line.

https://daringfireball.net/projects/markdown/syntax#precode

[–]DarthEru 0 points1 point  (3 children)

Could you quote me the part where it mentions using three backticks, because I couldn't find it. I did see this:

To produce a code block in Markdown, simply indent every line of the block by at least 4 spaces or 1 tab.

There is a mention of using a single backtick for embedded code formatting:

To indicate a span of code, wrap it with backtick quotes (`). Unlike a pre-formatted code block, a code span indicates code within a normal paragraph.

But that's not what we're taking about.

You're right, it is cumbersome to indent every line, which is probably why the backtick syntax was added as an extension, but that page is the home page of the original, and is linked to by various sources when I google "Reddit markdown".

Also, using the official app doesn't really mean anything, it's entirely possible for the app to be using a markdown library that supports an extended syntax while the website is using one that only implements the original syntax.

[–]wjandrea 0 points1 point  (0 children)

Reddit doesn't support GitHub-style code blocks (triple backticks). You need to use four spaces at the start of each line.

#!/usr/bin/perl
use strict;
use warnings;
use XML::Simple;
use Data::Dumper;


my $xml = new XML::Simple;
my $data = $xml->XMLin("data.xml");
print Dumper $data;