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