Field values and character formatting

Background
I would like to create tiddlers for chemical compounds using the name of the compound. However, many names include some sort of character formatting, e.g. italic, bold and superscript.

Assumption
Character formatting does not seem to be possible in the title field.

What I’ve Tried
However, it seems that it is possible to add character formatting to the value of other fields. For example, I have used (//R//)-butan-2-ol as the value of a field called cpd_name so that when I include {{!!cpd_name}} in the body it is displayed as (R)-butan-2-ol.

Questions

  1. Is my assumption correct?
  2. Is it okay to include markup in the value of a field?

This is my first post to the Discourse forum so I hope I’m doing it correctly but please tell me if I’m not. I also have a bunch of other queries that follow on from this but I’ll leave these for later.

Many thanks,

Anthony

Welcome Ant., you are using Discourse the way you need to use it.

A tiddler title is the key to you data, so it is wise to keep it simple. You can put markup into any field just like the text and as long as you transclude or wikify it it will be formatted.

The caption field is often use this way, perhaps transcluding an icon, or bolding and other formats. The caption is often used rather than the title in a list, try putting your format into the caption.

Remember a search string is best not including “markup”.

However in special notations like molecules or mathematical notations we have other ways to achieve the same results so we can guide you there.

Okay, grand and thank you @TW_Tones.

I can see the logic for keeping the title simple… the example I gave above was quite a simple case and (R)-butan-2-ol could be used as a title without much loss of meaning. However something like tricyclo[1.1.1.01,3]pentane, which as a title would have to be tricyclo[1.1.1.01,3]pentane is more problematic. Alternatively, for the title I could use a registry number system or other methods of encoding the structure but they are typically entirely cryptic or do not provide any chemical meaning. Really, I’m still trying to work out the best and easiest way forward.

I’ve been playing around with the caption field and discovered that I can transclude (I think that’s the correct term here) the value of another field into it. My thinking is that it would be logical (to me, at least) to have a field called, say, iupac_name (tl;dr IUPAC, among other things, oversees a system of nomenclature rules for naming chemical compounds - there are other nomenclature systems), the value of which is transcluded into the caption field with {{!!iupac_name}}. I know that the value of the caption field can then be diplayed in buttons and tabs and I was hoping I could also use it in links but I’ve not figured that out yet. Of course, if this is possible I guess I could just use the value of {{!!iupac_name}} rather than complicating things!

I think I understand why one wouldn’t want ‘markup’ in a search string but, equally, I don’t fully understand the nuance of what you’re saying.

I’m interested in your comments in the final paragraph…

Many thanks for your input so far,

Anthony

Hi Anthony,
Welcome to the club :slight_smile: … You are doing it right. … As Tony wrote, it’s OK to use fields in any way you want.

It’s only important, that you find a way that is consistent for you. So imo cpd_name as a field is OK, if it is OK for you.

There are some field names in tiddlywiki that we also use for various functions eg: caption, description and subtitle … You can see all fields used at tiddlywiki.com, if you open the
ControlPanel : Info : Advanced : Tiddler Fields tab

This shows all the fields, that tiddlywiki.com uses. Those with no description are part of the wiki content. Those with a description are known by the TW core. … Many “core fields” also activate special features. eg:

  • caption … Is a short title automatically used by the core tabs-macro or the “table of contents”
  • description … For all kind of descriptions
  • icon … Will allow you to add an icon to your tiddler title
  • subtitle … I personally use that one as a “long title” as the opposite of caption

So if you “prefix” your own fields, as you did with cpd_ there shouldn’t be any problems with naming conflicts.

The only problems, that come up with “custom” fields is, that the standard search doesn’t look at them. There are various plugins, that can help you there.

I did create the Field Search plugin which integrates in the “Standard” search tab. The main page contains a video, how to use it.

Mohammad created an Advanced Search in Fields plugin, which creates its own tab in advanced search

That’s it for the moment. … Just ask, if you have more questions

The TW search feature only finds “exact matches”. So if you use (//R//)-butan-2-ol as a tiddler title and search for eg: “(R)” it won’t show up in the search results. You would need to search for “(//R” or “butan-2” to get results.

I also did create a plugin, that can use “aliases” to be used in links. eg: [[alias-name|?]] … It’s part of the uni-link plugin

Aliases are not case sensitive, which makes it easy to use in within sentences or a the start of a sentence, where you typically start with a capital letter.

You are talking about this: Brief Guides to Nomenclature - IUPAC | International Union of Pure and Applied Chemistry … right.

I did have a very short look at the 3 different PDFs linked from the site. … It seems some “tagging” mechanism may be of help for you too. eg: organic, inorganic and polymer will already give you a good “sorting” feature, to get overviews.

eg: <<list-links "[tag[organic]]">> will give you a list of all tiddler titles tagged “organic”. … Just an example

Thanks @pmario, I thought that might be the reason but wondered if there was anything deeper.

Yes, those are the type of rules I meant… actually I’m really only going to be dealing with structures of organic compounds and I’m intending to use tags to categorise various features of each structure. Examples might be functional groups (e.g. alcohol, carboxylic acid, ketone, etc.) or type of ring system. Possibly getting a bit chemical-technical here so I’ll stop!

I was aware of some of the fields but hadn’t found that particular list. I’ve seen, as a new field name is typed, those already created that match the string so far are displayed so I’ve been careful to avoid clashes.

I’m replying to individual posts but they’re all showing at the bottom of the thread so this may be getting a little jumbled.

I think finding a good solution for your case, and any others where we have a specialist encoding or markup, would be a good idea. Why not start with your case.

There seems to me two almost opposite approaches;

  • Have a way to record a searchable name and a separate markup
  • Have a special markup in names with tools to search them.

I can see an interactive method to search for “molecules” based on what we (perhaps you) know about the representation of molecules (in your wiki). You could make a nice interface to select from available elements, molecules and enter new ones which has the smarts to populate both the title, in a separate field that has the appropriate markup and perhaps a “plan english name” as well. The same set of methods could be used for search as well for example we may search for molecule’s that have an OH and a C4.

If designed well the use of such a system would slowly “teach your wiki”, allowing future molecules to be added more easily as it acquires names, symbol’s etc…

If we find a suitable resource we could even preload the wiki with common english names for molecular combinations.

Thanks these are some interesting and big ideas! However, I’m not sure I have the skills to do this. There are quite a few chemoinformatic and drawing apps already available so there might be a degree of reinventing the wheel as well.

If I understand correctly, I think this would mean recording similar data twice, both with and without markup. With complicated names this could be error prone.

I did wonder whether some sort of regex tool could do the job. Again, that’s way beyond my skill set! Alternatively a macro that takes the field value and just strips out the markup and passes the value on to a search tool.

All sorts of interesting ideas being raised and it’s giving me lots to think about.

Just present a User Interface to enter the molecules and let the interface handle this programmatically, updating fields and tiddlers with a single button click. Making it even less error prone.

That’s not a big problem. There is an link automatic link at your post, that let’s me see my post.

image


… The better way is, to quote the relevant text you reply to. Replies can also be expanded, to see the whole post.

image

To go back to your OP. It should be relatively simple to replace the tiddler title in the view template with a rendered name. There could be an option, to switch between the 2 representations. 1 rendered, 1 “raw”.

With the possibilities we have now with v5.2.1, that should be possible without modifying the core UI. So the changes should be “forward compatible”.

I think for the beginning the only thing to sort out needs to be “search ability”. IMO this needs some testing from your side. … Except, if you have a testcase wiki, with some real tiddlers, we could play with.

If you don’t have an easy way to publish a wiki, you could use tiddlyhost.com, to create such a test-wiki.

I’m just getting to grips with this… managed to do it this time!

1 Like

This would make sense! Maybe something I can work towards but at present my skills are rather limited. More to think about and tinker with…

Okay, I generally follow what you mean but I don’t, currently, know how to do this (I’m not asking for you/anyone to do this - see below).

I don’t have a wiki that I could share at present… I was really just thinking about possibilities and trying things out with a few test tiddlers. It’s still really early days and I thought I’d ask a few questions to try to clarify my understanding (and also to try to learn how to use Discourse as I’ve found doing more than just lurking a bit daunting).

I hope it’s okay to quote from different posts… I’ve installed your uni-link plugin and had some success with it so that’s positive. I’m still a little confused about some aspects (the Alias options, for example) but I’m working through things and I’m getting it straight in my mind.

I hadn’t fully appreciated this aspect of searching. I will take a look at your Field Search plugin and also @Mohammad’s Advanced Search in Fields plugin.

Ant,

In case it’s helpful for poking around, I have tiddlers for books, where the author is not italicized but the title is, and I want the tiddlers to display as short forms of Author, Title (year). So I’m displaying the caption field instead of the title, on both the sidebar lists and the ViewTemplate. Check it out if you like:

https://springerspandrel.github.io/tw/biblio-demo

Looks good… now I just need to work out how the caption field is displayed rather than the title… hopefully I can work it out so don’t tell me!

Many thanks.

1 Like