Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] Codeblock inside list has wrong indentation #2209

Closed
gabyx opened this issue Jan 5, 2022 · 11 comments
Closed

[bug] Codeblock inside list has wrong indentation #2209

gabyx opened this issue Jan 5, 2022 · 11 comments

Comments

@gabyx
Copy link

gabyx commented Jan 5, 2022

Convert the following

<pre class='metadata'>
Title: Bla
Shortname: bla
Level: 1
Revision: 1
Status: DREAM
URL:
Markup Shorthands: markdown yes
Editor: 
Date: 2021-01-04
Toggle Diffs: no
No Abstract: no
Default Highlight: cpp
</pre>

# First

-   Bla bla

    ``` cpp
    int a;
    ```

Results in

image

@tabatkins
Copy link
Collaborator

Indeed, looks like I run the "remove indents from pre" code before I do Markdown processing to turn code blocks into pres. It looks like just swapping the order is mostly okay, but it causes some paragraphs to lose their paragraph-ness, so I'll have to be play around with this and see how best to handle it.

@gabyx
Copy link
Author

gabyx commented Jan 7, 2022

Why not use pandoc ;) and its AST which makes it Commonmark compliant in all means ? It would be soo nice if bikeshed would use pandoc because, it would be a major benefit IMO

@tabatkins
Copy link
Collaborator

Because Bikeshed-flavored Markdown makes two important changes divergences from CommonMark - no indented code blocks, and good handling of HTML with indentation. (These two are intrinsically connected; you can't do the second without the first.) So no, I can't use any other Markdown parser.

@gabyx
Copy link
Author

gabyx commented Jan 7, 2022

Ok jeah, thats true, I also dont understand why indented codeblocks can not be deprecated, its nonsense IMO…

@gabyx
Copy link
Author

gabyx commented Jan 7, 2022

Bit I thought the comman mark spec allows HTML everywhere except when its parsed as indented codeblock?

@tabatkins
Copy link
Collaborator

CommonMark does not handle HTML well, with proper indentation and such. It fundamentally can't, because indented code blocks exist. So you can mix a little HTML into your standard Markdown, but you can't write a proper hybrid HTML/Markdown document, which was explicitly one of my goals with Bikeshed. Thus, Bikeshed-flavored Markdown is slightly different.

The problem here isn't related to any of this, tho. It is indeed just a bug on my part - I just run the indent-removing code before the markdown code blocks are turned into a form that I can recognize as needing their indents removed.

@gabyx
Copy link
Author

gabyx commented Jan 7, 2022

Ah thanks for the explanations, interessting.
No worries, I was just curious. Thanks for the fix :)

@tabatkins
Copy link
Collaborator

All right, took a surprising amount of twiddling before I hit on a correct solution I was happy with. All fixed now, tho.

@gabyx
Copy link
Author

gabyx commented Jan 14, 2022

Thanks for your effort!!

@gabyx
Copy link
Author

gabyx commented Jan 17, 2022

There is a regression I think:

- a:

  \```cpp
  #pragma once

  namespace {
    static const float c_threshold = 3.14156f;
    void myPrivateFunction() {}
  }
  \```

Still has wrong indentation. Dont know why.

@tabatkins
Copy link
Collaborator

Ah, it was because you have a blank line in it, which has a zero-space prefix. I've now fixed the code to skip blank lines when calculating the prefix to strip, and confirmed that it catches some additional cases in my test files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants