It not “bad movie”, but it certainly is not a good movie. I saw it because I was curious and I wanted to watch something that I wouldn’t mind being interrupted while watching.
Toward the end, I was kind of hoping for it to end.
Ultimately, it feels like a movie that was trying really, really hard for you to like it. The main protagonist is a combination of Superman’s powers with a 90’s moody Batman who kills. You don’t get much of a reason to root for him until much later in the film and at that point it was too late.
It not “bad movie”, but it certainly is not a good movie. I saw it because I was curious and I wanted to watch something that I wouldn’t mind being interrupted while watching.
Toward the end, I was kind of hoping for it to end.
Ultimately, it feels like a movie that was trying really, really hard for you to like it. The main protagonist is a combination of Superman’s powers with a 90’s moody Batman who kills. You don’t get much of a reason to root for him until much later in the film and at that point it was too late.
If you have some time, could you check out what I wrote regarding the update to my blog theme?
I’m rolling out another update to my theme for Micro.blog. It took a lot of time and effort on my part. It definitely reminds me of the story about how people paint both the front and back of a fence. I don’t think most will know or use some of the things that I put into this. If you do use or learn anything from this, I would really appreciate you sending me a message.
I’ve been doing small tweaks to the theme for the last couple of weeks as I learn more and more about CSS. I had even posted about how I had started working through the material found in Kevin Powell’s Conquering Responsive Layouts course and got a couple of responses that pointed me to further research.
There are plenty of miscellaneous changes that I put in related to accessibility and edge cases for HTML elements.
Back on the (code) block
I’ve been working on code blocks for a while. I don’t think there are many blogs on micro.blog that feature code as a regular part of what they publish. It’s very important to me that as someone who is writing about the code of the theme that it can be read.
It haunts me.
I was ok with the fact that the code blocks worked well with Hugo version .91 but, with the availability of .177, I couldn’t ignore the problems that I saw.
The underlining issue is that the default properties for the theme and Hugo is to place the styling inline of the HTML. AND, that I’ve opted to use display: inline-block for the <div> that is the container for my blog posts.
To better explain the issue, I’ll use the following snippet found in the Hugo documentation about code fences and put it in one of my posts, I’d get different results based on the version of Hugo that I’m running.
```go {linenos=table,hl_lines=[1,11,"15-16"],linenostart=199, anchorlinenos=true, lineanchors=small }
// GetTitleFunc returns a func that can be used to transform a string to
// title case.
//
// The supported styles are
//
// - "Go" (strings.Title)
// - "AP" (see https://www.apstylebook.com/)
// - "Chicago" (see https://www.chicagomanualofstyle.org/home.html)
//
// If an unknown or empty style is provided, AP style is what you get.
func GetTitleFunc(style string) func(s string) string {
switch strings.ToLower(style) {
case "go":
return strings.Title
case "chicago":
return transform.NewTitleConverter(transform.ChicagoStyle)
default:
return transform.NewTitleConverter(transform.APStyle)
}
}
```
Hugo will render this as a series of nested spans in a table in a couple of divs. For example, the span that contains the line number would be div.highlight > div > table > tr > td:first-of-type > pre > code > span.
Each level of this structure may have its own inline styling.
Going back to the code snippet, with version .91, I would get the following output for the highlighted line 213 (the one that with ‘case “go”’). I changed the spacing for legibility.
Note that this version allows use to set anchors for the individual lines as well as a prefix.
At this point, I realized that I needed to have a better way of controlling the behavior of the different elements. Luckily, the documentation for Hugo Highlighting configuration has a noClasses flag that we can set in the config.json of the theme.
With the noClasses set to false1, the line that we’ve been looking at gets rendered to something like below.
The example is legible without the color and inline formatting.
To put the color back into the example, we refer to the documentation on how to generate syntax highlighter CSS to get the colors. I used the example that they provided so that I could compare it to the defaults.
hugo gen chromastyles --style=monokai > syntax.css
Then we add the newly created css file to our site-head.html to represent that syntax color is important but that the style.css is the final say for customization from the theme.
Unfortunately, the lines to do not … um… line up and the colors don’t match up with what we’re expecting.
Highlights not lining up for code blocks
After some experimenting with Firefox developer tools, I added the following to the style.css to get the lines to match.
The color for the highlight appears to be incorrect for all the styles that I tested, so I went back to an earlier version of Hugo to get the color and then placed it in the style.css as well.
// GetTitleFunc returns a func that can be used to transform a string to
// title case.
//
// The supported styles are
//
// - "Go" (strings.Title)
// - "AP" (see https://www.apstylebook.com/)
// - "Chicago" (see https://www.chicagomanualofstyle.org/home.html)
//
// If an unknown or empty style is provided, AP style is what you get.
funcGetTitleFunc(stylestring)func(sstring)string{switchstrings.ToLower(style){case"go":returnstrings.Titlecase"chicago":returntransform.NewTitleConverter(transform.ChicagoStyle)default:returntransform.NewTitleConverter(transform.APStyle)}}
You can also link directly to lines (for example, line 213) and it should work. It also scrolls side to side to accommodate the longer lines.
Showing the table of contents
When I get frustrated with code blocks, I look at other aspects of the theme and what’s available in Hugo and Micro.blog. Hugo offers built in table of content short code that can be used in the themes. You can read more about it in the online documentation.
My first idea was that I wanted to have a property that users could turn on to automatically add the table of contents to a post. I came across this feature in the Cards Theme for Micro.blog and thought that it would be a nice feature for those who write a long post.
I create _partial\toc.html with the following code that I would put above the <div> that that contains the contents of an individual post.
Line 2 makes the default state of the table of contents hidden and then line 7 checks to see if Hugo has rendered a <ul> within whatever is in the .TableOfContents class. If it’s true, then line 8 will set the display type to a block; making it visible.
Problem Opportunity
Unfortunately, I ran into a number of issues.
It does not take into account older posts that already have table of contents
Most of my posts about labarum have headers and I do not want to go back and edit all of them. Some users might only want a table of contents that they specify themselves.
It obscures posts that start off with a big “hero” image
I have a couple of posts like this and the floating of the table of contents did not look correct. I will have to come back to this when I’m a little better with CSS.
This technique does not currently work with Firefox
The table of contents does not show up on Firefox. I tried experimenting with different logic to toggle the visibility, but ultimately, I couldn’t get it working. I don’t know how many people are using this theme or how many people come to my site using Firefox, but I really, really want people to be able to read this. NOTE: I wrote this on August 20th, and then the Firefox nightly build enabled the :has flag in build 119. Meaning that this will work soon.
I decided to remove the property and make two different shortcodes for table of contents.
The first one is activated by adding {{ toc }} to your text and will float in the center of the article.
The second one is activated by adding {{ floating-toc }} to your text and will float in the right of the article.
Please note that if you place the short codes at the beginning of the post, it will be part of the .summary.
There were a couple of things that I wanted to add to this release but realized that I was stopping progress. In my last two posts about labarum, I told myself that I wouldn’t wait for perfection to happen.
That being said, here are the things that I have on the roadmap for my next release.
Show the Profile Picture
A couple of the other themes on Micro.blog use the profile picture on the site. I do load this picture in the metadata of the theme’s head and articles but an end user doesn’t see that. Part of this is just me not wanting to show my face and not having it in my initial design for the theme.
Enable Mermaid Diagrams
Hugo natively allows for GoAT diagrams2 which are rendereded as SVGs on the site. To enable mermaid, you have to place something in the theme. I’ll be experimenting with and hopefully find a way so that it doesn’t load the associated javascript library if a user doesn’t want to use it.
I’ll have to read more. I like the idea of having a standard, but I vaguely remember something about why I made the decisions that I did.
CSS responsiveness
Working with my theme makes me appreciate other web developers. Unfortunately, I start comparing my work to others, and comparison is the thief of joy. I’m not happy with a part of the theme that I have. It has to do with how it looks on smaller screens.
The borders on the side complicate the image
Nothing is “wrong” with this, but for some reason, it “does not spark joy”.
I’ll have to take a couple steps back and think about what I want from this.
Break time!
Thank you for getting to the bottom of this article. I certainly hope that you got something out of it.
Please contact me if you have any positive comments or questions!
I have a hard time following “not false” instead of “true”. ↩︎
The name makes it harder than it needs to be to find examples. ↩︎
Doing spelling and grammar checking on a post with a lot of sample code is a definite pain. I’m happy that the post is scheduled and I’ll just sit back and see who finds any new issues.
For fun, I thought I would go over all the browsers that I currently have installed and what I use them for
Brave - Used to have it for browsing comics. Just there because I forgot to delete it
Firefox - I tell my family to use this browser for their general browsing. We share a computer so I keep all my web surfing in other browsers so they don’t mess up by tabs and bookmarks.
Firefox Developer Edition - Web development and testing
Google Chrome - Web testing. I should switch to chromium
Microsoft Edge - Connect to work using this
Safari - General and tech browsing. Allowing me to move from my iMac to my phone. I really like it.
Safari Preview - I also like seeing what Safari is going to be doing in the future.
Orion - Testing Webkit outside of Safari. Also a nice browser to take screenshots of my website theme.
Vivaldi - Media browsing (comics, YouTube, more comics)
This all kind of helps switch my mindset on what I’m doing on the computer because they all look different.
I woke up and then went back to sleep this morning. I’m really exhausted today.
I’m fighting the “shut up and ship it” phase of an update to my theme.