Display.html Troubles

Hello Herb, I hope that you’re doing well. I’m in the middle of a small project that involves customizing a display template and I came across a few things.

  1. The <?allfields?> merge command writes the entire display.html into the body of a note. This is not obvious from within Notenik, but when inspecting the (very useful) temp_display.html file it is evident.

    For example the following:

    <body>
    <?allfields?>
    <?if "=$IndividualFields$=" ?>
    <!-- For Detailed Formatting Control, Uncomment these lines: 
    <?if "=$tags$=" ?>
    
    <p><em>=$tags$=</em></p>
    <?endif?>
    
    <p><strong>=$title&h$=</strong></p>
    <?if "=$backlinks$=" ?>
    
    <p>Backlinks: =$backlinks$=</p>
    <?endif?>
    
    <?if "=$wikilinks$=" ?>
    
    <p>Wiki Links: =$wikilinks$=</p>
    <?endif?>
    
    <?if "=$body$=" ?>
    =$bodyw1o$=
    <?endif?>
    -->
    <?endif?>
    </body>
    

    Results in a body element in temp_display.html that consists of itself:

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="utf-8" />
    <title>2023-01-08 Sunday</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <style>
    ...
    	/* 	Notenik's default CSS styles */
    ...
    </style>
    </head>
    <body>
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="utf-8" />
    <title>2023-01-08 Sunday</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <style>
    ...
    /* The default CSS again */
    ...
    </style>
    </head>
    <body>
    ...
    <!--  The note rendered in HTML	 -->
    ...
    </body>
    </html>
    </body>
    </html>
    

    What is strange is that even if the CSS styling within the <style> element is completely different from the default, the default style will be put into the duplicate HTML document that appears within the note’s <body> element.

  2. The =$bodyw1o$= in the default display.html file is missing the ampersand before the variable modifiers (it should instead be =$body&w1o$=).

  3. Backlinks do not render as functional links in the same way that Wikilinks which appear in a note’s body do.

    • =$backlinks$= and =$backlinks&w1$= results in text like 2023-01-13 Friday;; that is not a link (i.e. it is plain text with the two semicolons included).

    • =$backlinks&w1o$= and =$backlinks&o$= will result in an HTML link that points to 2023-01-13-friday.html for example, instead of https://ntnk.app/20230113friday which customarily points to the note within Notenik.

  4. Tags are not linkable in a way that will display the corresponding tag in Notenik’s sidebar when they appear in a note as a result of a =$tags$= variable.

    E.g.

    <?allfields?> yields the following code:

    <p><em><a href="notenik://expand?path=/Users/user/Daily%20Notes/&tag=blog" style="text-decoration: none">blog</a>, <a href="notenik://expand?path=/Users/user/Daily%20Notes/&tag=design" style="text-decoration: none">design</a></em></p>
    

    =$tags$= results in only:

    <p><em><a href='blog' rel='tag'>blog</a>, <a href='design' rel='tag'>design</a></em></p>
    

Perhaps there may be a difference in how Notenik generates fields in unison via the <?allfields?> command and how it does so when the fields are called upon individually?

As always, thank you for your work. Please let me know if there is any other information that you’d like for me to offer.

See the latest beta and let me know if this works better for you.

I will say, in general, that the allfields command does work a bit differently from the use of the individual field variables, more or less by design.

That is, the allfields command uses the same code that is actually used on the Display tab, and so is meant to replicate the whole thing without variation.

On the other hand, when you use the individual fields, the intent is to give you more or less the raw data, assuming that in general you will format the data however you like (without even the assumption that you will be generating HTML).

This assumption becomes problematic, however, when the raw data consists of a potential series of values, and it would clearly be advantageous for each of the values to link separately to different locations.

I believe I’ve made adjustments so that, when you use the variable modifier of o on the backlinks field, or the wikilinks field, you should see the same sort of display you see in the normal display.

I haven’t done anything similar with the tags, partially because there are already a couple of variable modifiers available (g and z) that might suit your needs in this department.

Thanks again for the great bug reporting, and let me know how the beta works for you, when you get a chance!

2 Likes

Thank you for taking the time to explain the methodology behind these aspects of the display.html. It makes a lot of sense. I’m excited to try the beta out!