benweet / stackedit

In-browser Markdown editor
https://stackedit.io/
Apache License 2.0
21.8k stars 2.73k forks source link

Add Stack Exchange flavored syntax #361

Open akerbos opened 10 years ago

akerbos commented 10 years ago

There are some features the SE Markdown has but StackEdit does not, e.g.

For preparing SE posts with StackEdit, it would be useful if we could turn on these features (optionally).

Semyazz commented 10 years ago

don't like the idea.

akerbos commented 10 years ago
Semyazz commented 10 years ago

Maybe I got the wrong idea of this editor, but to me it's a general purpose Markdown HTML-based editor and not only a tool for Stack Exchange, and I think your request should be implemented as some kind of an extension if something like that is possible in the architecture or StackEdit. It's just a random idea, I've not read the code yet.

akerbos commented 10 years ago

I can't speak for the original author but I always took the name as sign of what Stack Edit was made for.

That said, it does support features that SE does not but that's not a reason to include SE-specific features.

I agree that the correct place for such features should be an extension (that can be turned on/off). Does not change my request, though.

brasofilo commented 10 years ago

The tag bubble can be solved with How to create 'simplelinks' in stackedit?.

Replacing URL by the title would require an API call, seems complicated... If anyone wants to try, this script has an example of API call.

I wanted to show prettified code for indented blocks, so I've done this extension, we have to add a <!-- end --> to it, so it can be replaced by the final backticks ```:

userCustom.onPagedownConfigure = function(editor) {
    var converter = editor.getConverter();
    converter.hooks.chain("preConversion", function(text, blockGamutHookCallback) {
        text = text.replace(/(\r\n|\r|\n)<!-- language: lang-javascript -->/g, '\r```javascript' );
        text = text.replace(/(\r\n|\r|\n)<!-- language: lang-php -->/g, '\r```php' );
        text = text.replace(/(\r\n|\r|\n)<!-- end -->/g, '\r```' );
        return text;
    });
};