Parsing a tiddler containing structured data

116 views
Skip to first unread message

Steven Schneider

unread,
Oct 18, 2016, 12:13:28 PM10/18/16
to TiddlyWiki
As part of my bibliography project (see previous thread, https://groups.google.com/forum/#!topic/tiddlywiki/ZKiviPin72c) it occurs to me that I could import a structured file (a bib file) as a tiddler, and write macros that search for / extract records from that tiddler. Is something like that even possible?

Here, for example, is what a bib file with two entries might look like
@InProceedings{Dalgaard2001,
  author     = {Dalgaard, Rune},
  title      = {Hypertext and the Scholarly Archive: Intertexts, Paratexts and Metatexts at Work},
  urldate    = {2016-10-17},
}

@Article{Rowan2016,
  author     = {Rowan, Kyle Edward},
  title      = {Not Quite a Sunset: a hypertext opera},
  date       = {2016},
  shorttitle = {Not Quite a Sunset},
  urldate    = {2016-10-17},
}


How could I write macros that would allow me to transclude fields/values from this tiddler, for example:

{{Rowan2016!!url}} to return http://escholarship.org/uc/item/9830g5pn.pdf

{{Rowan2016!!type}} to return @Article (this would be necessary to generate custom templates based on type)

etc.


I am still interested in parsing this file into separate tiddlers (one for each @), but the approach outlined above might be easier for me to handle.

Thanks,

//steve.

Jeremy Ruston

unread,
Oct 18, 2016, 1:09:51 PM10/18/16
to tiddl...@googlegroups.com
Hi Steve

> Ideally, TW should read the .bib file directly, of course. But, one step at a time...

OK, I’ve bowed to the inevitable and spent 40 minutes whipping up a basic BibTeX importer plugin, based on a JavaScript BibTeX parser that I found.

You can try it out at:


I found that your .bib file at https://stevesunypoly.updog.co/bibtex/first-jabref-bibtex-db.bib gives an error unless I remove the final line:

@Comment{jabref-meta: databaseType:bibtex;}

I’ve only done the most basic field conversion:

* title comes from citationKey
* bibtex-entry-type comes from entryType
* all entryTags are assigned to fields with the prefix “bibtex-“

Let me know how you get on,

Best wishes

Jeremy


--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/830c0d47-36df-4535-b137-54e93a845c5a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Steven Schneider

unread,
Oct 18, 2016, 1:46:19 PM10/18/16
to TiddlyWiki
Thanks, Jeremy. Yes, works perfectly! You've made my day!! I'll get to work on macros, that I can handle. A deserializer is way beyond my skills (and only vaguely within my comprehension.

This will help me and others who need bibliographic management within TiddlyWiki, and allow us to move TW forward as a serious academic tool, including being able to write (and publish) journal articles, books, etc. 

40 minutes! It took me 3 days to figure out that I should import a .bib file directly :). Again, thanks, and I'll get on with testing the pre-release version ...

//steve.

Jeremy Ruston

unread,
Oct 18, 2016, 2:11:22 PM10/18/16
to tiddl...@googlegroups.com
Hi Steve

Thanks, Jeremy. Yes, works perfectly! You've made my day!! I'll get to work on macros, that I can handle. A deserializer is way beyond my skills (and only vaguely within my comprehension.

Great, I hope it does the trick.

A deserialiser, by the way, is a JS module that extracts tiddlers from a block of text. The same deserialisers are used in the browser during the import process, and under Node.js by the --load command.

This will help me and others who need bibliographic management within TiddlyWiki, and allow us to move TW forward as a serious academic tool, including being able to write (and publish) journal articles, books, etc. 

40 minutes! It took me 3 days to figure out that I should import a .bib file directly :). Again, thanks, and I'll get on with testing the pre-release version ...

I think there's a bit more work needed. The field conversion done at the moment doesn't make any attempt to extract tags, for instance.

When you've had a chance to play around it would be helpful if you could map out a more useful mapping, and we'll figure out a way to configure the conversion process.

Best wishes

Jeremy

Steven Schneider

unread,
Oct 18, 2016, 2:57:38 PM10/18/16
to TiddlyWiki
Ask and you shall receive! The TiddlyWiki gods have been kind to me this week! Based on Jeremy's BibTex importer plugin (available in pre-release), I'm now able to do, well, almost everything I imagined with respect to bibliography management using bibtex and importing into tiddlywiki.


More work to be done, but this is huge

(duplicate of biblio thread).
Reply all
Reply to author
Forward
0 new messages