suitable macros for Pandoc custom styles for paragraphs, spans and tables
Hello list, I started a topic in Pandoc discussions (see https://github.com/jgm/pandoc/discussions/10208) about custom styles in pandoc tables. This is the framework: - in Pandoc, some textual elements have a "custom-style" attribute, whose value becomes the name of a paragraph or character style in DOCX, ICML or ODT when exported to those formats - e.g. when you have a Span with custom-style="myStyle" around some inline text, you'll get a character style "myStyle" in those formats - for paragraphs, it's a bit different: since they have no attributes in Pandoc, you set the "custom-style" attribute of a surrounding Div element, then all the paragraphs inside it will get that custom paragraph style in DOCX, ICML or ODT - for DOCX output you may set a "custom-style" attribute also in tables Why not using that information about custom styles for ConTeXt output too? I started from the last ones (tables), suggesting that a Table element with a "custom-style" attribute set to "myStyle" could be output in ConTeXt as: \startxtable[myStyle] (Currently, tables converted to ConTeXt by Pandoc start only with a "\startxtable" line) That's doable, because ConTeXt does not terminate with an error, when it encounters a \startxtable[myStyle] not preceded by a \definextable[myStyle]. Then JGM, Pandoc's main author, replied that it would be weird having custom styles for tables and not for spans or paragraphs in ConTeXt output. Good point. In ConTeXt, there are many ways to specify what in Word and LibreOffice are "character" and "paragraph" styles. For example, \definehighlight is suitable for character styles. Badumont, in the pandoc discussion, suggested \definestartstop; good, though you should be careful not to specify a custom style with the same name of an existing environment (e.g. "narrower"); maybe a prefix like "CS" could be a workaround, so that "myStyle" becomes "CSmyStyle", and also "narrower" becomes a less dangerous "CSnarrower". Also, in this case, Pandoc should prepend a \definestartstop[CSmyStyle] before \startCSmyStyle, otherwise ConTeXt would terminate with an error (I think this is doable in Pandoc code, anyways). (BTW, the wiki says \definestartstop is "used to define block level commands": does it mean it can't be suitable for spans of inline text in a paragraph?) Any ideas to specify paragraph and character styles? Massi
Am 24.09.24 um 00:08 schrieb mf:
Any ideas to specify paragraph and character styles?
I’d use \definehighlight for character styles and \defineparagraph for par styles. For the latter to work, you must add \startparagraph … \stopparagraph around each. Not to be confused with \startparagraphs (plural), which is a columns mechanism. Documentation in the wiki is still lacking (was missing until a few minutes ago). Hraban
Il 24/09/24 09:04, Henning Hraban Ramm ha scritto:
Am 24.09.24 um 00:08 schrieb mf:
Any ideas to specify paragraph and character styles?
I’d use \definehighlight for character styles and \defineparagraph for par styles.
For the latter to work, you must add \startparagraph … \stopparagraph around each. Not to be confused with \startparagraphs (plural), which is a columns mechanism. Documentation in the wiki is still lacking (was missing until a few minutes ago).
Hraban
I'm posting here the solution I got from Wolfgang: --------------------------------------------------------- You can try the the \start command which accepts an optional argument which expands to the environment given by the argument when available. When there is no environment with the given name the command pair results in a local group for the content between them. In the following example the first line ignores the argument of \start because no \startimportant environment exists at this point. The second line on the other hand gets formatted because I used \definestartstop to define the \startimportant environment. %%%% begin example \starttext before \start[important]inbetween\stop{} after \definestartstop [important] [color=red,style=bold] before \start[important]inbetween\stop{} after \stoptext %%%% end example Wolfgang --------------------------------------------------------- I reported this solution in the original Pandoc's discussion forum. Thanks Hraban and Wolfgang. Massi
participants (2)
-
Henning Hraban Ramm
-
mf