Git Product home page Git Product logo

pagedown's Introduction

pagedown

Automatically exported from code.google.com/p/pagedown

Introduction

PageDown is the JavaScript Markdown previewer used on Stack Overflow and the rest of the Stack Exchange network. It includes a Markdown-to-HTML converter and an in-page Markdown editor with live preview.

While on the Stack Exchange sites PageDown is exclusively used on the client site (on the server side, MarkdownSharp is our friend), PageDown's converter also works in a server environment. So if your Node.JS application lets users enter Markdown, you can also use PageDown to convert it to HTML on the server side.

The largest part is based on work by John Fraser, a.k.a. Attacklab. He created the converter under the name Showdown and the editor under the name WMD. See this post on the Stack Exchange blog for some historical information.

Over the years, we (the Stack Exchange team and others) have made quite a few changes, bug fixes etc., which is why we decided to publish the whole thing under a new name. This is not to mean we want to deprive John Fraser of any credits; he deserves lots. And you'll still be finding the letters "wmd" in a few places.

It should be noted that Markdown is not safe as far as user-entered input goes. Pretty much anything is valid in Markdown, in particular something like <script>doEvil();</script>. This PageDown repository includes the two plugins that Stack Exchange uses to sanitize the user's input; see the description of Markdown.Sanitizer.js below.

In the demo/ folder, it also include usage examples. To see the editor at work, open demos/browsers/demo.html in your browser. To see the server side version at work, go to the demos/node folder and run node demo.js, then navigate your browser to http://localhost:8000.

node.js and npm

The easiest way to get the Markdown converter working in node.js is by getting it through npm.

$ npm install pagedown
[    $ node
> var pagedown = require("pagedown");
> var converter = new pagedown.Converter();
> var safeConverter = pagedown.getSanitizingConverter();
> converter.makeHtml("*hello*")
'<p><em>hello</em></p>'
> safeConverter.makeHtml("Hello <script>doEvil();</script>")
>'<p>Hello doEvil();</p>'

If you don't want to use npm, then follow the instructions below.

The three main files

Markdown.Converter.js

In the browser

Used in a regular browser environment, it provides a top-level object called Markdown with two properties:

Markdown.Converter is a constructor that creates a converter object. Call this object's makeHtml method to turn Markdown into HTML:

var converter = new Markdown.Converter();

document.write(converter.makeHtml("**I am bold!**"));

The constructor optionally takes an OPTIONS object as an argument.

The only currently recognized option is OPTIONS.nonAsciiLetters. If this is truthy, the converter will work around JavaScript's lack of unicode support in regular expressions when handling bold and italic. For example, since intra-word emphasis is prevented, the asterisks in w *or *d will not cause bolding. However without the workaround, the same is not true if the letters are outside the ASCII range: ? *??´? *? will cause the middle part of the word to be bolded.

If the workaround is enabled, latin and cyrillic will behave identically here.

Markdown.HookCollection is a constructor that creates a very simple plugin hook collection. You can usually ignore it; it's exported because the Markdown Editor (see below) uses it as well.

On the server

If you're using it in a CommonJS environment (we'll just assume Node.JS from now on), those two properties are the module's exports.

var Converter = require("./Markdown.Converter").Converter;
var converter = new Converter();

console.log(converter.makeHtml("**I am bold!**"));

Markdown.Sanitizer.js

In the browser

In a browser environment, this file has to be included after including Markdown.Converter.js. It adds a function named getSanitizingConverter to the Markdown object (created in the previous file).

This function returns a converter object that has two plugins registered on the postConversion plugin hook. One of them sanitizes the output HTML to only include a list of whitelisted HTML tags. The other one attempts to balance opening/closing tags to prevent leaking formating if the HTML is displayed in the browser.

var converter = getSanitizingConverter();
document.write(converter.makeHtml("<script>alert(42);</script><b>bold"); // creates "alert(42);bold"
On the server

Same thing, except that getSanitizingConverter is exported, and you don't need to load Markdown.Converter.js.

var converter = require("./Markdown.Sanitizer").getSanitizingConverter();
console.log(converter.makeHtml("<script>alert(42);</script><b>bold"); // creates "alert(42);bold"

Markdown.Editor.js

This file is only made for usage in the browser (obviously running it on the server neither makes sense nor works).

It has to be included after Markdown.Converter.js, as it requires the top-level Markdown object and its HookCollection property. If you're not using the provided Markdown converter, you'll have to change this file to include these two things.

The file adds the property Markdown.Editor, which is a constructor taking up to three arguments:

  • The first argument is required, and is the Markdown converter object (as created above) used for the editor's preview.

  • The second argument is optional, and is usually only necessary if you're using several editors within the same page. If given, this argument is a string, appended to the HTML element ids of the three elements used by the editor. By default, the editor looks for #wmd-button-bar, #wmd-input, and #wmd-preview. If you're using more than one editor, you of course can't give the second group of elements the same ids as the first, so you may create the second input box as <textarea id="wmd-input-2"> and pass the string "-2" as the second argument to the constructor.

  • The third argument is optional as well, and if given, is an object containing information about the "Help" button offered to the user. The object needs a handler property, which will be the onclick handler of the help button. It can also have a title property, which is then set as the tooltip (i.e. title attribute) of the help button. If not given, the title defaults to "Markdown Editing Help".

If the third argument isn't passed, no help button will be created.

The created editor object has (up to) three methods:

  • editor.getConverter() returns the converter object that was passed to the constructor.
  • editor.run() starts running the editor; you should call this after you've added your plugins to the editor (if any).
  • editor.refreshPreview() forces the editor to re-render the preview according to the contents of the input, e.g. after you have programmatically changed the input box content. This method is only available after editor.run() has been called.

To start using it, you'll probably want to look at the example in the demos/browser folder; it also includes some boilerplate CSS for you to start working with.

Plugin hooks =

Both the converter and the editor objects have a property called hooks, which is a collection of plugin hooks. The functionality is of the category "simplest thing that works", so don't expect too much magic. The two (important) methods on this object are:

  • hooks.set(hookname, func) registers the given function as a plugin on the given hook. Any previously registered plugins on the same hook are lost.
  • hooks.chain(hookname, func) registers the given function as the next plugin on the given hook; e.g. the second registered function will be called with the output of the first registered function as its only argument. This does not make sense on all plugin hooks.

Following is a list of the available plugin hooks.

Hooks on the converter object

preConversion

Called with the Markdown source as given to the converter's makeHtml object, should return the actual to-be-converted source. Fine to chain.

converter.hooks.chain("preConversion", function (text) {
    return "# Converted text follows\n\n" + text; // creates a level 1 heading
});

postConversion

Called with the HTML that was created from the Markdown source. The return value of this hook is the actual output that will then be returned from makeHtml. This is where getSanitizingConverter (see above) registers the tag sanitzer and balancer. Fine to chain.

converter.hooks.chain("postConversion", function (text) {
    return text + "<br>\n**This is not bold, because it was added after the conversion**";
});

plainLinkText

When the original Markdown contains a bare URL, it will by default be converted to a link whose link text is the URL itself. If you want a different link text, you can register a function on the hook that receives the URL as its only argument, and returns the text to be displayed. This will not change the actual URL (i.e. target of the link).

Note that the returned string will be inserted verbatim, not HTML-encoded in any way.

Okay to chain, although this may or may not make sense (after all you're receiving a URL and returning just about anything).

converter.hooks.chain("plainLinkText", function (url) {
    if (/^http:\/\/\w+\.stackexchange.com/i.test(url))
        return "<b>A link to an awesome site!</b>";
    else
        return "some page on the internet";
});

Notice on the following hooks

The following converter plugin hooks should be considered advanced. In order to use them, it makes sense to have a certain understanding how PageDown (or similar Markdown implementations that are based on the original Perl version) works internally. They are much more powerful than the previous ones, but it's also easier to break things with them. Documentation here is kept to a minimum; you should inspect the code around the hooks.

postNormalization

Called with the Markdown source after normalization. This includes things like converting all line endings to \n, replacing tabs with spaces, and turning whitespace-only lines into empty lines. But it also includes replacing certain characters with placeholders for internal reasons, so be sure to have a look at the actual code. This hook is fine to chain.

preBlockGamut and postBlockGamut

The above warning about understandind the inner workings of PageDown goes doubly with these two hooks. They are the most powerful ones.

Called with the text before or after creating block elements like code blocks and lists. Fine to chain. Note that this is called recursively with inner content, e.g. it's called with the full text, and then only with the content of a blockquote. The inner call will receive outdented text

If you are creating a new kind of block-level structure that can include other Markdown blocks (say, you're reimplementing block quote), you will need to run the full block gamut again on the contents of your block. For this purpose, these two plugin hooks receive a second argument, which is a function that will do just that. Be aware that from within that function, your plugin will of course be called again, so make sure you're not creating ambiguity that leads to infinite recursion.

As a contrived and simplified expample, let's say you're inventing fenced blockquotes, where blocks that are surrounded by lines with three quote characters in them are turned into block quotes. Such a thing could look like this:

converter.hooks.chain("preBlockGamut", function (text, runBlockGamut) {
    return text.replace(/^ {0,3}""" *\n((?:.*?\n)+?) {0,3}""" *$/gm, function (whole, inner) {
        return "<blockquote>" + runBlockGamut(inner) + "</blockquote>\n";
    });
});

The first editor in the http://pagedown.googlecode.com/hg/demo/browser/demo.html demo page implements this.

preSpanGamut and postSpanGamut

Called with the text of a single block element before or after the span-level conversions (like bold, code spans, etc.) have been made on it. For example, you would use this if you wanted to have text between !!double exclamation points!! appear in red.

Hooks on the editor object

Remember to add all your necessary plugins before you call the editor's run() method.

onPreviewRefresh

Called with no arguments after the editor's preview has been updated. No return value is expected. Fine to chain, if you want to be notified of a refresh in several places.

editor.hooks.chain("onPreviewRefresh", function () {
    console.log("the preview has been updated");
});

postBlockquoteCreation

Called after the user has clicked the "Blockquote" button (or pressed Ctrl-Q) and the user's selection has been changed accordingly. This function is passed the content that would be inserted in place of the original selection, and should return the actual to-be-inserted content.

The name isn't 100% correct, as this hook is also called if a blockquote is removed using this button. Fine to chain (but probably unlikely to be used anyway).

editor.hooks.chain("postBlockquoteCreation", function (text) {
    if (!/^>/.test(text))
        return text; // the blockquote button was clicked to remove a blockquote -- no change

    return text + "\n\nThe above blockquote is brought to you by PunyonDew(tm)\n\n"
});

insertImageDialog

When the user clicks the "add image" button, they usually get a little dialog to enter the URL of an image. If you want a different behavior (like, in the case of Stack Exchange, a dialog to upload an image), register a plugin on this hook that returns true (this tells the editor not to create its own dialog and instead wait for you). The function is called with a single argument, which is a callback that you should call with the URL of the to-be-inserted image, or null if the user cancelled.

It does not make sense to chain functions on this hook.

editor.hooks.set("insertImageDialog", function (callback) {
    alert("Please click okay to start scanning your brain...");
    setTimeout(function () {
        var prompt = "We have detected that you like cats. Do you want to insert an image of a cat?";
        if (confirm(prompt))
            callback("http://icanhascheezburger.files.wordpress.com/2007/06/schrodingers-lolcat1.jpg")
        else
            callback(null);
    }, 2000);
    return true; // tell the editor that we'll take care of getting the image url
});

Note that you cannot call the callback directly from the hook; you have to wait for the current scope to be exited. If for any reason you want to return a link immediately, you'll have to use a 0ms timeout:

editor.hooks.set("insertImageDialog", function (callback) {
    setTimeout(function () { callback("http://example.com/image.jpg"); }, 0);
    return true;
});

pagedown's People

Contributors

krtek4 avatar vejobuj avatar

Stargazers

Sergey avatar

Watchers

James Cloos avatar

pagedown's Issues

unbinding the editor

I use the editor within a 'modal' dialog within the page (using colorbox). When 
someone closes the dialog, I'd like to be able to cleanup after the editor has 
been shown so that if they re-open the dialog, everything is fresh again. 

This means unbinding any events and removing elements like the wmd-button-bar. 
Would it be possible to add a editor.close() function?

Original issue reported on code.google.com by [email protected] on 20 Dec 2011 at 12:33

Add method to only make links

It would be great if the Markdown.Converter had a method which only created 
links. I'm dealing with feed posts and I don't want the user to be able to 
create headers and all that jazz.

Original issue reported on code.google.com by [email protected] on 2 Feb 2012 at 9:19

Make #wmd-button-bar non-required

I use pagedown also in comment-form it has well keyboard shortcuts support, 
it's very useful to format small code snippets against typing 4 spaces every 
single line. But I have to put button bar on dom also. Of course I can hide it 
with css but that's not on true-way.

There are some other issues I want to post if you don't mind. Actually for now 
there is no any other editor to be used with markdown except markitup — which 
as to me very is very weird and do everything but nothing well.

Original issue reported on code.google.com by [email protected] on 11 Feb 2012 at 4:59

Creating bulleted list after numbered converts the first one to bulleted

Type this:
--------
Example:

 1. Number One
 2. Then Number Two


--------

on last second blank line press Ctr+U and you'll get this:
--------
Example:

 - Number One
 - Then Number Two
 - List item
--------

Chrome 17, Ubuntu
UPD: pressing Ctrl+U converts every list before to bulleted, and Ctrl+O 
converts them all to numbered

Original issue reported on code.google.com by [email protected] on 10 Feb 2012 at 6:39

Error in documentation, there is a bracket missing

Fairly simple.
Looking at the in-browser example for the Markdown.Sanitizer.js...

document.write(converter.makeHtml("<script>alert(42);</script><b>bold"); // 
creates "alert(42);bold"

you can find that there is only one closing bracket before the ;




Original issue reported on code.google.com by [email protected] on 25 Sep 2012 at 8:09

Support asynchronous module definition

Supporting asynchronous module definition [1] would allow to use 
CommonJS-compliant asynchronous javascript loaders like requirejs [2] on the 
client side.

This also allows to declare dependencies between modules, and to ensure that 
some module is loaded before an other.

This would look like this for Markdown.Converter:

``` Javascript
define(function() {
    // return Converter here
});

And for Markdown.Editor:

define(['Markdown.Converter'], function(Converter) {
    // return Editor here
});

And in the client code:

require(['Markdown.Converter', 'Markdown.Editor'], function(Converter, Editor) {
     // ...
});

With non-CommonJs compat:

var Markdown;

function doExport(factory) {
    if (typeof 'define' === 'function' && typeof 'require' === 'function') {
        define.call(this, factory);
    } else {
        Markdown.Converter = factory();
    }
}
doExport(function() {
     // ... return Converter
});

[1] http://wiki.commonjs.org/wiki/Modules/AsynchronousDefinition
[2] http://requirejs.org/


Original issue reported on code.google.com by `arnaud.lb` on 4 Aug 2011 at 5:09

When referencing links with empty optional parameters, the converter fails

What steps will reproduce the problem?
1. write 
[14]:http://blog.thecanadaline.com/wp-content/uploads/2012/03/IMG_62441-225x300.
jpg ()\n\n
2. try to convert
3.

What is the expected output? What do you see instead?
we are expecting to have the link correctly coded inside the page, instead we 
have a broken link and the unconverted string appears at the end of the page as 
text: 
[14]:http://blog.thecanadaline.com/wp-content/uploads/2012/03/IMG_62441-225x300.
jpg ()\n\n

We should be able to furnish empty parameters in brackets without breaking the 
behaviour of the app...

What version of the product are you using? On what operating system?


Please provide any additional information below.
Removing the empty braces fixes the markdown.

Original issue reported on code.google.com by [email protected] on 13 Sep 2012 at 11:32

An url is not transformed to link if it's after a previous url separated only by a sole enter character

What steps will reproduce the problem?
1. Go to demo http://pagedown.googlecode.com/hg/demo/browser/demo.html
2. Add this text to any of the textboxes:
"http://google.com
http://google.com
text between links
http://google.com
"

What is the expected output? What do you see instead?
Expected:
"http://google.com http://google.com text between links http://google.com"
And all three links are clickable(so transformed to links)

Instead:
The second http://google.com is not transformed to a link.


What version of the product are you using? On what operating system?
Current live web demo.

Please provide any additional information below.

Original issue reported on code.google.com by [email protected] on 23 Jan 2013 at 4:50

mailto: no correctly rendered

What steps will reproduce the problem?
1. create some markdown with a link to send an email like 
[mail]([email protected])
2. call the converter on the string
string = '[mail](mailto:[email protected])'
converter.makeHtml(string);
3.

What is the expected output? What do you see instead?
The output should be 
<a href="mailto:[email protected]">mail</a>

instead we have
<a href="{absoluteURL}mailto%[email protected]">mail</a>

What version of the product are you using? On what operating system?


Please provide any additional information below.

This has been fixed by tweaking one of the attackLab functions (below), to 
avoid encoding the ":" when preceeded by "mailto".

function encodeProblemUrlChars(url) {
   if (!url)
     return "";
//if we have an "email:" type of link then do not encode the ":"
   else if (/mailto:/.test(url))
     return url;
   else {
     var len = url.length;
     return url.replace(_problemUrlChars, function (match, offset) {
    if (match == "~D") // escape for dollar
          return "%24";
    if (match == ":") { 
      if (offset == len - 1 || /[0-9\/]/.test(url.charAt(offset + 1)))
        return ":"
    } 
    return "%" + match.charCodeAt(0).toString(16);
     });
  }
}

Original issue reported on code.google.com by [email protected] on 17 Nov 2012 at 1:30

Attachments:

Support for Markdown Extra

PHP Markdown Extra (http://michelf.com/projects/php-markdown/extra/) is a great 
extension to markdown which supports table, definition list, header id and 
abbreviation, tables and definition lists are especially usefull when writing 
blogs and other types of documents, so it would be nice to support it.

Original issue reported on code.google.com by [email protected] on 22 Feb 2012 at 7:05

Markdown.Sanitizer.js should not use global window variable

We are trying to use Markdown.Sanitizer.js in Acre (a server-side javascript 
environement).

However, we find ourselves hacking a window object to use Markdown.Sanitizer.js.

But if Markdown.Sanitizer.js passes "this" as the "window" variable, we can use 
Markdown.Sanitizer.js on the server-side as is:

(function(window) {

...

})(this);


Original issue reported on code.google.com by [email protected] on 24 Sep 2012 at 2:59

Please pull handleUndo changes

Hi,

I implemented a shared settings object which allows you to tweak the editor at 
creation time without editing the code.

I also added a handleUndo switch which allows you to turn off the undo 
functionality which I needed for my project with shareJS.

The change is at 
http://code.google.com/r/woutmertens-noundo/source/detail?r=52c43623e71b1c912d68
4bd4b513c9fe1cc23c09

Original issue reported on code.google.com by [email protected] on 5 Jan 2012 at 3:56

Atx-style headers missing

What steps will reproduce the problem?
1. Enter three times the hash sign #
2. the output is no h3-tag


What is the expected output? What do you see instead?
Three # should generate a h3 heading (<h3> my headline </h3>
According to http://daringfireball.net/projects/markdown/syntax#header markdown 
should support html headers h1 down to h6 be entering n times the # sign.

What version of the product are you using? On what operating system?
The current version (july 2012).

Please provide any additional information below.
Take a look at the markdown page at daringfireball.net

Original issue reported on code.google.com by [email protected] on 22 Aug 2012 at 8:40

  • Merged into: #29

Treat `&colon;` as `:` in URLs

Fixes an XSS vulnerability reported by Mario Heiderich 
(http://twitter.com/0x6d6172696f).

This change ensures that…

   new Markdown.Converter().makeHtml('**_[Free iPad Here!](javascript&colon;alert(1))_**')

…has the same result as…

   new Markdown.Converter().makeHtml('**_[Free iPad Here!](javascript:alert(1))_**')

Original issue reported on code.google.com by [email protected] on 9 Aug 2012 at 12:18

Attachments:

Getting Uncaught SyntaxError on list creation

> Markdown.Editor.js:327
> Uncaught SyntaxError: Invalid flags supplied to RegExp constructor 'sfsdf 
sdfs dfsdf sdf sf'

How i got it: 
- type a list of words and create a new blank line at last
- select every line (except the blank one). The last non-blank one should be 
hilighted to the end of line — not end of last word in line.
- press Numbered or Bulleted list via shortcut or toolbar button

Since my English is not as well as I want so, attaching a screenshot :)

Original issue reported on code.google.com by [email protected] on 9 Feb 2012 at 7:56

Attachments:

Sanitizer fails to find Markdown in certain requirejs environments

When building a bundle using some requireje-based tools each file is loaded in 
a separate closure, with the result that Markdown.Convertor creates a Markdown 
in a different scope than window and Markdown.Sanitizer then fails to find it. 
This can be fixed by modifying the converter to explicitly create 
window.Markdown as well:

diff --git a/src/3rdparty/pagedown/Markdown.Converter.js 
b/src/3rdparty/pagedown/Markdown.Converter.js
index 58fc54a..8c1a909 100755
--- a/src/3rdparty/pagedown/Markdown.Converter.js
+++ b/src/3rdparty/pagedown/Markdown.Converter.js
@@ -3,7 +3,7 @@ var Markdown;
 if (typeof exports === "object" && typeof require === "function") // we're in a CommonJS (e.g. Node.js) module
     Markdown = exports;
 else
-    Markdown = {};
+    Markdown = window.Markdown = {};

 // The following text is included for historical reasons, but should
 // be taken with a pinch of salt; it's not all true anymore.

Original issue reported on code.google.com by [email protected] on 4 Jan 2013 at 3:41

Links to open in new tab

Links could be improved to open in a new tab (it currently opens up in the same 
page).

Adding the target="_blank" attribute would fix it.

Original issue reported on code.google.com by [email protected] on 2 Feb 2012 at 3:48

Relative links don't work in the demo, parenthesis => %2a

What steps will reproduce the problem?
1. Go to demo http://pagedown.googlecode.com/hg/demo/browser/demo.html
2. Add this text to the unsanitized text box:
      "See my [About](about/) page for details."
    Example like: http://daringfireball.net/projects/markdown/syntax#link

What is the expected output? What do you see instead?
Expected the link to be to "about/", but it was to 
http://pagedown.googlecode.com/hg/demo/browser/%2aabout%2a/
Is my markdown syntax right? 

What version of the product are you using? On what operating system?

Current live web demo on current Chrome OSX.

Please provide any additional information below.

Original issue reported on code.google.com by [email protected] on 22 Dec 2012 at 9:09

underscore (_) conversion not working if not preceeded by a space

What steps will reproduce the problem?
1. having a sting like August,29th_to:_ August,30th
2. there is no space before the leading "_"
3.

What is the expected output? What do you see instead?
We expect to see the bolded "to:", we have _to:_ instead

What version of the product are you using? On what operating system?


Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 13 Sep 2012 at 11:25

Sanitizer needs a semicolon at the end

What steps will reproduce the problem?
1. use a tool like Chirpy to package all three Markdown.*.js files together: 
Converter, Sanitizer, and Editor.
2. include the javascript file in a page


What is the expected output? What do you see instead?

I'd expect the page to behave the same way as if I included the javascript 
files individually. Instead, it has a javascript error because Sanitizer ends 
with a function call that doesn't return anything, and Editor begins with a 
parenthesis, which makes the javascript think you're calling a function that 
got returned from the Sanitizer's initialization function.

You can fix this issue by adding a semicolon at the end of the Sanitizer.js 
file, as shown in the included Hg patch file.


Original issue reported on code.google.com by [email protected] on 1 Sep 2011 at 11:05

Attachments:

pull request for AutoNewLines port form MarkDownSharp

i cloned pagedown an ported the AutoNewLines option form MarkDownSharp to 
PageDown.

it could be usefull for other people as well, plz pull (and review) if you got 
the time.

http://code.google.com/r/marcdrexel-pagedown/

Original issue reported on code.google.com by [email protected] on 3 Aug 2012 at 11:38

UI buttons (bold, italic for example) use inaccessible code

Usage of WAI-ARIA and correct HTML would help ensure a slightly better 
experience.

For example using a <button> opposed to a <span> and using roles using as 
"application" and "menu" or "button" to the inserted mark-up shouldn't be that 
tricky to implement.

Am happy to hack around and provide more concrete examples if needed...


Original issue reported on code.google.com by [email protected] on 15 Nov 2011 at 9:42

Can't make a relative link

The syntax [link](test.txt) does not work.  Instead, I see "link" (the word), 
but it is not made into a link for me.

Original issue reported on code.google.com by [email protected] on 16 May 2012 at 1:13

Suggestion: live preview site, for bug reporting

If there was a live preview site for pagedown,
I could test out a bug on the current code.
Right now I can only report a bug against the current version in use somewhere, 
which might not be the current version.

Original issue reported on code.google.com by [email protected] on 27 Jan 2012 at 9:44

Need a prominent version number

In order to get this library updated on cdnjs, someone needs to submit a pull 
request which follows the rules at https://github.com/cdnjs/cdnjs  A very old 
version of this library is already on cdnjs as 1.0, but I can't find a proper 
version number for pagedown, so can't update that version number to the correct 
value when supplying the latest source.

Original issue reported on code.google.com by Forbes.Lindesay on 20 May 2012 at 10:23

XSS: fails to escape link text in [<svg/onload=alert(1)//]() correctly

> new Markdown.Converter().makeHtml('[<svg/onload=alert(1)//]()')
→ '<p><a href=""><svg/onload=alert(1)//</a></p>'

This displays an alert in Firefox (XSS). Demo: 
data:text/html;charset=utf-8,<p><a href=""><svg/onload=alert('XSS')//</a></p>

Expected output is:

→ '<p><a href="">&lt;svg/onload=alert(1)//</a></p>'

I.e. the `<` should always be escaped.

Original issue reported on code.google.com by [email protected] on 9 Aug 2012 at 1:39

An indented code block following a list, without an intervening paragraph, does not get formatted correctly

What steps will reproduce the problem?
1. Open /browser/demo.html
2. Input the following text into the editor:

This is a bug.

    here is a code block, properly monospaced

But if I start a list,

* even if it only has one item

    and then I try to make a code block, it doesn't work.

On the other hand, if I start another normal paragraph first,

    code blocks work again



What is the expected output? What do you see instead?

"    and then I try to make a code block, it doesn't work." should be displayed 
as a code block. Instead it is included as part of the list element.

What version of the product are you using? On what operating system?

changeset:   21:44a4db795617
tag:         tip
user:        balpha
date:        Fri Mar 02 14:55:03 2012 +0100

Original issue reported on code.google.com by [email protected] on 11 Apr 2012 at 3:22

IFrame support

Don't working from an IFrame.

Example usage - Facebook Canvas application.

Original issue reported on code.google.com by [email protected] on 26 Aug 2011 at 6:42

Double postprocessing when using image dialog hook

I get:

![![enter image description here][5]][5]

What steps will reproduce the problem?

1. made a page much like the demopage
2. initialized it like the following

<script type="text/javascript">
    function my_dialog(callback){
        alert ("hello");
        var retval = callback("http://xyz.png/x.png");
        return true
    }
    var converter1 = Markdown.getSanitizingConverter();
    var editor1 = new Markdown.Editor(converter1);
    editor1.hooks.set("insertImageDialog",my_dialog)
    editor1.run();
</script> 

3. pressed the image link

What is the expected output? What do you see instead?
![enter image description here][5]

What version of the product are you using? On what operating system?
N/A

Please provide any additional information below.

I can make it work if commenting out the 
                postProcessing();


inside the linkEnteredCallback function


Original issue reported on code.google.com by [email protected] on 7 Oct 2011 at 2:47

Patch for /Markdown.Editor.js

Adds an optional second argument to linkEnteredCallback, allowing alt text to 
be specified instead of using the default.

The bracket-escaping is moved to the bottom of the function so it is applied to 
the alt text.

Original issue reported on code.google.com by jeremybanks.ca on 8 Feb 2012 at 6:11

Attachments:

underscore (_) not recognized by the markdown converter

What steps will reproduce the problem?
1. Try to convert this a string like  _From: _July 30th, 2012 _to _August 5th, 
2012 

2. There are spaces after the string to be emphasized: _From: _
3.

What is the expected output? What do you see instead?
we would expect this:
<em>From: </em>July 30th, 2012 <em>to </em>August 5th, 2012
instead we have the input again:
_From: _July 30th, 2012 _to _August 5th, 2012 

What version of the product are you using? On what operating system?


Please provide any additional information below.

The space at the end seem to break the converter functionality

Original issue reported on code.google.com by [email protected] on 13 Sep 2012 at 11:22

npm module

How about publishing an npm module for nodejs usage? I could fork this project 
on github and publish an npm module myself, but it would be great if you 
consider adding one.

Thanks
Subbu

Original issue reported on code.google.com by [email protected] on 10 Aug 2011 at 4:13

Fix the numbered list creation algorithm

This issue was already filed at the old 'wmd-new' repo.

The issue is still valid. I'm copypasting this as I just run into the very same 
problem.

What steps will reproduce the problem?
1. Type a list with each step on its own line

one
two
three

2. Highlight list and click the numbered list button
3. Rage at the resulting list

  1. one two three

What is the expected output? What do you see instead?

I want this:

one
two
three

to look like this:

 1. one
 2. two
 3. three


What version of the product are you using? On what operating system?

unknown version in chrome/ie

Please provide any additional information below.

The type-list/highlight/format-list pattern is common and any normal editor 
allows you to do this without deformatting your list and placing multiple lines 
on a single line.  Stop doing this, please.

Original issue reported on code.google.com by [email protected] on 10 Apr 2012 at 8:38

JavaScript files missing the MIT license header

I noticed that the four JavaScript files don't have a license header. This 
seems to be a common practice amongst JavaScript libraries out there. Would it 
be possible to add the information to the files, perhaps similar to jQuery's 
text?

( https://github.com/jquery/jquery/blob/master/src/intro.js )

Original issue reported on code.google.com by [email protected] on 18 Sep 2012 at 5:06

Localization of the editor

Hi,

I'm in the process of developing a website in french and I was wondering if you 
already thought of the Localization of the different parts of the editor ?

I'm willing to do the job if we can agree on the architecture behind the 
changes.

Thanks for the great work !

Original issue reported on code.google.com by [email protected] on 17 Sep 2011 at 10:42

h4-h6 do not work

What steps will reproduce the problem?

Attempt to enter an h4, h5, or h6 like so:

#### Test
##### Test
###### Test

What is the expected output? What do you see instead?

Expect to convert to <h4>Test</h4> for example. Converts to unmarked-up text 
instead.


What version of the product are you using? On what operating system?

Using trunk code in Chrome 19, Mac OS X Snow Leopard


Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 20 Feb 2012 at 8:37

add footnote support

Footnotes are important!

When it comes to specs, I recommend conforming to what's becoming a sort of 
standard in markdown libraries:

http://freewisdom.org/projects/python-markdown/Footnotes
http://michelf.com/projects/php-markdown/extra/#footnotes

Original issue reported on code.google.com by [email protected] on 27 Sep 2011 at 7:37

Prompt background does not disappear after 2nd try

When clicking the image button, the wmd-prompt-background appears. If the image 
insert is canceled using callback(null); in JavaScript, then the background 
disappears. However, if the user clicks the image button again, the 
wmd-prompt-background will appear again, but whether callback(null); or 
callback("http://someurlhere.com/photo.jpg"); is used, the background will not 
disappear.

The JavaScript Console shows at this time "Uncaught TypeError: Cannot call 
method 'removeChild' of null" in Markdown.Editor.js line 1684. 

I have attached the trace that the browser's console provides. The browser 
version is Google Chrome 20.0.1132.57 m on Windows XP.

Original issue reported on code.google.com by [email protected] on 25 Jul 2012 at 11:06

Attachments:

Converter allows for headings up to h6, but sanitizer removes anything after h3.

What steps will reproduce the problem?
1. var converter = Markdown.getSanitizingConverter();
2. converter.makeHtml( '#h4-header')
3. the text 'h4-header' is returned.

What is the expected output? What do you see instead?
I expected '<h4>h4-header</h4>' to be returned

What version of the product are you using? On what operating system?
Latest version, OS X 10.7


Please provide any additional information below.

The issue is that on line 23 of Markdown-Sanitizer.js a whitelist is declared 
that only allows h tags up to h3.  However, line 747 of the 
Markdown-Converter.js allows h1-h6. Adding h4-h6 to the whitelist fixed the 
issues.

Original issue reported on code.google.com by [email protected] on 5 Jul 2012 at 4:52

  • Merged into: #29

Minor scoping issue in Markdown.Editor.js

The fakeButton variable used to handle the shift+enter indent is missing a var 
statement.

Patched at 
https://code.google.com/r/tmslft-pagedown/source/detail?r=785c6f8483248f084d0879
3da9e1cac5e2037ec8

Original issue reported on code.google.com by [email protected] on 8 Jan 2012 at 10:39

'$' not defined after submitting hyperlink

What steps will reproduce the problem?
1. I start the Browser Demo.html 
2. I click the Hyperlink icon
3. I insert 'http://example.com/ "optional title"' as shown in example

What is the expected output? What do you see instead?

Foutdetails webpagina

Gebruikersagent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; 
Trident/4.0; .NET CLR 1.1.4322; OfficeLiveConnector.1.4; OfficeLivePatch.1.3; 
.NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C)
Tijdstempel: Tue, 14 Aug 2012 21:41:20 UTC


Bericht: '$' is niet gedefinieerd
Regel: 1647
Teken: 17
Code: 0
URI: file:///C:/pl/pagedown/Markdown.Editor.js



What version of the product are you using? On what operating system?

IE8, pagedown Version 3151a581819f39123b0b5fd1ca9e26cebdcaa873

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 14 Aug 2012 at 9:53

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.