question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Extending export formats

See original GitHub issue

Analysis of current code shows that the export of the generated Abstract Syntax Tree attaches toHtml(), toMarkdown(), toLatex() to all levels of the AST:

  • Document
  • Section
  • Paragraph
  • Sentence For extending the capabilties of a wtf as a wiki transformation framework someone would install npm install wtf_wikipedia and then require the module in the extension with
const wtf = require('wtf_wikipedia');

Assume we want to add/replace the existing default one with another export format or add a new export format my_format, then the constructors need new export methods for the AST nodes - something like this:

wtf.ast.Document.prototype.my_format =  function(options) {
   ....
    return doc_in_my_format;
  };

wtf.ast.Paragraph.prototype.my_format =  function(options) {
   ....
    return par_in_my_format;
  };
 
wtf.ast.Section.prototype.my_format =  function(options) {
   ....
    return sec_in_my_format;
  };

...

I guess the constructors for the AST nodes defined in src can be expanded for another format if the AST node constructor are accessible in the required wtf_wikipedia - i.e. the constructor e.g. of a Document node in src/01-document/Document.js is available in wtf at wtf.ast.Document. These access to the constructors could be added at src/index.js with a require command.

wtf.ast = require('astnodes');

Or is there a better way to add plugins or extension for new export formats to wtf_wikipedia without touching the current code base of wtf_wikipedia, Spencer?

Cheers Bert

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
niebertcommented, May 14, 2019

Excuse me Spencer, do not want to trigger a refactoring. Excuse me for that. Forgot about the fact that nodes like Sentence are used multiple times and the require() must be adapted, if the export consists of just a single method. Would recommend to export always a hash with module.export={...} so that expanding the export hash does not require the adaptions of multiple const mynode = require('0x-node') imports. Thank you for all your feedback and thoughts, very valuable for me. Cheers, Bert

0reactions
spencermountaincommented, Mar 12, 2020

hey, this should all be possible now, as of v8! https://github.com/spencermountain/wtf_wikipedia/#configuration cheers

Read more comments on GitHub >

github_iconTop Results From Across the Web

Export or import data to another file format - Microsoft Support
You can export information from Project to another format, such as .xlsx, .csv, .txt, and .xml) using the Export Wizard or Import Wizard....
Read more >
File formats you can export and import
File formats you can export and import ; 1-2-3® and Symphony®. Microsoft™ Excel. WKS, WK1, WRK, WR1, WK3, WK4. Entire worksheet or named...
Read more >
Data Export Formats - Qualtrics
About Export Formats · CSV (Comma Separated Values) · TSV (Tab Separated Values) · Excel · XML (Extensible Markup Language) · SPSS (Statistical...
Read more >
What is it? How to open an EXPORT file? - FILExt
an export Export File is a special file format by Dassault Systèmes and should only be edited and saved with the appropriate software....
Read more >
Extending ODT export (The Org Manual)
The ODT export back-end can produce documents in other formats besides ODT using a specialized ODT converter process. Its common interface works with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found