-
Notifications
You must be signed in to change notification settings - Fork 1
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
expand childpages if converted to pandoc #100
Conversation
n2y/blocks.py
Outdated
elif block_type == ChildPageBlock: | ||
for b in blocks: | ||
result = b.to_pandoc() | ||
title = result[0][0]['title'][0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice idea! I think it makes a lot of sense to expand out sub pages. I would actually not show the page title as an H1, and would just show the page's content in place. This would work identically to linked pages then, which we use (or have a plugin) that expands.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea, I only did it as a debug because this subpage was converting to pandoc as a Pandoc block inside of another Pandoc block and that's against protocol. Is there another way you'd solve that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this was due to a weird thing Emily did in the templates. I just fixed it in the templates! That said, I think expanding the page (without the title) is a good idea.
n2y/blocks.py
Outdated
@@ -67,6 +67,10 @@ def children_to_pandoc(self): | |||
for block_type, blocks in groupby(self.children, lambda c: type(c)): | |||
if issubclass(block_type, ListItemBlock): | |||
pandoc_ast.append(block_type.list_to_pandoc(blocks)) | |||
elif block_type == ChildPageBlock: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we just add a condition to the if statement on Line 77 below rather than having a separate elif for this?
if isinstance(result, list) or block_type == ChildPageBlock:
I think we'd still get the desired functionality right (double check this please)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not the same because ChildPageBlock.to_pandoc() results in a Pandoc block which will cause an error because all of the pandoc will eventually end up in another Pandoc block. that's why result[1]
is selected on line 73. I could bring this logic down into that iteration though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work @sHermanGriffiths!
Author's Checklist
Before assigning reviewers, step through the following checklist. Check each item once it's completed. If an item is skipped, write an explanation below the item.
N/A
N/A
N/A
N/A
N/A