Skip to content

RustTraining Python Book Chapter 12 Mermaid Syntax Error #83

@AloyBranCheung

Description

@AloyBranCheung

Description

The mermaid diagram under Comprehensions vs Iterator Chains is showing this error :

Unable to render rich display

Parse error on line 2:
...,3,4,5]"] -->|.iter\(\)| B["Iterator"]
-----------------------^
Expecting 'SQE', 'DOUBLECIRCLEEND', 'PE', '-)', 'STADIUMEND', 'SUBROUTINEEND', 'PIPE', 'CYLINDEREND', 'DIAMOND_STOP', 'TAGEND', 'TRAPEND', 'INVTRAPEND', 'UNICODE_TEXT', 'TEXT', 'TAGSTART', got 'PS'

For more information, see https://docs.github.com/get-started/writing-on-github/working-with-advanced-formatting/creating-diagrams#creating-mermaid-diagrams

Also seen on site

Actual code

flowchart LR
    A["Source<br/>[1,2,3,4,5]"] -->|.iter\(\)| B["Iterator"]
    B -->|.filter\(\|x\| x%2==0\)| C["[2, 4]"]
    C -->|.map\(\|x\| x*x\)| D["[4, 16]"]
    D -->|.collect\(\)| E["Vec&lt;i32&gt;<br/>[4, 16]"]
    style A fill:#ffeeba
    style E fill:#d4edda
Loading

Solution

I would like to propose this solution for the fix

flowchart LR
    A["Source<br/>[1,2,3,4,5]"] -->|".iter()"| B["Iterator"]
    B -->|".filter(|x| x%2==0)"| C["[2, 4]"]
    C -->|".map(|x| x*x)"| D["[4, 16]"]
    D -->|".collect()"| E["Vec&lt;i32&gt;<br/>[4, 16]"]
    style A fill:#ffeeba
    style E fill:#d4edda
flowchart LR
    A["Source<br/>[1,2,3,4,5]"] -->|".iter()"| B["Iterator"]
    B -->|".filter(|x| x%2==0)"| C["[2, 4]"]
    C -->|".map(|x| x*x)"| D["[4, 16]"]
    D -->|".collect()"| E["Vec&lt;i32&gt;<br/>[4, 16]"]
    style A fill:#ffeeba
    style E fill:#d4edda
Loading

Please let me know what you think

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions