Re: [NTG-context] How to do code listings & sections from XML (AsciiDoc)

2022-08-12 Thread Max Chernoff via ntg-context
> Hi,
> 
> Hans helped me out with some asciidoc processing a while ago.
> 
> I played a bit further, but I'm currently facing two minor issues:
> 
> (a) I don't know how to turn program listing (verbatim code) from xml
> to (perhaps, vim-based) syntax highlighting (but most importantly, to
> make sure that line breaks work properly)


> Ad (a). The source that looks similar to this:
> 
> 
> int main()
> {
> return 0;
> }
> 
> 
> should be converted into some kind of equivalent of
> 
> % on top
> \usemodule[vim]
> \definevimtyping [CPP] [syntax=cpp]
> 
> \startCPP
> int main()
> {
> return 0;
> }
> \stopCPP

> Any hints would be greatly appreciated.

This should get you pretty close:

   https://tex.stackexchange.com/a/652116/
   
You can look through the revision history for a few different versions if
the newest one doesn't quite work.
   
-- Max
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] Keep the right margin in [nothyphenated, flushleft] columns

2022-08-12 Thread Denis Maier via ntg-context
Also stretch might be useful as an additional option for align.

Denis


Von: ntg-context  im Auftrag von Aditya Mahajan via 
ntg-context 
Gesendet: Freitag, 12. August 2022 23:11:21
An: Marcin Ciura via ntg-context
Cc: Aditya Mahajan
Betreff: Re: [NTG-context] Keep the right margin in [nothyphenated, flushleft] 
columns

On Fri, 12 Aug 2022, Marcin Ciura via ntg-context wrote:

> Dear list,
>
> I am typesetting [nothyphenated,flushleft] text in two columns. Some words
> stick through the right margin of the left column, sometimes even
> overlapping the right column. How can I make Context obey the right margin?

(Untested): Try adding 'tolerant' or 'verytolerant' to the align options.

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] How to do code listings & sections from XML (AsciiDoc)

2022-08-12 Thread Aditya Mahajan via ntg-context
On Fri, 12 Aug 2022, Mojca Miklavec via ntg-context wrote:

> Hi,
> 
> Hans helped me out with some asciidoc processing a while ago.
> 
> I played a bit further, but I'm currently facing two minor issues:
> 
> (a) I don't know how to turn program listing (verbatim code) from xml
> to (perhaps, vim-based) syntax highlighting (but most importantly, to
> make sure that line breaks work properly)

Does something like this work:

https://wiki.contextgarden.net/Verbatim_XML

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] Keep the right margin in [nothyphenated, flushleft] columns

2022-08-12 Thread Aditya Mahajan via ntg-context
On Fri, 12 Aug 2022, Marcin Ciura via ntg-context wrote:

> Dear list,
> 
> I am typesetting [nothyphenated,flushleft] text in two columns. Some words
> stick through the right margin of the left column, sometimes even
> overlapping the right column. How can I make Context obey the right margin?

(Untested): Try adding 'tolerant' or 'verytolerant' to the align options.

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


[NTG-context] How to do code listings & sections from XML (AsciiDoc)

2022-08-12 Thread Mojca Miklavec via ntg-context
Hi,

Hans helped me out with some asciidoc processing a while ago.

I played a bit further, but I'm currently facing two minor issues:

(a) I don't know how to turn program listing (verbatim code) from xml
to (perhaps, vim-based) syntax highlighting (but most importantly, to
make sure that line breaks work properly)

(b) some section titles are missing


Ad (a). The source that looks similar to this:


int main()
{
return 0;
}


should be converted into some kind of equivalent of

% on top
\usemodule[vim]
\definevimtyping [CPP] [syntax=cpp]

\startCPP
int main()
{
return 0;
}
\stopCPP

In the attachment I have the source document (test.adoc), the
generated docbook xml that should be further processed, and test.tex
that one processes to get the final pdf.

Any hints would be greatly appreciated.

Mojca


test.tex
Description: Binary data


test.adoc
Description: Binary data



http://docbook.org/ns/docbook; xmlns:xl="http://www.w3.org/1999/xlink; version="5.0" xml:lang="en">

Document title (completely missing)
2022-08-12


This title seems to be missing
Hello code 

How it works
// test.cpp:

halfword tex_copy_node(halfword p)
{
/*tex
We really need a stub for copying because mem might move in the meantime due to resizing!
*/
if (p  0 || p = lmt_node_memory_state.nodes_data.allocated) {
return tex_formatted_error("nodes", "attempt to copy an impossible node %d", (int) p);
} else if (p  lmt_node_memory_state.reserved  lmt_node_memory_state.nodesizes[p] == 0) {
return tex_formatted_error("nodes", "attempt to copy a free %s node %d", get_node_name(node_type(p)), (int) p);
} else {
/*tex type of node */
halfword t = node_type(p);
int i = get_node_size(t);
/*tex current node being fabricated for new list */
halfword r = tex_get_node(i);
/*tex this saves work */
memcpy((void *) (lmt_node_memory_state.nodes + r), (void *) (lmt_node_memory_state.nodes + p), (sizeof(memoryword) * (unsigned) i));
if (tex_nodetype_is_complex(i)) {
 // halfword copy_stub;
if (tex_nodetype_has_attributes(t)) {
add_attribute_reference(node_attr(p));
node_prev(r) = null;
lmt_properties_copy(lmt_lua_state.lua_instance, r, p);
}
node_next(r) = null;
switch (t) {
case glue_node:
copy_sub_list(glue_leader_ptr(r), glue_leader_ptr(p));
break;




m-asciidoc-manual.tex
Description: Binary data
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] image with rounded corners

2022-08-12 Thread Henning Hraban Ramm via ntg-context

Am 12.08.22 um 13:10 schrieb Wolfgang Schuster via ntg-context:

Henning Hraban Ramm via ntg-context schrieb am 12.08.2022 um 10:57:

Hi, can ConTeXt make rounded image corners?



\setupexternalfigures[location=default]

\starttext

\startMPclip{rounded corner}
clip currentpicture to (roundedsquare(OverlayWidth,OverlayHeight,EmWidth));
\stopMPclip

\clip[nx=1,ny=1,mp=rounded corner]{\externalfigure[mill]}

\stoptext


Thank you!

Hraban

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


[NTG-context] Keep the right margin in [nothyphenated, flushleft] columns

2022-08-12 Thread Marcin Ciura via ntg-context
Dear list,

I am typesetting [nothyphenated,flushleft] text in two columns. Some words
stick through the right margin of the left column, sometimes even
overlapping the right column. How can I make Context obey the right margin?

The MWE is below.

Here is the output PDF:
https://live.contextgarden.net/cgi-bin/result.cgi?id=UnSfnS


Best regards,

Marcin


\setupalign[nothyphenated,flushleft]

\starttext

\startitemize[n,nowhite,columns,two]

% The word '(boków' sticks through the right

% margin of the left column.

\item {\bf Wielokąt} to figura na płaszczyźnie,

której brzeg składa się z~odcinków

({\bf boków wielokąta}).

Końce boków nazywamy wierzchołkami wielokąta.

Czasem wyróżniamy jeden bok,

nazywając go podstawą wielokąta.

\stopitemize

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] Fwd: Typesetting modern Greek (UTF8) with ConTeXt

2022-08-12 Thread Adam Reviczky via ntg-context
Thanks Hanx for the fix!

>> Just curious: you're still in mkii?
No, I was just trying to compare an old project (nothing important) with
lmtx, otherwise I wouldn't have even noticed.

Adam


On Fri, Aug 12, 2022 at 8:14 AM Hans Hagen  wrote:

> On 8/12/2022 2:57 AM, Adam Reviczky wrote:
> > Hi Hans,
> >
> > I get a 'Nonletter' error with *fmtutil* for the mkii greek patterns
> (from
> > the latest cont-tmf.zip 2022-08-05 17:17).
> >
> > Is that an issue with texlive's *fmtutil* itself or something wrong with
> > the mkii greek pattern file?
>
> Actually, we never had a greek hyphenation pattern file, only for
> ancient greek. Modern greek in mkii has not encoding defined (we're
> talking 2005 and before when Tomas made the greek encoding that dealt
> with utf in pdftex). It has to do with 'setting what are letters' and
> these modern greek patterns have plenty different.
>
> You can patch lang-grk.mkii:
>
> \installlanguage
>[\s!gr]
>[\c!spacing=\v!packed,
> \c!leftsentence=---,
> \c!rightsentence=---,
> \c!leftsubsentence=---,
> \c!rightsubsentence=---,
> \c!leftquote=\greekleftquot,
> \c!rightquote=\greekrightquot,
> \c!leftquotation=\greekleftquot,
> \c!rightquotation=\greekrightquot,
>  % we're missing an encoding for greek
> \s!patterns=\s!agr,
> \s!mapping=\s!agr,
> \s!encoding=\s!agr,
> % but one can use mkiv / lmtx anyway
> \c!date={\v!day\ \v!month\ \v!year}]
>
> At least you get something. In mkiv and lmtx we have both.
>
> Just curious: you're still in mkii?
>
> Hans
>
> -
>Hans Hagen | PRAGMA ADE
>Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
> tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
> -
>
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] image with rounded corners

2022-08-12 Thread Wolfgang Schuster via ntg-context

Henning Hraban Ramm via ntg-context schrieb am 12.08.2022 um 10:57:

Hi, can ConTeXt make rounded image corners?
Both of my approaches don’t work:


\externalfigure[mill][
  width=3cm,
  frame=on,
  corner=round,radius=1cm,
  backgroundcorner=round,backgroundradius=1cm,
]

\defineoverlay[Mill][{%
  \externalfigure[mill][width=\overlaywidth]
}]
\framed[background=Mill,width=3cm,height=4cm,
corner=round,radius=1cm,
backgroundcorner=round,backgroundradius=1cm,
offset=overlay]{}


\setupexternalfigures[location=default]

\starttext

\startMPclip{rounded corner}
clip currentpicture to (roundedsquare(OverlayWidth,OverlayHeight,EmWidth));
\stopMPclip

\clip[nx=1,ny=1,mp=rounded corner]{\externalfigure[mill]}

\stoptext

Wolfgang

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] parameters of (setup)externalfigure, conversions etc.

2022-08-12 Thread Henning Hraban Ramm via ntg-context

Am 11.08.22 um 15:51 schrieb Henning Hraban Ramm via ntg-context:

Hi Hans,

yesterday you told me about the image conversions in grph-con.lua, and I 
tried to find out how to use them. Up to know I only knew "mp" for SVG 
images.


I found I can use "gray.pdf" or "cmyk.pdf" to convert an image (JPG or 
PNG) to grayscale/CMYK, but the resolution isn’t used for downsampling 
(of course, it’s not mentioned in the command template):


\externalfigure[hacker][conversion={gray.pdf},resolution=72]

I tried to write my own downsampling converter, but don’t understand how 
I can hook it into the list of converters:


"""

local downsample = sandbox.registerrunner {
   name = "downsample",
   program  = "gm",
template = [[convert -compress Zip -sampling-factor 1x1 -density 
%resolution%x%resolution% -resample %resolution%x%resolution% %oldname% 
%newname%]],

   checkers = checkers,
   defaults = defaults,
}

programs.downsample = { runner = downsample }


I found the solution in 
https://wiki.contextgarden.net/Using_Graphics#Image_Conversion, but 
that’s not as elegant as those in grph-inc.lua


(And I learned that ImageMagick’s convert works differently than 
GraphicsMagick’s WRT -density; i.e. you must use "gm convert".)


Peter Münster’s grph-downsample.lua was better, it calculated the actual 
pixel size necessary, but that doesn’t work any more.



"""

(I’m not sure if I must calculate the desired pixel size beforehand.)

-*-*-

Apart from converters, there are several parameters of \externalfigure 
that I don’t understand and thus can’t document in the Wiki; a few are 
even not yet documented in the interface files:


* equalwidth/equalheight
* s/sx/sy
* xmax/ymax
* prefix, label, comment
* bodyfont
* mask
* frames (≠ frame)
* interaction (PDF inclusion; found)crossreference
* resources
* display (alternative source? multimedia only?)
* order (of extensions; found)
* crop, transform
* controls, preview: only related to video and thus obsolete?
* hfactor/wfactor: When do these make sense? (I know factor)


Also, orientation seems to be missing in the interface (auto-syntax 
doesn’t pick it up).


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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


[NTG-context] Numbercommand and title

2022-08-12 Thread Fabrice Couvreur via ntg-context
Hello,
How to make the period after the number be after the second parenthesis
when there is a title like this  Définition 1.1 (Title). ?
Thanks
Fabrice


\definestructureconversionset [structure] [n, R, n, n, n] [n]

\defineconversionset [digit] [] [n]

\setupheads[sectionconversionset=structure]

\setupenumerations
  [before={\blank},
   after={\blank},
   alternative=serried,
   distance=0.5em,
   title=yes,
   titleleft=,
   titleright=,
   titlestyle=normal,
   numbercommand=\groupedcommand{}{.},
   titlecommand=\groupedcommand{(}{)},
   width=broad,
   way=bychapter,
   prefix=yes,
   prefixsegments=chapter,
   prefixconversionset=digit,]

\defineenumeration
   [definition]
   [text=Définition,
number=yes,
style=italic]

\starttext
\startchapter
  [title={First Chapter}]
  \startdefinition
[title={My first définition}]
\input{ward}
  \stopdefinition
  \startdefinition
\input ward
  \stopdefinition
  \startdefinition
[title={My third définition}]
\input ward
  \stopdefinition
\stopchapter
\stopchapter
\stoptext
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


[NTG-context] image with rounded corners

2022-08-12 Thread Henning Hraban Ramm via ntg-context

Hi, can ConTeXt make rounded image corners?
Both of my approaches don’t work:


\externalfigure[mill][
  width=3cm,
  frame=on,
  corner=round,radius=1cm,
  backgroundcorner=round,backgroundradius=1cm,
]

\defineoverlay[Mill][{%
  \externalfigure[mill][width=\overlaywidth]
}]
\framed[background=Mill,width=3cm,height=4cm,
corner=round,radius=1cm,
backgroundcorner=round,backgroundradius=1cm,
offset=overlay]{}

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] Fwd: Typesetting modern Greek (UTF8) with ConTeXt

2022-08-12 Thread Hans Hagen via ntg-context

On 8/12/2022 2:57 AM, Adam Reviczky wrote:

Hi Hans,

I get a 'Nonletter' error with *fmtutil* for the mkii greek patterns (from
the latest cont-tmf.zip 2022-08-05 17:17).

Is that an issue with texlive's *fmtutil* itself or something wrong with
the mkii greek pattern file?


Actually, we never had a greek hyphenation pattern file, only for 
ancient greek. Modern greek in mkii has not encoding defined (we're 
talking 2005 and before when Tomas made the greek encoding that dealt 
with utf in pdftex). It has to do with 'setting what are letters' and 
these modern greek patterns have plenty different.


You can patch lang-grk.mkii:

\installlanguage
  [\s!gr]
  [\c!spacing=\v!packed,
   \c!leftsentence=---,
   \c!rightsentence=---,
   \c!leftsubsentence=---,
   \c!rightsubsentence=---,
   \c!leftquote=\greekleftquot,
   \c!rightquote=\greekrightquot,
   \c!leftquotation=\greekleftquot,
   \c!rightquotation=\greekrightquot,
% we're missing an encoding for greek
   \s!patterns=\s!agr,
   \s!mapping=\s!agr,
   \s!encoding=\s!agr,
   % but one can use mkiv / lmtx anyway
   \c!date={\v!day\ \v!month\ \v!year}]

At least you get something. In mkiv and lmtx we have both.

Just curious: you're still in mkii?

Hans

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
   tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___