retupmoca / p6-markdown Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
Renderer that only allows a (configurable?) "safe" subset of HTML tags (to prevent XSS injections, etc)
This is part of #37
I'm unfamiliar with what plain Markdown is meant to handle, but applying styling to links (e.g. bold or code styles) works on GitHub, yet ends up verbatim, unrendered with Text::Markdown:
$ perl6 -MText::Markdown -e 'Text::Markdown.new("[`foo` *bar* **ber** ***meow***](blarg)").render.say'
<p><a href="blarg">`foo` *bar* **ber** ***meow***</a></p>
$ perl6 -v
This is Rakudo version 2017.10-3-gf40babb built on MoarVM version 2017.10
implementing Perl 6.c.
It's related to this
Given the following piece of Markdown
<h1>Hello</h1>
the HTML output should be literally the same, but at the moment, the HTML tags are converted to inline links, i.e. the HTML output is the following:
<a href="h1">h1</a>Hello<a href="/h1">/h1</a>
As far as I am aware of, inline links are supposed to be used if and only if
I hope that I'll be able to provide a patch for this issue.
Tables like this one:
| Works |
| ----- |
| True |
Inline code (``
) within headers (#
, ##
, etc.) and links ([]()
) doesn't seem to be rendered:
use Text::Markdown;
say Text::Markdown.new('# The `sub` keyword').render;
# Output: <h1>The `sub` keyword</h1>
# Expected: <h1>The <code>sub</code> keyword</h1>
say Text::Markdown.new('The [`sub`](#) keyword').render;
# Output: <p>The <a href="#">`sub`</a> keyword</p>
# Expected: <p>The <a href="#"><code>sub</code></a> keyword</p>
I seam to be having problems with producing an list: currently I have tied the following:
* Item 1
* Item 2
The code Im using:
use Text::Markdown;
multi sub MAIN ( $mdFile ) {
my $md = parse-markdown-from-file($mdFile);
say $md.render;
}
Which doesn't convert into html. Is there something I'm missing?
Thank you for your prompt reply.
-Michael
The following code hangs:
use Text::Markdown;
say parse-markdown(q:to/END/);
* a list item
END
After running excellent @atroxaper's RaCoCo, this is the result
Things like
`MY_GOOD_THING`
should be rendered as
MY_GOOD_THING
, but instead it goes with italic and '`' work as wrappers.
If I do:
* Foo
* Bar
* Baz
Then it doesn't render them as nested bullet points, but instead as a bunch of * on the same line as the first bullet point.
I facts, it hangs up...
Is there any interest in shipping a wrapper script that would generate HTML given a markdown file? If so, I can see about putting a PR together.
The following features are used a lot on Github to indicate code blocks, but they are not recognized by this module:
some code
some more code
We are using Text::Markdown to convert the README.md from GitHub to show on our web site.
It has some issues. http://bailador.net/documentation It would be nice if it could be fixed...
So that it's easy to extract any kind of element and navigate through it.
Such as this one
[`grep`](https://docs.perl6.org/routine/grep) is
one of them
For instance, try this
use v6;
use Text::Markdown::Document;
use Test;
plan 3;
my $text = q:to/TEXT/;
this character belongs to this
[category](https://en.wikipedia.org/wiki/Unicode_character_property#General_Category),
TEXT
my $document = Text::Markdown::Document.new($text);
ok $document ~~ Text::Markdown::Document, 'Able to parse';
is $document.items.elems, 2, 'has correct number of items';
my $p = $document.items[0];
ok $p ~~ Text::Markdown::Paragraph, 'It is a Paragraph';
dd $p.items;
It returns
1..3
ok 1 - Able to parse
ok 2 - has correct number of items
ok 3 - It is a Paragraph
Array @!items = ["this character belongs to this [category](https://en.wikipedia.org/wiki/Unicode", Text::Markdown::Emphasis.new(text => "character", level => 1), "property#General_Category),"]
It's splitting at the _
level, instead of extracting the link correctly.
this needs to become a <code><pre></pre></code>
Add missing features
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.