Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert "Deterministic builds with clang and lld" to Markdown #63

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

DavidSpickett
Copy link
Contributor

Fixes #52

Sort of. Articles pre-sometime in 2020 are in HTML form and with https://github.com/JohannesKaufmann/html-to-markdown they convert pretty well but not enough to mass convert them.

But since I put the effort into trying it I figured I would clean up this one that had been (rightly) complained about.

I used a script to reformat the header, html2markdown to convert and then added back some plain text/monospace/code markers where they had been missed, and removed some escapes that got added because those plaintext bits weren't marked properly.

Now that it's Markdown, Hugo's theme will apply and produce the right colours for light and dark mode. The URL of the post will be the same.

Fixes llvm#52

Sort of. Articles pre-sometime in 2020 are in HTML form and with
https://github.com/JohannesKaufmann/html-to-markdown they convert
pretty well but not enough to mass convert them.

But since I put the effort into trying it I figured I would clean
up this one that had been noticed.

I used a script to reformat the header, html2markdown to
convert and then added back some plain text/monospace/code markers
where they had been missed, and removed some escapes that got added
because those plaintext bits weren't marked properly.

Now that it's Markdown, Hugo's theme will apply and produce the
right colours for light and dark mode.

The URL of the post will be the same.
@DavidSpickett DavidSpickett marked this pull request as ready for review November 15, 2024 15:53
@DavidSpickett
Copy link
Contributor Author

The orginal author is Nico Weber and I can't add reviewers here, or @ them, so I'll send them an email instead.

@asl
Copy link
Contributor

asl commented Nov 15, 2024

@nico

@nico
Copy link

nico commented Nov 15, 2024

Thanks for the PR!

Is there a way to preview how the md file will appear on the blog?

@asl
Copy link
Contributor

asl commented Nov 15, 2024

@nico Yes, you'd need to clone the repo, and then run the local hugo instance.

@DavidSpickett
Copy link
Contributor Author

https://github.com/llvm/llvm-blog-www?tab=readme-ov-file#building-locally

@nico
Copy link

nico commented Nov 18, 2024

https://github.com/llvm/llvm-blog-www?tab=readme-ov-file#building-locally

I tried following that and got

ERROR deprecated: .Site.Author was deprecated in Hugo v0.124.0 and will be removed in Hugo 0.140.0. Implement taxonomy 'author' or use .Site.Params.Author instead.
ERROR render of "section" failed: "/Users/thakis/src/llvm-blog-www/themes/hugo-kiera/layouts/_default/baseof.html:6:3": execute of template failed: template: _default/list.html:6:3: executing "_default/list.html" at <partialCached "footer" .>: error calling partialCached: "/Users/thakis/src/llvm-blog-www/themes/hugo-kiera/layouts/partials/footer.html:21:11": execute of template failed: template: partials/footer.html:21:11: executing "partials/footer.html" at <.Site.GoogleAnalytics>: can't evaluate field GoogleAnalytics in type page.Site
ERROR render of "page" failed: "/Users/thakis/src/llvm-blog-www/themes/hugo-kiera/layouts/_default/single.html:4:3": execute of template failed: template: _default/single.html:4:3: executing "main" at <partial "single_footer" .>: error calling partial: "/Users/thakis/src/llvm-blog-www/themes/hugo-kiera/layouts/partials/single_footer.html:20:15": execute of template failed: template: partials/single_footer.html:20:15: executing "partials/single_footer.html" at <.Site.DisqusShortname>: can't evaluate field DisqusShortname in type page.Site

Maybe https://github.com/llvm/llvm-blog-www?tab=readme-ov-file#building-locally could mention which version of hugo should be used?

Also, maybe some additional setup step is needed for that GoogleAnalytics error?

(I'm using hugo v0.139.0-dacef0df92a9a20072b4eaa42003e1a63ace8f41 darwin/arm64 BuildDate=2024-11-18T16:17:45Z VendorInfo=gohugoio, which is what one gets when downloading hugo from their website today.)

@nico
Copy link

nico commented Nov 18, 2024

I got it working locally with this diff

diff
% git diff
diff --git a/themes/hugo-kiera/layouts/_default/rss.xml b/themes/hugo-kiera/layouts/_default/rss.xml
index 76945ef4..fcb82469 100644
--- a/themes/hugo-kiera/layouts/_default/rss.xml
+++ b/themes/hugo-kiera/layouts/_default/rss.xml
@@ -8,9 +8,9 @@
    <link>{{ .Permalink }}</link>
    <description>Recent content {{ if ne  .Title  .Site.Title }}{{ with .Title }}in {{.}} {{ end }}{{ end }}on {{ .Site.Title }}</description>
    <generator>Hugo -- gohugo.io</generator>{{ with .Site.LanguageCode }}
-   <language>{{.}}</language>{{end}}{{ with .Site.Author.email }}
-   <managingEditor>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</managingEditor>{{end}}{{ with .Site.Author.email }}
-   <webMaster>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</webMaster>{{end}}{{ with .Site.Copyright }}
+   <language>{{.}}</language>{{end}}{{ with .Site.Params.Author.email }}
+   <managingEditor>{{.}}{{ with $.Site.Params.Author.name }} ({{.}}){{end}}</managingEditor>{{end}}{{ with .Site.Params.Author.email }}
+   <webMaster>{{.}}{{ with $.Site.Params.Author.name }} ({{.}}){{end}}</webMaster>{{end}}{{ with .Site.Copyright }}
    <copyright>{{.}}</copyright>{{end}}{{ if not .Date.IsZero }}
    <lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
    {{ with .OutputFormats.Get "RSS" }}
@@ -21,7 +21,7 @@
        <title>{{ .Title }}</title>
        <link>{{ .Permalink }}</link>
        <pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
-       {{ with .Site.Author.email }}<author>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</author>{{end}}
+       {{ with .Site.Params.Author.email }}<author>{{.}}{{ with $.Site.Params.Author.name }} ({{.}}){{end}}</author>{{end}}
        <guid>{{ .Permalink }}</guid>
        <description>{{ .Content | replaceRE `[\x00-\x1F\x7F]` "" | html}}</description>
      </item>
diff --git a/themes/hugo-kiera/layouts/partials/footer.html b/themes/hugo-kiera/layouts/partials/footer.html
index 9c6d9966..57cae6f3 100644
--- a/themes/hugo-kiera/layouts/partials/footer.html
+++ b/themes/hugo-kiera/layouts/partials/footer.html
@@ -18,9 +18,6 @@
     </footer>
 </div>
 <script src="{{ "js/scripts.js" | relURL }}"></script>
-{{ if .Site.GoogleAnalytics }}
-  {{ template "_internal/google_analytics.html" . }}
-{{ end }}
 {{ partial "user_footer" . }}
 </body>
 
diff --git a/themes/hugo-kiera/layouts/partials/header.html b/themes/hugo-kiera/layouts/partials/header.html
index 6ccdbb9b..8beb6e28 100644
--- a/themes/hugo-kiera/layouts/partials/header.html
+++ b/themes/hugo-kiera/layouts/partials/header.html
@@ -23,9 +23,9 @@
           {{ end }}
         {{- end -}}
         {{- range .Site.Data.social.social_icons -}}
-          {{- if isset $.Site.Author .id }}
+          {{- if isset $.Site.Params.Author .id }}
              <li>
-               <a href="{{ printf .url (index $.Site.Author .id) }}" title="{{ .title }}">
+               <a href="{{ printf .url (index $.Site.Params.Author .id) }}" title="{{ .title }}">
                <i class="{{ .icon }} fa-lg"></i>
                </a>
              </li>
diff --git a/themes/hugo-kiera/layouts/partials/meta.html b/themes/hugo-kiera/layouts/partials/meta.html
index a3bc5fad..23e71930 100644
--- a/themes/hugo-kiera/layouts/partials/meta.html
+++ b/themes/hugo-kiera/layouts/partials/meta.html
@@ -1,7 +1,7 @@
 <meta charset="utf-8" />
 <meta name="viewport" content="width=device-width, initial-scale=1" />
 <meta name="description" content="{{ .Site.Params.description | default "The HTML5 Herald" }}" />
-<meta name="author" content="{{ .Params.Author | default .Site.Author.name }}" />
+<meta name="author" content="{{ .Params.Author | default .Site.Params.Author.name }}" />
 {{- with .OutputFormats.Get "rss" -}}
         {{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }}
 {{- end -}}
diff --git a/themes/hugo-kiera/layouts/partials/single_footer.html b/themes/hugo-kiera/layouts/partials/single_footer.html
index 000dbd88..edddfc50 100644
--- a/themes/hugo-kiera/layouts/partials/single_footer.html
+++ b/themes/hugo-kiera/layouts/partials/single_footer.html
@@ -17,8 +17,5 @@
     {{ if .Site.Params.UtterancesRepo }}
         {{ partial "utterances" . }}
     {{ end }}
-    {{ if .Site.DisqusShortname }}
-        {{ partial "disqus" . }}
-    {{ end }}
   {{ end }}
 {{ end }}

It'd be nice if it worked without local tweaking, though.

Copy link

@nico nico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for doing this! This looks good except for a few small things below, and for one larger issue: IIRC I added the yellow highlighting back then to highlight all the flags and important parts that one should use, so that it's easy to scroll quickly through the document and see the "what should I actually do" bits. I don't know if we have something for that.

I suppose markdown has **foo** for highlighting, and maybe hugo makes it possible to set background-color on whatever class strong in markdown generates, and that could be set depending on light or dark mode? I don't know how that's usually done. (e.g. "Do not use these flags" was marked for emphasis, as were a bunch of flags.)

More of a question than a comment: It looks like this does one line of text per paragraph. Is that how all the md files look in this repo?

Also, I've been meaning to update the post with some new things for a long time, but it's good to do a clean conversion without any other changes first.

@DavidSpickett
Copy link
Contributor Author

I got it working locally with this diff

I'm using Hugo v0.119.0 so I didn't see this issue. There hasn't been a change to the theme in a long time (https://github.com/avianto/hugo-kiera) so I think we'd be ok patching it in this repo instead.

I can do that if you like, if you don't mind me starting from your diff?

IIRC I added the yellow highlighting back then to highlight all the flags and important parts that one should use, so that it's easy to scroll quickly through the document and see the "what should I actually do" bits. I don't know if we have something for that.

We can use HTML tags in Markdown, as long as we choose one that will be readable in a dark theme. I see there is a <mark>Marked text</mark>. I will try that.

More of a question than a comment: It looks like this does one line of text per paragraph. Is that how all the md files look in this repo?

I think this is just what the converter decided to do. Markdown can be same line or multiple and it'll treat it as one either way.

I can 80 column break it if you like, but perhaps I do that once I've fixed the other things?

@nico
Copy link

nico commented Nov 18, 2024

I can do that if you like, if you don't mind me starting from your diff?

Sure, thanks :) That was just local hacks to get things building though. I'm guessing we might not want to remove GoogleAnalytics on the actual page? (Don't know though.)

I think this is just what the converter decided to do. Markdown can be same line or multiple and it'll treat it as one either way.

I can 80 column break it if you like, but perhaps I do that once I've fixed the other things?

No strong opinion, do whatever you think works best in this repo.

Maybe git diffs look a bit better (including on github) if paragraphs are split over several lines, but up to you.

@DavidSpickett
Copy link
Contributor Author

We can use HTML tags in Markdown, as long as we choose one that will be readable in a dark theme. I see there is a Marked text. I will try that.

I've done this, it works well for light and dark themes.

Except for the ml.py link which comes out white link text on yellow background, so I've highlighted the text that follows it instead.

There is also a note at the start so the reader knows why bits of the text are formatted this way (it was not obvious to me at least).

@DavidSpickett
Copy link
Contributor Author

No strong opinion, do whatever you think works best in this repo.

I had a go at it but I think it comes down to what's best for the person editing it. An 80 column wrap is a waste of space on a wide screen and the rendered copy will be automatically wrapped anyway. You're the author so you can wrap it later if it helps you make changes.

@DavidSpickett
Copy link
Contributor Author

2 ways to be compatible with latest Hugo versions:
#64
#65

Copy link

@nico nico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Code-formatted text is white on a white background, making it hard to see
3 participants