Skip to content

Commit

Permalink
Clean: Axe super duper old code for parallel block
Browse files Browse the repository at this point in the history
  • Loading branch information
Musa Al-hassy committed Dec 24, 2024
1 parent d462959 commit d5a262a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 81 deletions.
84 changes: 9 additions & 75 deletions org-special-block-extras.org
Original file line number Diff line number Diff line change
Expand Up @@ -3722,7 +3722,7 @@ src_latex[:exports code]{\color{blue}} is a nightmare. )
:CUSTOM_ID: Parallel
:END:

osbe-example:~/org-special-block-extras/tests/parallel.yaml
osbe-example:~/org-special-block-extras/tests/parallel.yaml

#+latex_header: \usepackage{multicol}
#+begin_src emacs-lisp -r -n :title Implementation :folded t
Expand Down Expand Up @@ -3796,79 +3796,6 @@ With LaTeX export, the use of ‘#+columnbreak:’ is used to request a column b
(if (s-contains-p " " cols) "</div>" ""))))))))
#+end_src

** COMMENT Older setup :Possibly_delete:
:PROPERTIES:
:CUSTOM_ID: COMMENT-Older-setup
:END:

:Header:
#+BEGIN_SRC emacs-lisp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Parallel blocks: 𝓃parallel[NB] for n:2..5, optionally with ‘N’o ‘b’ar
;; in-between the columns.
;;
;; Common case is to have three columns, and we want to avoid invoking the
;; attribute via org, so making this.
#+END_SRC
:End:

We want to be able to reduce the amount of whitespace noise in our articles, and
so use the =parallel= block to place ideas side-by-side ---with up to the chosen
limit of 5 columns.

#+caption: Displaying thoughts side-by-side ^_^ Top is browser, then Emacs, then PDF
[[file:images/parallel.png]]

#+LATEX_HEADER: \usepackage{multicol}
| =#+LATEX_HEADER: \usepackage{multicol}= |

I initially used the names =parallel𝓃= but names ending with a number =𝓃= did not
inherit highlighting, so I shifted the number to being a prefix instead.
+ For LaTeX, new lines are used to suggest opportunities for column breaks
and are needed even if explicit columnbreaks are declared.
+ Use the nullary switch =:columnbreak:= to request a columnbreak; this has no
effect on HTML export since HTML describes how text should be formatted on a
browser, which can dynamically shrink and grow and thus it makes no sense to have
hard columnbreaks.
+ We also provide ~𝓃parallelNB~ for users who want ‘N’o ‘B’ar separator
between columns.

#+BEGIN_SRC emacs-lisp
(cl-loop for cols in '("1" "2" "3" "4" "5")
do (cl-loop for rule in '("solid" "none")
do (eval (read (concat
"(defun org--" cols "parallel"
(if (equal rule "solid") "" "NB")
"(backend contents)"
"(format (pcase backend"
"(`html \"<div style=\\\"column-rule-style:" rule ";column-count:" cols ";\\\"%s</div>\")"
"(`latex \"\\\\par \\\\setlength{\\\\columnseprule}{" (if (equal rule "solid") "2" "0") "pt}"
" \\\\begin{minipage}[t]{\\\\linewidth}"
" \\\\begin{multicols}{" cols "}"
" %s"
" \\\\end{multicols}\\\\end{minipage}\"))"
"(s-replace \":columnbreak:\" (if (equal 'html backend) \"\" \"\\\\columnbreak\")
contents)))")))))
#+END_SRC
#
# Musa: If I use “<div …> %s</div>”, the ‘>’ causes some undesirable whitespace
# in the first column. Hence, omitting it.

We also use ~parallel~ as an alias for ~2parallel~: The forward declaration is
tangled at the top of the file, whereas the alias declarations are declared upon
mode activation ---after such functions have been declared.
#+BEGIN_SRC emacs-lisp :noweb-ref forward-decls :tangle no
(declare-function org--2parallel "org-special-block-extras" t t)
(declare-function org--2parallelNB "org-special-block-extras" t t)
#+END_SRC
#+BEGIN_SRC emacs-lisp :noweb-ref enable-mode :tangle no
(defalias 'org--parallel
#'org--2parallel)

(defalias 'org--parallelNB
#'org--2parallelNB)
#+END_SRC
* COMMENT  :fire: HTML Export Styles as Links
:PROPERTIES:
:CUSTOM_ID: HTML-Export-Styles-as-Links
Expand Down Expand Up @@ -8363,6 +8290,14 @@ z
#+end_src
#+end_details

* TODO [#A] COMMENT README improvements

Add images for the “osbe-example” results and link to the html,
since otherwise things don't look as nice in a markdown readme file.

#+caption: Displaying thoughts side-by-side ^_^ Top is browser, then Emacs, then PDF
[[file:images/parallel.png]]

* COMMENT Case Studies
** In doubt, a block's main argument should be enclosed in quotes
:PROPERTIES:
Expand Down Expand Up @@ -8422,7 +8357,6 @@ It is said that $e^{i \cdot \pi} + 1 = 0$ is the truth.
#+end_theorem



* TODO [#A] COMMENT Summary
:PROPERTIES:
:CUSTOM_ID: Summary
Expand Down
22 changes: 16 additions & 6 deletions tests/parallel.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
input: |-
Articles can get lengthy when vertical whitespace is wasted on thin
lines; instead, one could save space by using
/[[doc:org-block/parallel][parallel]] columns of text/.
Reduce the amount of whitespace noise in your articles by using the
/[[doc:org-block/parallel][parallel]] block to place ideas
side-by-side ---with up to 𝓃-many columns.
----------------------------------------------------------------------
Expand Down Expand Up @@ -34,12 +34,16 @@ input: |-
# In the Soft Columns style above, any ‘#+columnbreak:’ are merely ignored.
In summary, articles can get lengthy when vertical whitespace is
wasted on thin lines; instead, one could save space by using
/[[doc:org-block/parallel][parallel]] columns of text/.
expectations:
html: |-
<p>
Articles can get lengthy when vertical whitespace is wasted on thin
lines; instead, one could save space by using
<i><abbr class="tooltip" title="Place ideas side-by-side, possibly with a separator.<br><br>There are COLS many columns, and they may be seperated by solid<br>vertical rules if BAR is a non-nil (colour) value.<br><br>+ COLS is either a number or a sequence of the shape: 10% 20% 30%.<br>+ BAR is either ‘t’, ‘nil’, or a colour such as ‘red’ or ‘blue’.<br><br><hr><br><br>“Soft Columns”: Writing “#+begin_parallel 𝓃 :bar t” will produce<br>𝒏-many parallel columns, possibly separated by solid rules, or a<br>“bar”. This style allows text to freely move between columns,<br>depending on the size of the browser, which may dynamically<br>shrink and grow.&emsp;BAR can either be ‘t’, ‘nil’, or<br>any (backend)-valid colour specification; such as ‘red’ or<br>‘green’.<br><br>“Hard Columns”: Alternatively, for non-uniform column widths,<br>COLS may instead be a specification of the widths of the<br>columns. However, this extra flexibility comes at an additional<br>cost: The contents of the block must now contain 𝒏-1 lines<br>consisting of ‘#+columnbreak:’, when the specification determines<br>𝒏 columns, as shown in the following example.<br><br>&emsp; #+begin_parallel 20% 60% 20% :bar green<br>&emsp; Hello, to the left!<br><br>&emsp; #+columnbreak:<br>&emsp; A super duper wide middle margin!<br><br>&emsp; #+columnbreak:<br>&emsp; Goodbye (“God-be-with-ye”) to the right!<br>&emsp; #+end_parallel<br><br>The specification is 𝒏 measurements denoting widths; which may be<br>in any HTML recognisable units; e.g., “5em 20px 30%” is valid.<br>I personally advise only the use of percentage measurements.<br><br>In the Soft Columns style above, any ‘#+columnbreak:’ are merely ignored.<br>With LaTeX export, the use of ‘#+columnbreak:’ is used to request a column break.<br><br>(fn BACKEND RAW-CONTENTS &rest _)">parallel</abbr> columns of text</i>.
Reduce the amount of whitespace noise in your articles by using the
/<abbr class="tooltip" title="Place ideas side-by-side, possibly with a separator.<br><br>There are COLS many columns, and they may be seperated by solid<br>vertical rules if BAR is a non-nil (colour) value.<br><br>+ COLS is either a number or a sequence of the shape: 10% 20% 30%.<br>+ BAR is either ‘t’, ‘nil’, or a colour such as ‘red’ or ‘blue’.<br><br><hr><br><br>“Soft Columns”: Writing “#+begin_parallel 𝓃 :bar t” will produce<br>𝒏-many parallel columns, possibly separated by solid rules, or a<br>“bar”. This style allows text to freely move between columns,<br>depending on the size of the browser, which may dynamically<br>shrink and grow.&emsp;BAR can either be ‘t’, ‘nil’, or<br>any (backend)-valid colour specification; such as ‘red’ or<br>‘green’.<br><br>“Hard Columns”: Alternatively, for non-uniform column widths,<br>COLS may instead be a specification of the widths of the<br>columns. However, this extra flexibility comes at an additional<br>cost: The contents of the block must now contain 𝒏-1 lines<br>consisting of ‘#+columnbreak:’, when the specification determines<br>𝒏 columns, as shown in the following example.<br><br>&emsp; #+begin_parallel 20% 60% 20% :bar green<br>&emsp; Hello, to the left!<br><br>&emsp; #+columnbreak:<br>&emsp; A super duper wide middle margin!<br><br>&emsp; #+columnbreak:<br>&emsp; Goodbye (“God-be-with-ye”) to the right!<br>&emsp; #+end_parallel<br><br>The specification is 𝒏 measurements denoting widths; which may be<br>in any HTML recognisable units; e.g., “5em 20px 30%” is valid.<br>I personally advise only the use of percentage measurements.<br><br>In the Soft Columns style above, any ‘#+columnbreak:’ are merely ignored.<br>With LaTeX export, the use of ‘#+columnbreak:’ is used to request a column break.<br><br>(fn BACKEND RAW-CONTENTS &rest _)">parallel</abbr> block to place ideas
side-by-side &#x2014;with up to 𝓃-many columns.
</p>
<hr />
Expand Down Expand Up @@ -79,6 +83,12 @@ expectations:
</div></div>
<p>
In summary, articles can get lengthy when vertical whitespace is
wasted on thin lines; instead, one could save space by using
<i><abbr class="tooltip" title="Place ideas side-by-side, possibly with a separator.<br><br>There are COLS many columns, and they may be seperated by solid<br>vertical rules if BAR is a non-nil (colour) value.<br><br>+ COLS is either a number or a sequence of the shape: 10% 20% 30%.<br>+ BAR is either ‘t’, ‘nil’, or a colour such as ‘red’ or ‘blue’.<br><br><hr><br><br>“Soft Columns”: Writing “#+begin_parallel 𝓃 :bar t” will produce<br>𝒏-many parallel columns, possibly separated by solid rules, or a<br>“bar”. This style allows text to freely move between columns,<br>depending on the size of the browser, which may dynamically<br>shrink and grow.&emsp;BAR can either be ‘t’, ‘nil’, or<br>any (backend)-valid colour specification; such as ‘red’ or<br>‘green’.<br><br>“Hard Columns”: Alternatively, for non-uniform column widths,<br>COLS may instead be a specification of the widths of the<br>columns. However, this extra flexibility comes at an additional<br>cost: The contents of the block must now contain 𝒏-1 lines<br>consisting of ‘#+columnbreak:’, when the specification determines<br>𝒏 columns, as shown in the following example.<br><br>&emsp; #+begin_parallel 20% 60% 20% :bar green<br>&emsp; Hello, to the left!<br><br>&emsp; #+columnbreak:<br>&emsp; A super duper wide middle margin!<br><br>&emsp; #+columnbreak:<br>&emsp; Goodbye (“God-be-with-ye”) to the right!<br>&emsp; #+end_parallel<br><br>The specification is 𝒏 measurements denoting widths; which may be<br>in any HTML recognisable units; e.g., “5em 20px 30%” is valid.<br>I personally advise only the use of percentage measurements.<br><br>In the Soft Columns style above, any ‘#+columnbreak:’ are merely ignored.<br>With LaTeX export, the use of ‘#+columnbreak:’ is used to request a column break.<br><br>(fn BACKEND RAW-CONTENTS &rest _)">parallel</abbr> columns of text</i>.
</p>
latex: |-
🚫 The LaTex backend is intentionally unmaintained.
🫠 Whoops, there seems to be an error:
Expand Down

0 comments on commit d5a262a

Please sign in to comment.