q2a-markdown-editor icon indicating copy to clipboard operation
q2a-markdown-editor copied to clipboard

``` and <code> code blocks ignore indentation

Open akien-mga opened this issue 8 years ago • 11 comments

Hi there,

We're using this plugin on Godot Engine's Q&A, and I've noticed that the behaviour of the ``` and <code> 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.

akien-mga avatar Mar 09 '16 12:03 akien-mga

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 <code> 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.

svivian avatar Mar 12 '16 18:03 svivian

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

jeromesun14 avatar Sep 28 '17 09:09 jeromesun14

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

:/

q2apro avatar Feb 13 '18 14:02 q2apro

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

BlackEdder avatar Apr 20 '18 08:04 BlackEdder

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 avatar May 02 '19 19:05 jcubic

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

jcubic avatar May 02 '19 19:05 jcubic

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.

svivian avatar May 03 '19 10:05 svivian

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.

jcubic avatar May 03 '19 12:05 jcubic

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

rklec avatar Oct 06 '20 13:10 rklec

Hello,

Any progress here on CommonMark implementation?

Would be nice to use


    ```tex
    \csname TeX highlighted  \endcsname
    ```

Like it is here on Github:

\csname TeX highlighted \endcsname

maybe this php extension could lead somewhere?

Swoy avatar Mar 03 '21 10:03 Swoy

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)

sgohl avatar Feb 01 '22 18:02 sgohl