Skip to content

List collection in the parser omits sublists #4

@t-eckert

Description

@t-eckert

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions