{"id":15601189,"url":"https://github.com/hacknlove/textmaker","last_synced_at":"2025-09-19T20:12:39.547Z","repository":{"id":48020076,"uuid":"177940927","full_name":"hacknlove/textmaker","owner":"hacknlove","description":"Generate texts with a rich and descriptive microlanguage of recursive sustitutions","archived":false,"fork":false,"pushed_at":"2023-01-03T18:51:57.000Z","size":479,"stargazers_count":2,"open_issues_count":6,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-08T20:51:09.334Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hacknlove.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-27T07:29:32.000Z","updated_at":"2024-04-25T02:48:48.000Z","dependencies_parsed_at":"2023-02-01T09:01:56.673Z","dependency_job_id":null,"html_url":"https://github.com/hacknlove/textmaker","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hacknlove%2Ftextmaker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hacknlove%2Ftextmaker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hacknlove%2Ftextmaker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hacknlove%2Ftextmaker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hacknlove","download_url":"https://codeload.github.com/hacknlove/textmaker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240810789,"owners_count":19861308,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-03T02:19:32.830Z","updated_at":"2025-09-19T20:12:34.482Z","avatar_url":"https://github.com/hacknlove.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# textmaker\n\n[![HowTo](https://asciinema.org/a/mIAGbQ5zX9lAV8p1ZJ4391kh9.png)](https://asciinema.org/a/mIAGbQ5zX9lAV8p1ZJ4391kh9)\n\n## Instalation\n```\n  npm install @hacknlove/textmaker\n```\n\n## Usage\n\n```\n  import TextMaker from { 'textmaker' }\n  // // or\n  // const TextMaker = require('textmaker')\n\n  const textMaker = new TextMaker({\n    description: ObjectWithTheTextsDescriptions,\n    seed: \"Some string, if you want your text to be predictable and replicable\"\n  })\n\n  var text = textMaker.generate()\n```\n\n## Text description\n\nThe text description is a Javascrit Object that contains an array with the templates,  a bunch of sustitution arrays with more templates\n\nyou can check [example.json](example.json)\n\nIt contains string templates that includes plain text, **direct sustitutions** and **referenced sustitutions**\n\n### Set variable\nThe template `\"...((name: value))...\"` will set a variable called `name` with the value `value`\n\nThe value can be any template, but direct nesting is not allowed.\n\n* `...((foo:...((bar:buz))...))...` is not allowed.\n* `...((foo:...$bar))` it is always allowed even if `$bar` can be sustituted with `...((bar:buz))...`\n\n### Variable substitutions\nThe template ``\"...%name...\" will generate `...value...` where `value` is the value of the variable called `name`\n\n### Direct sustitutions\n\nThe template ``\"I want [[cake-fruit-pie]]\"`` will generate\n* *I want cake*\n* *I want fruit*\n* *I want pie*\n\nThey can have as many options as you need, but if you need a lot of options you should consider using **referenced sustitutions** to keep your templates human readable.\n\nThey could be anidated so ``\"I want [[some fresh [[fruit-juice]]-a piece of [[cake-pie]]\"`` will generate\n* *I want some fresh fruit*\n* *I want some fresh juice*\n* *I want a piece of cake*\n* *I want a piece of pie*\n\nYou can nest as many options as you need, but you should consider using **referenced sustitutions** if you feel that you are loosing the vision of what is going there.\n\n**Direct sustitutions** should be used to define quick simple choices.\n\n### Referenced sustitutions\n\nDirect sustitutions are words formed only by characters from `a-z`, `A-Z`, `0-9`, including the `_` (underscore), that starts with a `$`\n\nFor instance `\"$foo\"`, `\"$bar\"` `\"$foo_bar\"`\n\nThey match the javascript regexp `/\\$[\\w]+/` that is equivalent to `/\\$[a-z0-9_]+/i`\n\nThey are sustituted for a random template of the array in `description` whose `key` matchs\n\n#### Examples\n\n```\n  description = {\n    templates: [\n      \"I want $dessert\"\n    ],\n    $dessert: [\n      \"cake\",\n      \"fruit\",\n      \"pie\"\n    ]\n  }\n```\n\n```\n  description = {\n    templates: [\n      \"I want $dessert\"\n    ],\n    $dessert: [\n      \"some fresh $healthyDesert\",\n      \"a piece of $unhealthyDessert\"\n    ],\n    \"$healthyDesert\": [\n      \"fruit\",\n      \"juice\"\n    ],\n    \"$unhealthyDesert\": [\n      \"cake\",\n      \"pie\"\n    ]\n  }\n```\n\n### description.templates\nThis array contains the fist level templates, those that the generator picks in the first step.\n\nIt could be as complicated as you want, but it is preferable to keep them as simple as possible so they could be an index to the human eyes, so you can know at a glance what each one generates.\n\n### Process flow\n\nThe transformations are done in 4 steps:\n\n1. variable setting\n2. variable sustitutions\n3. simple sustitutions\n4. reference sustitutions\n\nEach step is done iteratively until there is no more setting or substitutions to do\n\nIf one o more substitutions were done in the 4th step, the process start again from the first step. Otherwise the process ends.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhacknlove%2Ftextmaker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhacknlove%2Ftextmaker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhacknlove%2Ftextmaker/lists"}