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

serializeTaxonomy txt error #42

Open
kevincfz opened this issue Feb 1, 2018 · 3 comments
Open

serializeTaxonomy txt error #42

kevincfz opened this issue Feb 1, 2018 · 3 comments

Comments

@kevincfz
Copy link

kevincfz commented Feb 1, 2018

serializeTaxonomy.txt(taxonomy, process.stdout, { colors: true });

has error

TypeError: Cannot read property 'delimiter' of undefined

I believe the error traces to (wikidata-taxonomy/lib/serialize-txt.js:24:25) where it is looking for env.chalk but none is specified.

@nichtich
Copy link
Owner

nichtich commented Feb 1, 2018

Yes, this is wrongly documented. The serializeTaxonomy.txt expects no colors option but option chalk:

options = { chalk: require('chalk') }
serializeTaxonomy.txt(taxonomy, process.stdout, options)

I'm not happy with this but unsure how to provide better. Coloring depends on the output format, e.g. for HTML and CSS classes I use:

var col = (c) => (
        (s) => '<span class="'+c+'">'+escapeHTML(s)+'</span>'
      )
      options = {
        chalk: {
          delimiter: col('text-secondary'),
          green: col('text-success'),
          white: col('text-white'),
          cyan: col('text-info'),
          yellow: col('text-warning'),
          red: col('text-danger'),
        }
      }
serializeTaxonomy.txt(taxonomy, process.stdout, options)

What are the use cases?

@kevincfz
Copy link
Author

kevincfz commented Feb 6, 2018

My use case was to display the txt result/command line output on a web view, because I think the it is nice enough and do not want to parse json again.

@kevincfz
Copy link
Author

kevincfz commented Feb 6, 2018

I can satisfy my use case by learning how you are processing this in the web app example. Feel free to resolve this issue.

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

2 participants