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

List collection in the parser omits sublists #4

Open
t-eckert opened this issue Dec 13, 2020 · 1 comment
Open

List collection in the parser omits sublists #4

t-eckert opened this issue Dec 13, 2020 · 1 comment
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@t-eckert
Copy link
Contributor

Issue

When a user writes a list of ingredients or directions with a sublist, the sublist is not parsed in and is omitted in the output.

This issue was first seen in @jimbobbennett's pull request #3.

In this PR, @jimbobbennett submitted a recipe which included the instruction:

1. Whilst the condensed milk is boiling, make the pie base:

    1. Grease a pie dish with butter

    1. Put the digestive biscuits in a plastic bag and smash and roll with a rolling pin till you have fine crumbs

    1. Melt a small amount of butter in a pan and mix in the biscuit crumbs. You need enough butter for the crumbs to stick together, but not too much, so keep adding small bits of butter as needed until the crumbs start to bind.

    1. Spread the crumbs into the pie dish and press them firmly to the bottom and sides to make a pie base

    1. Put in the fridge till the butter cools and sets

The compiler did not render the indented instructions:

image

Root cause

The get_list_within_section function does not recursively collect items. It only checks the first set of children within a list and returns the strings. Source

Possible solutions

Instead of returning a list of strings, the parser should return a list of nodes which may be leafs or have children. No new class should be needed, the existing Node class in the marko package will do the job just fine.

The Recipe class will need to be changed such that the ingredients and instructions attributes are lists of Node instead of str.

The render_recipe_page will need to be changed to render HTML from the markdown nodes before being passed to the Jinja template.

@t-eckert t-eckert added bug Something isn't working good first issue Good for newcomers labels Dec 13, 2020
@t-eckert
Copy link
Contributor Author

This will also be fixed with the solution proposed in issue #7.

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

No branches or pull requests

1 participant