diff --git a/org-special-block-extras.org b/org-special-block-extras.org index a55f260..5d8cc04 100644 --- a/org-special-block-extras.org +++ b/org-special-block-extras.org @@ -13,6 +13,28 @@ html-export-style:solarized_light + +#+RESULTS: +: kill-buffer-and-window + +#+name: startup-code +#+begin_src emacs-lisp :exports none :tangle no :exports none +(org-docs-load-libraries (list "~/org-special-block-extras/documentation.org")) +#+end_src + +# MA: TODO: Margin blocks produce extra newlines! + +# TODO: Make org-defblock looks almost the same as cl-defun, namely argslist has args being either pairs or singletons! + +# TODO: Since the implementation is a find-replace, nested blocks do not honor enclosing blocks. +# For example, try placing a `rename` block within an `example` block and see that it is expanded! + + Look: +# 1. osbe-example:~/org-special-block-extras/tests/doc.yaml +# 2. osbe-example:~/org-special-block-extras/tests/rename.yaml + +* COMMENT Run all /unit/ tests + # TODO C-c C-c ⇒ Run all tests, and see them printed with their descriptions nicely. #+begin_src emacs-lisp :exports none :tangle no ;; Press ‘q’ to kill the resulting buffer and window. @@ -37,16 +59,6 @@ html-export-style:solarized_light ) #+end_src -#+RESULTS: -: kill-buffer-and-window - -#+name: startup-code -#+begin_src emacs-lisp :exports none :tangle no :exports none -(org-docs-load-libraries (list "~/org-special-block-extras/documentation.org")) -#+end_src - -# MA: TODO: Margin blocks produce extra newlines! - * HTML & LaTeX Setup :ignore: :PROPERTIES: :CUSTOM_ID: HTML-LaTeX-Setup @@ -285,7 +297,7 @@ Disable this behaviour by setting `org-special-block-add-html-extra' to `nil'. # # # See https://github.com/alhassy/emacs.d#what-does-literate-programming-look-like -* Testing :noexport: +* COMMENT Testing :noexport: :PROPERTIES: :CUSTOM_ID: Testing :END: @@ -479,7 +491,7 @@ jobs: # Upload coverage - uses: codecov/codecov-action@v1 -* Test that this org file itself exports without problems :noexport: +* COMMENT Test that this org file itself exports without problems :noexport: :PROPERTIES: :CUSTOM_ID: Test-that-this-org-file-itself-exports-without-problems :END: @@ -506,7 +518,7 @@ jobs: (should (org-html-export-to-html))) #+end_src -* Abstract :ignore: +* COMMENT Abstract :ignore: :PROPERTIES: :CUSTOM_ID: Abstract :END: @@ -669,7 +681,7 @@ and the result looks nice. “Look ma, no HTML required!” #+caption: Write in Emacs using Org-mode, export beautifully to HTML or LaTeX [[file:images/minimal-working-example-multiforms.png]] -* org-tutorial :ignore: +* COMMENT org-tutorial :ignore: :PROPERTIES: :CUSTOM_ID: org-tutorial :END: @@ -691,7 +703,7 @@ Installation instructions are [[#Summary][below]]. #+end_quote #+latex: \newpage -* A unified interface for special blocks and links: ~defblock~ +* COMMENT A unified interface for special blocks and links: ~defblock~ :PROPERTIES: :CUSTOM_ID: A-unified-interface-for-special-blocks-and-links-defblock :END: @@ -1826,7 +1838,7 @@ Three example uses: (main-arg-value (cl-second kwds)) (kwds (cddr kwds))) ;; Unless we've already set the docs for the generic function, don't re-declare it. - `(if ,(null body) + `(progn ;; if ,(null body) (cl-defgeneric ,(intern (format "org-block/%s" name)) (backend raw-contents &rest _) ,docstring) @@ -3319,7 +3331,7 @@ Such “open methods” are known as “multimethods”; e.g., see doc:cl-defgen #+end_src :End: -* Folded Details ---As well as boxed text and subtle colours +* COMMENT Folded Details ---As well as boxed text and subtle colours :PROPERTIES: :CUSTOM_ID: Folded-Details :END: @@ -3705,21 +3717,18 @@ src_latex[:exports code]{\color{blue}} is a nightmare. ) It may be useful to /fuse/ the ~box~ and ~details~ concepts into one. Something for future me ---or another contributor--- to think about ;-) -* Parallel +* Parallel ---/Place ideas side-by-side, possibly with a separator/ :PROPERTIES: :CUSTOM_ID: Parallel :END: - Articles can get lengthy when vertical whitespace is wasted on thin lines; - instead, one could save space by using /[[doc:org--parallel][parallel]] columns of text/. - -#+latex_header: \usepackage{multicol} -#+begin_center -Requires: src_latex[:exports code]{#+latex_header: \usepackage{multicol}} -#+end_center +# (setq osbe-example-yaml-cache (make-hash-table :test 'equal)) + osbe-example:~/org-special-block-extras/tests/parallel.yaml + +#+latex_header: \usepackage{multicol} #+begin_details Implementation - #+begin_src emacs-lisp -r -n +#+begin_src emacs-lisp -r -n (org-defblock parallel (cols "2" bar nil) "Place ideas side-by-side, possibly with a separator. @@ -3780,134 +3789,17 @@ With LaTeX export, the use of ‘#+columnbreak:’ is used to request a column b (columnBreak (lambda (width omit-rule?) (format "
%s
The ~rename~ block is for Textual Substitution. For example, as a translation tool: + + #+begin_rename "Allah to God, Yacoub to Jacob, Yusuf to Joseph" + Quran 12-4: *_Yusuf_* said to his father ( _*Yacoub*_ ), /“O my father, + indeed I have seen (in a dream) eleven stars and the sun and the + moon; I saw them prostrating to me.”/ + #+end_rename + + In the rendered result, the Arabic names are replaced with their English counterparts.+ html: |- +
+ Look: +
+ +The ~rename~ block is for Textual Substitution. For example, as a translation tool: + + #+begin_rename "Allah to God, Yacoub to Jacob, Yusuf to Joseph" + Quran 12-4: *_Yusuf_* said to his father ( _*Yacoub*_ ), /“O my father, + indeed I have seen (in a dream) eleven stars and the sun and the + moon; I saw them prostrating to me.”/ + #+end_rename + + In the rendered result, the Arabic names are replaced with their English counterparts.+ latex: |- + Look: + +
The ~rename~ block is for Textual Substitution. For example, as a translation tool: + + #+begin_rename "Allah to God, Yacoub to Jacob, Yusuf to Joseph" + Quran 12-4: *_Yusuf_* said to his father ( _*Yacoub*_ ), /“O my father, + indeed I have seen (in a dream) eleven stars and the sun and the + moon; I saw them prostrating to me.”/ + #+end_rename + + In the rendered result, the Arabic names are replaced with their English counterparts.diff --git a/tests/parallel.yaml b/tests/parallel.yaml index bbf4cd6..1e15ef7 100644 --- a/tests/parallel.yaml +++ b/tests/parallel.yaml @@ -1,185 +1,88 @@ input: |- - In the HTML Export, The result is 2 columns with no rule between - them and it contains the user's text, but ignores the - “#+columnbreak”. - - #+begin_parallel - Hello, to the left! - - #+columnbreak: - A super duper wide middle margin! - - - #+columnbreak: - Goodbye (“God-be-with-ye”) to the right! - - #+columnbreak: - woah + 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/. + + ---------------------------------------------------------------------- + + #+begin_parallel 2 + *“Soft Columns”:* Writing ~#+begin_parallel 𝓃 :bar BAR~ will produce + 𝒏-many parallel columns, possibly separated by solid rules, or a + “bar”. /This style allows text to freely move between columns, + depending on the size of the browser, which may dynamically shrink + and grow./ The value ~BAR~ can either be ~t~, ~nil~, or any + (backend)-valid colour specification; such as ~red~ or ~green~. #+end_parallel + ---------------------------------------------------------------------- - [Soft Columns] Below, the result is 2 columns with a solid BLACK - rule between them and it contains the user's text, but ignores the - “#+columnbreak”. + #+begin_parallel 25% 50% 25% :bar green - #+begin_parallel 2 :bar t - X + *“Hard Columns”:* Alternatively, /for non-uniform column widths, 𝓃 may + instead be a specification of the widths of the columns./ - #+columnbreak: - - Y - - Z - #+end_parallel - - - [Hard Columns] The result is 3 columns with a solid GREEN rule - between them and it contains the user's text along with the - “#+columnbreak” evaluated at the expected positions. - #+begin_parallel 20% 60% 20% :bar green X + #+columnbreak: + However, this extra flexibility comes at an additional cost: The + contents of the block must now contain /𝓃-1/ lines consisting of + ~#+columnbreak:~, when the specification determines 𝓃-many columns. #+columnbreak: + Goodbye (“God-be-with-ye”) to the right! - Y + #+end_parallel - #+columnbreak: + # Moreover: + # → In the Soft Columns style above, any ‘#+columnbreak:’ are merely ignored. + # → With LaTeX export, the use of ‘#+columnbreak:’ is used to request a column break. + # \usepackage{multicol} - Z - #+end_parallel -no-prettier: t expectations: html: |-
- In the HTML Export, The result is 2 columns with no rule between - them and it contains the user's text, but ignores the - “#+columnbreak”. -
- -- Hello, to the left! -
- -- A super duper wide middle margin! -
- - -- Goodbye (“God-be-with-ye”) to the right! -
- -- woah -
- -- [Soft Columns] Below, the result is 2 columns with a solid BLACK - rule between them and it contains the user's text, but ignores the - “#+columnbreak”. -
- -- X + Articles can get lengthy when vertical whitespace is wasted on thin + lines; instead, one could save space by using + parallel columns of text.
-- Y -
+
- Z
+ “Soft Columns”: Writing #+begin_parallel 𝓃 :bar BAR
will produce
+ 𝒏-many parallel columns, possibly separated by solid rules, or a
+ “bar”. This style allows text to freely move between columns,
+ depending on the size of the browser, which may dynamically shrink
+ and grow. The value BAR
can either be t
, nil
, or any
+ (backend)-valid colour specification; such as red
or green
.
- [Hard Columns] The result is 3 columns with a solid GREEN rule - between them and it contains the user's text along with the - “#+columnbreak” evaluated at the expected positions. -
--
- Y +
@@html:</div><div style="width: 25%; margin: 10px; border-right:4px none; float: left;">@@
, when the specification determines 𝓃-many columns.
-
- Z -
-