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

fenced_code markup not working inside a customblock #1

Open
mschwerhoff opened this issue Jun 28, 2020 · 2 comments
Open

fenced_code markup not working inside a customblock #1

mschwerhoff opened this issue Jun 28, 2020 · 2 comments
Labels
bug Something isn't working

Comments

@mschwerhoff
Copy link

I've just started experimenting with custom blocks in the context of the website generator Pelican, and was wondering what the preferred/recommended way of nesting fenced code blocks under custom blocks is.

Pelican by default supportes the syntax from CodeHilite (the ⎵ characters denote significant whitespace), as well as fenced code blocks:

⎵⎵⎵⎵#!python
⎵⎵⎵⎵print("I'm a string")

and

⎵⎵⎵⎵:::python
⎵⎵⎵⎵print("I'm a string")

and also

```python
print("I'm a string")
```

The good news: the former two syntax directly work when nested under a custom block. E.g.:

::: myblock
⎵⎵⎵⎵A *regular* line of `Markdown` formatted text.

⎵⎵⎵⎵⎵⎵⎵⎵#!python
⎵⎵⎵⎵⎵⎵⎵⎵print("I'm deeply offended *äh* indented")

To avoid the deep indentation, I typically prefer the fenced code blocks style, and thus tried the following:

::: myblock
⎵⎵⎵⎵A *regular* line of `Markdown` formatted text.

⎵⎵⎵⎵```python
⎵⎵⎵⎵print("Less is more")
⎵⎵⎵⎵```

Since fenced code blocks are only supported at the document root level, this requires installing the SuperFences as well.

Are there any other (maybe better) options?

Also, feel free to use this write-up in an FAQ or elsewhere (and to close this "issue"), maybe it can help others that find themselves in a similar situation.

@vokimon vokimon added question Further information is requested and removed question Further information is requested labels Jul 1, 2020
@vokimon
Copy link
Owner

vokimon commented Jul 1, 2020

Thanks for raising the question that indeed it spotted a bug. Github backtick syntax should definitely work inside a customblock. Would you mind to rewrite the issue as a bug report, for others to identify it better?

It should work because once a customblock is detected, any indented code is dedented and reparsed as markdown and because it is dedented, backtick code should be now a valid root level one with no need of superfences.

@vokimon vokimon added the bug Something isn't working label Jul 1, 2020
@vokimon vokimon changed the title Ways to nest code blocks under custom blocks (observation) Github's backtick code markup not working inside a customblock Jul 1, 2020
@vokimon vokimon changed the title Github's backtick code markup not working inside a customblock fenced_code markup not working inside a customblock Jul 2, 2020
@vokimon
Copy link
Owner

vokimon commented Jul 2, 2020

fenced_code documentation is honest about its limitations and seems ok with them, delegating to super_fences when nesting inside other blocks. I think it would be ok to keep it unsupported but i still have some hope on finding a solution so let me explore it further before closing the bug.

Both fenced_code and superfences, are defined as preprocessors to temporary preplace the code from the input text by a hash so that following processors won't mess up the code. Later they substitute it back with the formatted code.

The problem is that preprocessor are called before the parser, so when custom_blocks recall the parser with the dedented code, fenced_code is not applied. Maybe the key might be to find a way to call preprocessors as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants