Using display.html

I’ve successfully changed the body tag in display.css to change a Note’s Display pane’s background and foreground colors. So I wanted to add some italic and other niceties to that pane using display.html instead.

I moved my body tag into the Notekin-generated dispolay.html and removed display.css (and reloaded). But that just reverted to the default Dark system scheme.

And my edits to the HTML code weren’t observed either, of course. Here they are:

<body>
<?allfields?>
<?if "=$IndividualFields$=" ?>

<?if "=$tags$=" ?>

<p><em>=$tags$=</em></p><?endif?>

<h4>=$title&h$=</h4>

<?if "=$link$=" ?>

<p>Link: <a href="=$link$=">=$link$=</a></p><?endif?>

<?if "=$author$=" ?>

<p>Author: <b>=$author$=</b></p><?endif?>

<?if "=$worktype$=" ?>

<p>Work Type: =$worktype$=</p><?endif?>

<?if "=$date$=" ?>

<p>Date: <i>=$date$=</i></p><?endif?>

<?if "=$quote$=" ?>
<hr />
=$quotew1o$=
<?endif?>

<?endif?>
</body>

So how do I get display.html cooking? Or am I in the wrong kitchen here? TIA

Try placing <?nextrec?> at the very first line of your template (by itself) and placing <?loop?> at the very last line (by itself). These two commands are necessary for Notenik to know when a template begins (<?nextrec?> and when it ends <?loop?>.

https://notenik.app/knowledge-base/EPUB/html/nextrec-command.html

https://notenik.app/knowledge-base/EPUB/html/loop-command.html

The advice posted by @ThePrinter is good. In addition, try removing the line containing the <?allfields?> command. This one line will cause all fields for a Note to print and be formatted as they would on the Display tab, so this is probably what you are seeing.

Reference:

Thanks. I didn’t include the whole HTML file but that’s how it was created by Notekin. And I didn’t change any of that.

I appreciate the explanation, though.

OK, I removed that, changed the default color variables at the top and reloaded. I see my colors and the first few fields (tags, title), which are never blank. But as soon as I hit a field that is blank in the current Note, nothing more is rendered.

<body>

<?if "=$tags$=" ?>
<p><em>=$tags$=</em></p><?endif?>

<h4>=$title&h$=</h4>

<?if "=$link$=" ?>
<p>Link: <a href="=$link$=">=$link$=</a></p><?endif?>

<?if "=$author$=" ?>
<p>Author: =$author$=</p><?endif?>

<?if "=$worktype$=" ?>
<p>Work Type: =$worktype$=</p><?endif?>

<?if "=$date$=" ?>
<p>Date: =$date$=</p><?endif?>

<?if "=$body$=" ?>
=$body&w1o$=
<?endif?>

</body>

I did change =$body&w1o$= from =$bodyw1o$= (which works) otherwise this is what was generated by Notekin.

If I move fields that are filled in the current Note above ones that are empty, they do display. But any empty field aborts the rest of the Note’s display.

And if I remove the tests for a blank field, the display is rendered completely (but then I have these empty lines for the empty fields.

And (again) if I put the <?endif?> on a line by itself, that doesn’t abort the rendering. The docs do mention that but the Notekin export formats the <?endif?> on the same line as the HTML.

So the code that works for me is now:

<body>

<p><em>=$tags$=</em></p>

<h4>=$title&h$=</h4>

<?if "=$author$=" ?>
<p>Author: <strong>=$author$=</strong></p>
<?endif?>

<p>Date: <i>=$date$=</i></p>

<hr>
=$body&w1o$=

<hr>
<p>Work Type: <i>=$worktype$=</i><br>
<?if "=$link$=" ?>
Link: <a href="=$link$=">=$link$=</a></p>
<?endif?>
</body>
1 Like

I am implementing a fix to ensure that Merge Template commands such as <?endif?> will always appear on a line of their own, when generating the sample display template. See this item in the Pipeline.