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

Add option to disable indented code blocs #138

Closed
xplosionmind opened this issue May 31, 2021 · 4 comments
Closed

Add option to disable indented code blocs #138

xplosionmind opened this issue May 31, 2021 · 4 comments

Comments

@xplosionmind
Copy link

I am getting crazy. I have a lot of indented <ul> lists, where I need to use HTML since I am adding classes to single lists elements.

I write them like this, in markdown files:

<ul>
    <li>blah blax</li>
    <li>blah blax</li>
</ul>

and they are parsed like this:

    <li>blah blax</li>
    <li>blah blax</li>

I can’t therefore indent anything, not even in divs or in ols, since they are parsed as codeblocks.

I would really love the capability of disabling this.

Thanks a lot in advance!

@gjtorikian
Copy link
Owner

It's really unlikely that the option to disable indented Commonmark behavior will ever be added. If it's in the spec, it must be supported.

But let's see if we can't figure out a solution here. Is there a reason the lists need to be indented by four spaces? Would two spaces work for you? That would "turn off" the indented code blocks.

Also, I just tried this as a markdown doc:

text = <<~EOS
<ul>
    <li>blah blax</li>
    <li>blah blax</li>
</ul>
EOS

A call to CommonMarker.render_html(text, :UNSAFE) properly returns "<ul>\n <li>blah blax</li>\n <li>blah blax</li>\n</ul>\n" (no code blocks). Is it possible there's something else going on in the way your doc is being rendered/called?

@xplosionmind
Copy link
Author

Thanks a lot for your prompt answer, @gjtorikian.

Actually, I never indent my code with spaces, but with tabs. Furthermore, i found out what simple <ul> lists do work, even with a tab, as your test proved. The trouble happens when I use Liquid for loops in Jekyll, since I am using commonmarker via the jekyll-commonmark plugin. In that case, a lot of whitespace is generated and, even if it is still enclosed in <ul> and </ul> it is rendered as markdown…

Could I do something to prevent this? The only way I found out up to now is to remove all indentation. Using fewer spaces is useless since for sub-lists are still needed four spaces of indentation…

@gjtorikian
Copy link
Owner

Do you have a sample site I could look into? I might be able to reproduce the problem and implement a fix to minimize the whitespaces.

@xplosionmind
Copy link
Author

Right now I have no website using Commonmark, since it does not generate IDs for headings, and I need them to generate TOCs. As soon as automatic ID generation will be implemented, I will use jekyll-commonmarker for my website and I will ping you by writing here

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