chdemko / pandoc-latex-environment

Pandoc filter for adding LaTeX environement on specific div
https://pandoc-latex-environment.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
33 stars 9 forks source link

Allow multiple classes for a given environment #20

Open daamien opened 1 month ago

daamien commented 1 month ago

Hi !

Thanks for this filter this is very useful combined with awesomebox !

We would like to submit the following improvement : For a given environment, we would like to allow users to provide differents classes which would synonyms.

As far a I understand currently all the classes must be present to create en environment

---                           
pandoc-latex-environment:
  noteblock:  [class1, class2]
---

::: {.class2 .class1}
This is a noteblock
:::

We'd like to introduce a parameter named match_any_class to allow creating environment where at least one class is defined

---                           
pandoc-latex-environment:
  match_any_class: true
  noteblock:  [class1, class2]
---

::: { .class1 }
This is a noteblock
:::

::: class2
This is another noteblock
:::

the default value of match_any_class would be false to maintain backward compatibilty.

We are willing to sumbit a patch for this, if you're ok with this design...

chdemko commented 4 weeks ago

I'm not against the idea if it makes things easier for users. However, I'm thinking more along the lines of this syntax:

pandoc-latex-environment:
  noteblock: [class1, class2]

means that class1 and class2 must be present which could be a shortcut for:

pandoc-latex-environment:
  noteblock: [[class1], [class2]]
pandoc-latex-environment:
  noteblock:  [[class1, class2]]

could signify class1 or class2

And BTW,

pandoc-latex-environment:
  noteblock: [[class1, class2], class3]

which could be a shortcut for

pandoc-latex-environment:
  noteblock: [[class1, class2], [class3]]

could mean (class1 or class2) and class3

daamien commented 1 week ago

Hi @chdemko !

Thanks for the quick reply.

I agree that this new syntax is more expressive and more elegant. But I fear that it may not be very explicit for end users. I first, it's not clear that [[class1, class2], class3] means (class1 or class2) and class3, at least for me.

Anyway the problem is less urgent for us now, we have found a workaround by defining the same environment twice with 2 different names

pandoc-latex-environment:
  class1block: [class1]
  class2block: [class2]

header-includes:
- |
  \usepackage{awesomebox}
  \newenvironment{class1block}%
  {\begin{awesomeblock}[violet]{\aweboxrulewidth}{\faRocket}{violet}}
  {\end{awesomeblock}}
  \newenvironment{class2block}%
  {\begin{awesomeblock}[violet]{\aweboxrulewidth}{\faRocket}{violet}}
  {\end{awesomeblock}}

This is ugly but it's dead simple. So we'll stick to this and won't invest more time on other solutions.

Thanks for your time and the great work you do on those pandoc filters.

Feel free to close this issue at any time.