First time here? Check out the FAQ!
2

link is displayed correctly in preview but not in actual post

JSON

is shown correctly in preview but not in actual post

(in current git repo)

ie

[JSON][1]

  [1]: http://en.wikipedia.org/wiki/JSON
pcompassion's avatar
21
pcompassion
asked 2013-07-02 06:58:06 -0600, updated 2013-07-03 09:09:31 -0600
edit flag offensive 0 remove flag close merge delete

Comments

1

To notify Evgeny:

Please take a look at my comments.

pcompassion's avatar pcompassion (2013-07-08 22:52:00 -0600) edit
1

Sure, I'll reply tomorrow (Chile time).

Evgeny's avatar Evgeny (2013-07-08 22:53:05 -0600) edit
add a comment see more comments

1 Answer

0

The issue is that we have two markdown converters - one in Python and one in Javascript for the previewer. Both are third party libraries. Maybe there is a way to reduce the difference between the two, but we have not looked at this in detail yet. An alternative is to port implementation of one converter in the other language to replicate the functionalities exactly.

The "raw link" vs clickable link: we have a feature that forces raw link if user's reputation is lower than certain threshold, so we would need to replicate this in the previewer or remove this feature (there is also a feature that will prevent posts with links outright if user has low reputation).

Regarding the two markdown converters I think that in order to fix this issue reliably we should replicate the python markdown converter in JS 1:1...

A little more technical detail:

The Markdown parser we use is from the markdown2 library and it is set up in askbot.utils.markup.get_parser() function.

In addition to using raw markdown2 we do some more things (see functions askbot.models.Post.parse_and_save and askbot.models.post.parse_post_text):

  • "linkify" the @mentions
  • depending on the user reputation either insert full external links or insert them as plain text or reject the post (an antispam feature - we could argue separately whether this is actually a good feature or not)

Javascript converter does one more thing: if Mathjax is enabled it re-runs mathjax upon re-rendering.

So in order to exactly replicate this in the previewer this all has to also be coded in Javascript.

Re: Javascript implementation - we've recently switched to pagedown which was written for StackOverflow. This is a more reliable converter, before we used "showdown.js", but it proved to have XSS issues. AFAIK pagedown is a rewrite of showdown.

It is possible that we can implement the missing features in the previewer by simply configuring the "pagedown" converter - it seems to allow configurable post-processing scripts.

Evgeny's avatar
13.2k
Evgeny
answered 2013-07-03 09:12:37 -0600, updated 2013-07-11 15:07:56 -0600
edit flag offensive 0 remove flag delete link

Comments

1

Since it's very critical to askbot(what's more important than posting a question and reading it as it is supposed), I hope it gets fixed soon. Unfortunately I'm new to markdown/editor/parser in general to fix it fast :(

pcompassion's avatar pcompassion (2013-07-03 19:24:51 -0600) edit
1

list (ordered and unordered) is displayed incorrectly as well..

pcompassion's avatar pcompassion (2013-07-03 21:01:57 -0600) edit

I'm facing the same problem. The link is fine in preview mode but after posting its showing the raw link. Any idea how to solve this? I had only 1 link in my answer and its not coming correctly.

Chankey Pathak's avatar Chankey Pathak (2013-07-04 07:26:23 -0600) edit
1

Evgeny: can you share the current plan for this bug fix? or layout the strategy so that I can work on it?

pcompassion's avatar pcompassion (2013-07-08 17:24:38 -0600) edit

@Evgeny I see they mention using node.js for server side. Is that an option for askbot?

pcompassion's avatar pcompassion (2013-07-08 19:10:32 -0600) edit

@pcompassion the problem with node.js is that it's one more component to install, will make deployment more complicated.

Evgeny's avatar Evgeny (2013-07-09 12:05:17 -0600) edit

@Evgeny there's any relationship between askbot's markdown server side code and https://pypi.python.org/pypi/Markdown ? if not, is there a reason it has to be customized?

pcompassion's avatar pcompassion (2013-07-11 14:10:16 -0600) edit

We actually use markdown2 library https://pypi.python.org/pypi/markdown2 we are not customizing the module itself, but we do use custom patterns which are set up in askbot.utils.markup.get_parser() so I think that what we might end up doing is implementing markdown2 in js so that identical functionality is available on the client side. I'll expand a bit in the answer.

Evgeny's avatar Evgeny (2013-07-11 14:24:27 -0600) edit

my original question had 'features that work in previewer but not after posted' Doesn't this mean the feature is missing in server part and we want to locate the relavant part in javascript and insert it in the markdown2 python code? (not markdown2->js as you mentioned)

pcompassion's avatar pcompassion (2013-07-11 20:02:23 -0600) edit

No, it's actually missing features in js. I've described in the answer. We use markdown2 with extra patterns + some post-processing. Js is pure markdown and is independent implementation of markdown2.

Evgeny's avatar Evgeny (2013-07-11 20:26:25 -0600) edit

http://en.wikipedia.org/wiki/JSON not shown correctly is because JS lacks some functionality which are present in server-side python?">JSON

pcompassion's avatar pcompassion (2013-07-11 21:19:14 -0600) edit

sent a pull request for it

pcompassion's avatar pcompassion (2013-07-12 00:29:10 -0600) edit
add a comment see more comments