svivian / q2a-markdown-editor

Markdown editor plugin for Question2Answer
55 stars 24 forks source link

``` and <code> code blocks ignore indentation #19

Open akien-mga opened 8 years ago

akien-mga commented 8 years ago

Hi there,

We're using this plugin on Godot Engine's Q&A, and I've noticed that the behaviour of the `` and` tags seems to ignore indentation, which is quite annoying when typing code with strict indentation rules like Python or GDScript.

Some example: image      image      image

On the other hand <pre> and an indentation of the whole block work fine: image

I reckon that this is probably not a bug per-se, but just that <code> and any number of backquotes are interpreted as inline code markers, and such inline code does not support indentation or multiple lines code blocks. However many users are used to GitHub's Flavoured Markdown and how it use triple backquotes to delimit pre-formatted code blocks. It would be nice to have support for something similar in q2a-markdown-editor.

svivian commented 8 years ago

The `` syntax is not part of the original Markdown specification, but looks like it _is_ part of "CommonMark" which is the new defacto standard. The` example is working as expected - that's an inline tag so the result should be inline code.

I'll look at updating the Markdown parser. There are some newer ones that follow the CommonMark spec more closely.

jeromesun14 commented 7 years ago

Waiting for fence code feature so long.

I try to modify qa-plugin/markdown-editor/MyMarkdown.php, and fence code works fine except preview.

change:

class MyMarkdown extends \cebe\markdown\Markdown

to:

class MyMarkdown extends \cebe\markdown\MarkdownExtra
q2apro commented 6 years ago

It should absolutely be part of this plugin.

Tried this one first and saw it is not working...

Also the button for Code insert should create:

```

```

I considered using this plugin for another site, but not having this is markup implementation (php and js) is the killer :(

Update:

I have tried the suggested <code> which would be a good workaround, however, it cuts the code block:

image

And after submit it looks like this:

image

:/

BlackEdder commented 6 years ago

I have the same problem as @q2apro. Any progress on this?

jcubic commented 5 years ago

I'm testing the plugin with new installation of Question2Answers and Editor work the same as the one on StackOverlow (I think they open sources their code in WMD plugin used by this code).

You can use same thing as in SO:

<!-- language: lang-js -->
    function() {
        return x + x;
    }

this highlight as javascript (don't look very good just bold keywords) but that other issue.

jcubic commented 5 years ago

It's seems that comment only work in preview is not removed on final html.

svivian commented 5 years ago

I think they open sources their code in WMD plugin

Yes, they did years ago but they gave up on it years ago too. I've searched before and never found anything similar.

The conversion side is easy enough, there are several libraries that match the CommonMark spec (this one looks the best for JavaScript). But for the actual editor side - as in, all the buttons and so forth - we might have to rewrite our own.

jcubic commented 5 years ago

I've started working on Markdown editor - Aimed, because I needed something without preview with just helper buttons. Maybe I will swallow part of WMD so it will be created faster but not sure if I'll continue working on it. It's just starting point for Markdown Editor, I wanted to create Q&A app in php (with Markdown editor) but few days ago I've search again and found Q2A.

Not sure which one is better SO editor or GitHub flavoring Markdown for Q2A site where questions target programmers. but definitely GitHub ```javascript backticks syntax is much better then SO comment and not everybody know that you can change the language on SO.

For now I'll keep using your plugin for Q2A.

rklec commented 4 years ago

Any news here? SO now also allows triple-backticks for code. This add-on here does not even highlight them properly. See https://github.com/svivian/q2a-markdown-editor/issues/30

Swoy commented 3 years ago

Hello,

Any progress here on CommonMark implementation?

Would be nice to use


    ```tex
    \csname TeX highlighted  \endcsname

Like it is here on Github:

```tex
\csname TeX highlighted \endcsname

maybe this php extension could lead somewhere?

sgohl commented 2 years ago

Did anyone perhaps have success implementing a library that actually works as expected?

triple-ticks code is the number one must have for me (and would be nice if it works in preview too)