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

using org special block extras with tufte #20

Closed
ndvanforeest opened this issue Jan 6, 2024 · 7 comments
Closed

using org special block extras with tufte #20

ndvanforeest opened this issue Jan 6, 2024 · 7 comments

Comments

@ndvanforeest
Copy link

For some pages I use https://github.com/alhassy/org-special-block-extras. While this works out of the box with org-html-publish-to-html, it doesn't with org-tufte-publish-to-html. However, it suddenly does work if I replace 'tufte-html by 'html in

(defun` org-tufte-publish-to-html (plist filename pub-dir)
"Publish an org file to Tufte-styled HTML.

PLIST is the property list for the given project. FILENAME is
the filename of the Org file to be published. PUB-DIR is the
publishing directory.

Return output file name."
(ox-tufte--utils-entrypoint-funcall
filename
#'org-publish-org-to 'html filename ; HERE IS MY CHANGE
(ox-tufte--utils-get-export-output-extension plist)
plist pub-dir))

I admit that I don't uderstand why this change works.

@suhail-singh
Copy link
Contributor

#'org-publish-org-to 'html filename ; HERE IS MY CHANGE

When you do the above, you're not longer using ox-tufte. Which begs the
question, why not just use ox-html to begin with?

For some pages I use
https://github.com/alhassy/org-special-block-extras. While this works out of
the box with org-html-publish-to-html, it doesn't with
org-tufte-publish-to-html.

Could you please explain what you mean by "it doesn't [work] with
org-tufte-publish-to-html"? Since I don't use org-special-block-extras I'm
not sure how to test this.

Some minimal examples along with screenshots of the rendered HTML with and
without ox-tufte which highlights your expectation vs reality would be really
helpful.

@ndvanforeest
Copy link
Author

I'll include some screenshots. Here is what I did:

  • I overwrite (defun org-tufte-publish-to-html (plist filename pub-dir) to use #'org-publish-org-to 'html filename
  • I build my site, with the attached build-site.el,
    build-site.txt (BTW, I can't upload this format, so I recalled the file build-site.txt)
    which I call with emacs -Q --script build-site.el
  • The content directory contains the file new_minimal.org, see attached. (which I renamed to new-minimal.txt)
    new_minimal.txt
  • Then $> firefox ~/unsaved/public/new_minimal.html
  • I made two screenshot without_tufte.png and without_tufte_solution_clicked.png
    without_tufte_solution_clicked
    without_tufte

So, (if all is well), you can see an exercise environment that is green. And, in the page you can click on the solution, to see the solution :-) BTW, my present website (which runs on nikola but that I want to port to pure org mode) contains several examples: https://ndvanforeest.github.io/posts/one-cookie/

This works all very well for the exercises, but the sidenotes go wrong.

Now I run the same things as above, but with the org-tufte-publish-to-html as provided by ox-tufte. This gives the screenshot:
with_tufte
Now the nice exercise environment is broken, and the solution is visible without being "behind the solution" buttom.

Hopefully this suffices to explain the problem.

Thanks for all your help.

@suhail-singh
Copy link
Contributor

suhail-singh commented Jan 7, 2024

Thank you for the details. I think I'm starting to understand what's going on.
org-special-block-extras as the name suggests does some special handling of
"special blocks".

With the Org mode file you shared we're almost at a minimal example that I can
use to better understand what's going on. Hopefully with your (further) help
I'm able get a deterministic test.

Test result with ox-html

On my setup without org-special-block-extras installed, evaluating the below
Elisp code:

(org-export-string-as "PRE
#+begin_exercise
QUESTION
#+begin_solution
SOLUTION
#+end_solution
#+end_exercise
POST" 'html t)

Results in:

"<p>
PRE
</p>
<div class=\"exercise\" id=\"orgb7dafd5\">
<p>
QUESTION
</p>
<div class=\"solution\" id=\"org16ff343\">
<p>
SOLUTION
</p>

</div>

</div>
<p>
POST</p>
"

Test result with ox-tufte

With ox-tufte, evaluating below

(org-export-string-as "PRE
#+begin_exercise
QUESTION
#+begin_solution
SOLUTION
#+end_solution
#+end_exercise
POST" 'tufte-html t)

results in:

"<p>
PRE
</p>
<div class=\"exercise\" id=\"orgdc49136\">
<p>
QUESTION
</p>
<div class=\"solution\" id=\"org970f65b\">
<p>
SOLUTION
</p>

</div>

</div>
<p>
POST</p>
"

Help needed: Test result with ox-html when using org-special-block-extras

Could you please share the result of evaluating the below Elisp code when
org-special-block-extras is in use?

(org-export-string-as "PRE
#+begin_exercise
QUESTION
#+begin_solution
SOLUTION
#+end_solution
#+end_exercise
POST" 'html t)

@suhail-singh suhail-singh added this to the 3.0.4 milestone Jan 7, 2024
@suhail-singh suhail-singh removed this from the 3.0.4 milestone Jan 7, 2024
@ndvanforeest
Copy link
Author

ndvanforeest commented Jan 8, 2024 via email

@suhail-singh
Copy link
Contributor

Thank you for that. It's clear that org-special-block-extras is doing some
additional things when the export backend is 'html.

Looking at the code for org-special-block-extras.el,
I noticed a few occurrences of (equal backend 'html). At the very least these
would need to be amended to something like
(org-export-derived-backend-p backend 'html) instead.

It's not clear to me that the above change alone would be sufficient to address
matters, but it seems like it would be necessary. In any case the issue, as far
as I understand it, seems to be in org-special-block-extras' handling of its
"guards".

Have you tried reaching out to the author/maintainer of
org-special-block-extras?

@ndvanforeest
Copy link
Author

ndvanforeest commented Jan 8, 2024 via email

@suhail-singh
Copy link
Contributor

However, I don't need most of the fancy stuff that the -extras package offers.

You'll be able to get the necessary structure via an Org mode file that looks
something like below:

#+HTML_HEAD: <link rel="stylesheet" href="/path/to/tufte.css" type="text/css" />
#+HTML_HEAD: <link rel="stylesheet" href="/path/to/ox-tufte.css" type="text/css" />

PRE
#+begin_details
#+begin_summary
SUMMARY
#+end_summary
DETAILS
#+end_details
POST

Exporting the above via something like C-c C-e T h should result in an HTML
page with collapsible DETAILS.

The CSS will likely need some tweaks, some of which (e.g., those relating to
margins, spacing, layout etc) can probably be incorporated into ox-tufte.
Patches would be welcome!

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

No branches or pull requests

2 participants