ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* [NTG-context] suitable macros for Pandoc custom styles for paragraphs, spans and tables
@ 2024-09-23 22:08 mf
  2024-09-24  7:04 ` [NTG-context] " Henning Hraban Ramm
  0 siblings, 1 reply; 3+ messages in thread
From: mf @ 2024-09-23 22:08 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [NTG-context] Re: suitable macros for Pandoc custom styles for paragraphs, spans and tables
  2024-09-23 22:08 [NTG-context] suitable macros for Pandoc custom styles for paragraphs, spans and tables mf
@ 2024-09-24  7:04 ` Henning Hraban Ramm
  2024-09-26  9:19   ` mf
  0 siblings, 1 reply; 3+ messages in thread
From: Henning Hraban Ramm @ 2024-09-24  7:04 UTC (permalink / raw)
  To: ntg-context

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
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [NTG-context] Re: suitable macros for Pandoc custom styles for paragraphs, spans and tables
  2024-09-24  7:04 ` [NTG-context] " Henning Hraban Ramm
@ 2024-09-26  9:19   ` mf
  0 siblings, 0 replies; 3+ messages in thread
From: mf @ 2024-09-26  9:19 UTC (permalink / raw)
  To: ntg-context

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
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-09-26  9:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-23 22:08 [NTG-context] suitable macros for Pandoc custom styles for paragraphs, spans and tables mf
2024-09-24  7:04 ` [NTG-context] " Henning Hraban Ramm
2024-09-26  9:19   ` mf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).