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

Incorporate the collapsible code block #39

Merged
merged 2 commits into from
Nov 30, 2020

Conversation

snejus
Copy link
Contributor

@snejus snejus commented Nov 29, 2020

Something I use in the docs often is the <details><summary> html block which allows to embed code blocks of any size without losing out on the readibility - you can open and close the thing as you like.

Now the problem is that Confluence doesn't parse it (or does it in a weird way - I don't remember) and instead they have their own collapsible something, which is enabled through a flag in the code macro. This PR enables it, as well as the title field.

It's a bit of funky way to do it, but luckily github's markdown/codeblock parser is flexible enough to allow this:

```python collapse title Hello this is a Beautiful codeblock

def func():
    print("Beautiful")

# ... and 200 more lines of funk
```

And on confluence it looks this way:

image

Best part is that github's version looks as usual, seems like they just ignore the extra words.

If we wrap it in

<details>
<summary>Hello this is a Beautiful codeblock</summary>

```python collapse title Hello this is a Beautiful codeblock

def func():
    print("Beautiful")

# ... and 200 more lines of funk
```
</details>

We get

Hello this is a Beautiful codeblock
def func():
    print("Beautiful")

# ... and 200 more lines of funk

The lines that contain these tags have to be removed before uploading to confluence but that's specific to how I use it so may not apply to everyone - otherwise piping the file through sed /<\/\?details>\|<\/\?summary>/d removes them.

Let me know if I should remove the printfs from the template - it's a rather subjective change so I'm happy to let them go if you have doubts about them.

@kovetskiy
Copy link
Owner

Thank you!

@kovetskiy kovetskiy merged commit bcf2acb into kovetskiy:master Nov 30, 2020
@snejus snejus deleted the collapsible-code-block branch December 1, 2020 04:08
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

Successfully merging this pull request may close these issues.

2 participants