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

Substitutions behave strangely inside bindings #21

Open
rocketnia opened this issue Mar 7, 2016 · 0 comments
Open

Substitutions behave strangely inside bindings #21

rocketnia opened this issue Mar 7, 2016 · 0 comments

Comments

@rocketnia
Copy link

My CBDQ bot started acting up a few months ago. Suddenly #[pMysteriousPower:#pMysteriousPower#]treasureOfPower# started generating the text "pMysteriousPower" instead of following the treasureOfPower rules.

To see what was going on, I tried #[a:FOO#[b:c]d#BAR]a# as a more elaborate example. It generated the text "FOOb".

Here's some test code:

console.log(tracery.createGrammar({
    origin: [
        "#[a:FOO#[b:c]d#BAR]a#"
    ]
}).flatten("#origin#"));

console.log(tracery.createGrammar({
    "origin": [
        "#story#"
    ],

    "story": [
        "#[pMysteriousPower:#mysteriousPower#]storyOfParams1#"
    ],
    "storyOfParams1": [
        "#[pMysteriousTechnoTreasure:#[pMysteriousPower:#pMysteriousPower#]treasureOfPower#]storyOfParams2#"
    ],
    "storyOfParams2": [
        "When you need #pMysteriousPower#, look no further than the #pMysteriousTechnoTreasure#!"
    ],

    "mysteriousTechnoTreasure": [
        "#[pMysteriousPower:#mysteriousPower#]treasureOfPower#"
    ],
    "treasureOfPower": [
        "#treasureType# of #pMysteriousPower#"
    ],
    "treasureType": [
        "amulet",
        "talisman"
    ],
    "mysteriousPower": [
        "teleportation",
        "frost"
    ]
}).flatten("#origin#"));

On the main branch, these result in the text "{{a}}" and (for example) "When you need frost, look no further than the amulet of frost!" respectively. Those look like good results to me.

On the tracery2 branch, I get the text "FOOb" and (for example) "When you need frost, look no further than pMysteriousPower!"

Here's an .html file demonstrating the above example code on the tracery2 branch. It doesn't display anything, but it logs to the console.

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

No branches or pull requests

1 participant