-
Notifications
You must be signed in to change notification settings - Fork 73
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
Add optional for semantic html output #137
base: master
Are you sure you want to change the base?
Conversation
The feature is toggled via `org-static-blog-use-semantic-html`. The output is customizable via `org-static-blog-semantic-html-mapping`. closes bastibe#8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the pull request. The code looks good. But I fear that the mapping of semantic blocks to parts of the structure is not correct.
@@ -39,6 +39,7 @@ | |||
|
|||
;;; Code: | |||
|
|||
(require 'cl-macs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this needed for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cl-destructuring-bind
comes from this package
:safe t) | ||
|
||
(defvar org-static-blog-semantic-html-mapping | ||
'((preamble "header" "id=\"preamble\" class=\"status\"") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that mapping correct? We do have a page header and footer for each page. The preamble and postamble are part of the content really, not of the page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was mostly following your instructions here: #8 (comment)
The preamble and postamble are part of the content really, not of the page.
Mh, I 'm not sure if I understand what you mean by the difference between content and page.
Isn't the preamble and postamble the same for all pages?
org-static-blog/org-static-blog.el
Lines 159 to 167 in 682dbb6
(defcustom org-static-blog-page-preamble "" | |
"HTML to put before the content of each page." | |
:type '(string) | |
:safe t) | |
(defcustom org-static-blog-page-postamble "" | |
"HTML to put after the content of each page." | |
:type '(string) | |
:safe t) |
The structure in the org-static-blog-template
is
- preamble
- content
- postamble
org-static-blog/org-static-blog.el
Lines 396 to 406 in 682dbb6
"<body>\n" | |
"<div id=\"preamble\" class=\"status\">" | |
org-static-blog-page-preamble | |
"</div>\n" | |
"<div id=\"content\">\n" | |
tContent | |
"</div>\n" | |
"<div id=\"postamble\" class=\"status\">" | |
org-static-blog-page-postamble | |
"</div>\n" | |
"</body>\n" |
tContent
is either a single post or a multipost-page.
From https://html.spec.whatwg.org/multipage/sections.html#the-header-element:
The header element represents a group of introductory or navigational aids.
This is how the preamble is currently used in the blogs linked in the README.
Also see the last <header>
example from the spec linked above:
<body>
<header>
<h1>Little Green Guys With Guns</h1>
<nav>
<ul>
<li><a href="/games">Games</a>
<li><a href="/forum">Forum</a>
<li><a href="/download">Download</a>
</ul>
</nav>
<h2>Important News</h2> <!-- this starts a second subsection -->
<!-- this is part of the subsection entitled "Important News" -->
<p>To play today's games you will need to update your client.</p>
<h2>Games</h2> <!-- this starts a third subsection -->
</header>
<p>You have three active games:</p>
<!-- this is still part of the subsection entitled "Games" -->
...
From the <footer>
spec:
The footer element represents a footer for its nearest ancestor sectioning content element, or for the body element if there is no such ancestor. A footer typically contains information about its section such as who wrote it, links to related documents, copyright data, and the like.
When the footer element contains entire sections, they represent appendices, indices, long colophons, verbose license agreements, and other such content.
This is also the usage that I found in the blogs that I had a look at.
(concat (format "<%s %s>" tag attributes) | ||
to-wrap | ||
(format "</%s>\n" tag))) | ||
(concat "<div id=\"preamble\" class=\"status\">" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(concat "<div id=\"preamble\" class=\"status\">" | |
(concat default-wrapper |
Just a heads up, I realized that my changes currently break |
The feature is toggled via
org-static-blog-use-semantic-html
. The output is customizable viaorg-static-blog-semantic-html-mapping
.closes #8
@bastibe I tried to test this with your blog, but had some issues because I'm missing some file includes.
This currently outputs an additional and unnecessary space in the tag, i.e.
<header >
if the attributes in the mapping are empty, but I'm personally fine with that.I haven't added documentation in the README yet because I first wanted to get some feedback on the change.
I don't know if you want to even advertise the customization via
org-static-blog-semantic-html-mapping
.We could make it a
defconst
likeorg-static-blog-texts
to discourage access.