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

Add optional for semantic html output #137

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fapdash
Copy link

@fapdash fapdash commented Aug 25, 2024

The feature is toggled via org-static-blog-use-semantic-html. The output is customizable via
org-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 like org-static-blog-texts to discourage access.

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
Copy link
Owner

@bastibe bastibe 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 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)
Copy link
Owner

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?

Copy link
Author

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\"")
Copy link
Owner

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.

Copy link
Author

@fapdash fapdash Aug 26, 2024

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?

(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

"<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\">"
Copy link
Author

Choose a reason for hiding this comment

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

Suggested change
(concat "<div id=\"preamble\" class=\"status\">"
(concat default-wrapper

@fapdash
Copy link
Author

fapdash commented Sep 1, 2024

Just a heads up, I realized that my changes currently break org-static-blog-get-post-content.

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.

HTML5 semantic elements
2 participants