From 2584df53ee18b84597c566006d85b06c13387783 Mon Sep 17 00:00:00 2001
From: cb341
{{ page.description }}
{% endif %} -- {% if page.date %}{% endif %} +
+
- {%- if page.date %} {% endif %}
+
Source
{%- if page.raw_url %}
Markdown
diff --git a/_plugins/raw_markdown.rb b/_plugins/raw_markdown.rb
index f7fcdc7..c29c4b6 100644
--- a/_plugins/raw_markdown.rb
+++ b/_plugins/raw_markdown.rb
@@ -1,37 +1,12 @@
require "fileutils"
module RawMarkdown
- FRONT_MATTER = /\A---[ \t]*\r?\n.*?^---[ \t]*\r?\n/m
-
def self.pages(site)
pages = site.pages + site.collections.values.flat_map(&:docs).select(&:write?)
pages.select do |page|
page.url != "/" && File.extname(page.path.to_s).casecmp(".md").zero?
end
end
-
- def self.with_document_header(page, source, date_format)
- front_matter = source.match(FRONT_MATTER)
- return source unless front_matter
-
- body = source[front_matter.end(0)..].sub(/\A(?:\r?\n)*/, "")
- title = page.data["title"]
- return body unless title
-
- date = page.data["date"]&.strftime(date_format)
-
- if body.start_with?("# ")
- return body unless date
-
- heading, rest = body.split(/\r?\n/, 2)
- rest = rest&.sub(/\A(?:\r?\n)*/, "")
- body = [heading, date, rest].compact.join("\n\n")
- else
- body = ["# #{title}", date, body].compact.join("\n\n")
- end
-
- body
- end
end
Jekyll::Hooks.register :site, :post_read do |site|
@@ -45,8 +20,10 @@ def self.with_document_header(page, source, date_format)
source_path = File.expand_path(page.path, site.source)
raw_path = File.join(site.dest, page.data.fetch("raw_url").delete_prefix("/"))
FileUtils.mkdir_p(File.dirname(raw_path))
- source = File.read(source_path)
- date_format = site.config.fetch("date_format", "%Y-%m-%d")
- File.write(raw_path, RawMarkdown.with_document_header(page, source, date_format))
+ body = File.read(source_path).sub(/\A---[ \t]*\r?\n.*?^---[ \t]*\r?\n/m, "").lstrip
+ heading, body = body.split(/\r?\n/, 2) if body.start_with?("# ")
+ heading ||= "# #{page.data.fetch("title")}"
+ date = page.data["date"]&.strftime(site.config.fetch("date_format", "%Y-%m-%d"))
+ File.write(raw_path, [heading, date, body&.lstrip].compact.join("\n\n"))
end
end
diff --git a/bin/pdf.css b/bin/pdf.css
index bbb78b1..343e017 100644
--- a/bin/pdf.css
+++ b/bin/pdf.css
@@ -18,43 +18,35 @@
.wrapper { max-width: none; margin: 0; padding: 0; }
.article-title {
- margin: 0;
- padding: 0;
- border: 0;
+ margin: 0 0 7mm;
+ padding: 0 0 3.5mm;
}
.article-title h1 {
max-width: 15cm;
margin: 0;
- font-size: 27pt;
+ font-size: 28pt;
line-height: 1.05;
letter-spacing: -.025em;
}
.article-title > hr {
- display: block;
- margin: 3.5mm 0 7mm;
- border: 0;
- border-top: .35mm solid #222;
+ display: none;
}
.print-description {
display: block;
- margin: 3mm 0 4mm;
+ margin: 3mm 0;
color: #444;
- font-size: 13pt;
- line-height: 1.3;
+ font-size: 12pt;
}
- .article-details { margin: 0; }
.article-formats { display: none; }
.print-date {
display: block;
margin: 0;
- color: #555;
- font-size: 8.5pt;
+ color: #666;
+ font-size: 8pt;
}
- body > .skip-link,
- body > .wrapper > header,
- footer,
- nav[aria-label="Article formats"],
+ header[role="banner"],
+ footer[role="contentinfo"],
nav[aria-label="Post navigation"] { display: none; }
main a { color: #000; text-decoration: underline; }
From 2a8ccdbc8aaf6e8254a6016191a4bce461390d52 Mon Sep 17 00:00:00 2001
From: cb341