Re: [NTG-context] Ctx XML

2014-12-11 Thread Hans Hagen

On 12/11/2014 8:33 AM, Procházka Lukáš Ing. - Pontex s. r. o. wrote:

Hello,

On Thu, 11 Dec 2014 02:24:24 +0100, Hans Hagen pra...@wxs.nl wrote:


On 12/10/2014 11:08 PM, Lukáš Procházka wrote:

I assume that you also want the content of elements, not just the
attributes.


Yes...


Or how to achieve this in a best way under Ctx: XML file - Lua
table/tree?


It all depends on what kin dof table you want (if the content is an
indexed table and attributes keys then you have the problem that the
element cannot be a key too as it can clash) .. anyway, it's no big deal
to provide a stupid table, so I can provide something because after all
the loaded xml file is a table already.


It would be great.


local x = xml.load(file.xml)

local t = xml.totable(x)

where x is an index/hash mix plus _tag, _type and _namespace fields as
well (after all I assume that you need to know that too).

(btw, I bet that you can do what you want with the existing
functionality as well, so there is not much benefit in such a table)

Probably in the next upload,


 Means - some functionality (for me to test or to play with) might
be available tomorrow morning?


Hans


BTW, I prepared a really-simple-XML-test which shows XML - Lua
table/tree conversion, which I'd like to achieve (and which (approx.)
provides LuaXml lib).

 XML
a aaa=AAA
   b bbb=B1/
   b bbb=B2
 c
   /b
/a


 Lua representation
{ [0] = a, -- Element name
   { [0] = b, -- Element name
 -- No nested members
 bbb = B1, -- Atts
   },
   { [0] = b, -- Element name
 { c, }, -- Nested member
 bbb = B2, -- Atts
   },
   aaa = AAA, -- Atts
}



that already makes assumptions that it's just data ... the context xml 
parser is a roundtrip one so a bit more control is provided:


local str = [[
?xml version=1.0 ?
a one=1
!-- rubish --
  b two=1/
  b two=2
c gt; d
  /b
/a
]]

I've added some flags:

inspect(xml.totable(xml.convert(str)))

table={
 {
  xml version=\1.0\ ,
  [_type]=instruction,
 },
 \
,
 {
  \
,
  {
rubish ,
   [_type]=comment,
  },
  \
  ,
  {
   [_tag]=b,
   [_type]=_element,
   [two]=1,
  },
  \
  ,
  {
   \
c  d\
  ,
   [_tag]=b,
   [_type]=_element,
   [two]=2,
  },
  \
,
  [_tag]=a,
  [_type]=_element,
  [one]=1,
 },
 [_type]=root,
}

inspect(xml.totable(xml.convert(str),true))

table={
 {
  xml version=\1.0\,
  [_type]=instruction,
 },
 {
  {
   rubish,
   [_type]=comment,
  },
  {
   [_tag]=b,
   [_type]=_element,
   [two]=1,
  },
  {
   c  d,
   [_tag]=b,
   [_type]=_element,
   [two]=2,
  },
  [_tag]=a,
  [_type]=_element,
  [one]=1,
 },
 [_type]=root,
}

inspect(xml.totable(xml.convert(str),true,true))

table={
 {
  [0]=a,
  {
   [0]=b,
   [two]=1,
  },
  {
   [0]=b,
   c  d,
   [two]=2,
  },
  [one]=1,
 },
}

The last one is yours. Of course in all cases you loose info that is 
present in the original representation (where you can also access the
nodes via expressions). Don't expect additional helpers for this 
'totable' variant.


Hans


-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
 | 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 / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___

[NTG-context] Paragraph numbering

2014-12-11 Thread MANUEL GONZALEZ SUAREZ
Hello everyone.
I have a small question about paragraphs numbering. With LaTeX we have the 
possibility of numbering \paragraph and \subparagraph. With ConTeXt we have 
commands \subsubject, etc. What I like to do is number one paragraph in middle 
of the text, with the possibility of making a reference to it, with no spaces 
before or after. Something like this:

[1] Text of the first paragraph. [2] Text of the second paragraph ...

Should I use the \label or another command?
Thanks.

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

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___

[NTG-context] new beta

2014-12-11 Thread Hans Hagen

Hi,

I uploaded a beta ... there is a new feature (for Alan):

\starttext

\chapter{The never ending story}

\section{An ending story}

\in{chapter}[match(complex bibliographies)]
\in{chapter}[match(never ending)]
\in{chapter}[match(ending)]
\in{chapter}[match(chapter:never ending)]
\in{chapter}[match(chapter:ending)]
\in{section}[match(section:ending)]
\in{figure}[match(float:mess)]
\in{figure}[match(figure:mess)]
\in{figure (not found)}[match(section:mess)]
\in{figure (not found)}[match(section:)]
\in{figure}[match(mess)]

\placefigure{What a mess}{}

\chapter{About complex bibliographies}

\in{chapter}[match(complex bibliographies)]
\in{chapter}[match(never ending)]
\in{figure}[match(mess)]

\stoptext



-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
 | 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 / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___

Re: [NTG-context] Ctx XML

2014-12-11 Thread Hans Hagen

On 12/11/2014 12:25 PM, Procházka Lukáš Ing. - Pontex s. r. o. wrote:


BTW: In your example, you are using the following enum of _type:

instruction,
comment,
_element, -- REALLY UNDERSCORE here?
root,


of course, as you can have an attribute with name 'element'

Hans



--

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
 | 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 / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___

Re: [NTG-context] underscore hyphenation

2014-12-11 Thread Pablo Rodriguez
On 12/10/2014 10:58 PM, Hans Hagen wrote:
 On 12/10/2014 9:03 PM, Pablo Rodriguez wrote:
 Hans,

 the sample below hyphenates right what comes before \TexC in the
 paragraph. Also the contents of \TexC are hyphenated right.

 But hyphen is removed from standard text after the last \TexC command in
 the paragraph.
 
 Fixed, thanks for noticing, it had to do with picking up the right 
 settings after a change in alternative (we operate on several axis: 
 language, glyph and hyphenation properties).

Many thanks for having fixed it, Hans.


Pablo



 \startluacode

  function document.addfunnyhyphen(tfmdata)
  local underscore = utf.byte(_)
  local char   = tfmdata.characters[underscore]
  tfmdata.characters[0xFE000]   = {
  width= 0,
  height   = 0,
  depth= 0,
  commands = {
  { right, -char.width },
  { down, char.depth },
  { slot, 1, underscore },
  }
  }
  end

 utilities.sequencers.appendaction(aftercopyingcharacters,after,document.addfunnyhyphen)

 \stopluacode

 \definefontfamily[mainface][serif][GaramondNo8]
 \definefontfamily[mainface][mono][Mechanica]
 \setupbodyfont[mainface, 14pt]

 \definetype
[TeXcode]
[option=TEX,
 compact=absolute,
 lines=hyphenated]

 \definehyphenationfeatures
[whatever]
[righthyphenchar=FE000]

 \setuphyphenation[method=traditional]
 \sethyphenationfeatures[strict]

 \unexpanded\def\TexC#1%
{\dontleavehmode\begingroup
 \sethyphenationfeatures[whatever]%
 \normalexpanded{\TeXcode{\letterbackslash#1}}%
 \endgroup}

 \starttext
  \hsize\zeropoint
  newlargewordwithhyphen
  \TexC{definebodyfont}
  newlargewordwithnohyphen
 \stoptext

 
 


-- 
http://www.ousia.tk
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___

Re: [NTG-context] two issues with new hyphenator

2014-12-11 Thread Pablo Rodriguez
On 12/10/2014 10:58 PM, Hans Hagen wrote:
 On 12/10/2014 8:15 PM, Pablo Rodriguez wrote:
 On 12/09/2014 12:07 AM, Hans Hagen wrote:
 On 12/8/2014 5:47 PM, Pablo Rodriguez wrote:
 [..]
 And sorry for asking this again, but I need underscore hyphenation with
 the underscore character from the font and only for the \tex and
 \hyphenatedurl commands (not for the rest of the text).
 [...]

 just a variant of the addfunyhyphen:

 Many thanks for your sample, Hans.

 It really works great.

 Sorry for asking this again: would it be possible to add this feature
 also to \hyphenatedurl.

 I’m composing a book on A6 and it is really hard to add some urls.
 
 some code from an upcoming manual:

Many thanks for the sample, Hans.

For some strange reason, the line:

 [/]  = before, [\\] = before,

removes the backslashes in your sample. Setting \hsize to \zeropoint or
other length seems to avoid the problem.

What I had in mind is something different. Sorry for not having
explained in a more accurate manner before. The current line breaking
(without hyphenation) in \hyphenatedurl is fine for me.

The issue is that there are some urls that contain long words inside.
Here is one of them:

http://www.nietzschesource.org/#eKGWB/GD-Sprueche-12.

And only for those words underscore hyphenation is required. They should
be hyphenated as any other word, only using the underscore hyphen.

This would mean that urls would have two line breaks: one without hyphen
(as it was before) and another extra with underscore.

Many thanks for your help,


Pablo


 \startluacode
  local specials = {
  [!]  = before, [?]  = before,
  ['']  = before, [']  = before,
  [/]  = before, [\\] = before,
  [#]  = before,
  [$]  = before,
  [%]  = before,
  []  = before,
  [*]  = before,
  [+]  = before, [-]  = before,
  [,]  = before, [.]  = before,
  [:]  = before, [;]  = before,
  []  = before, []  = before,
  [=]  = before,
  [@]  = before,
  [(]  = before,
  [[]  = before,
  [{]  = before,
  [^]  = before, [_]  = before,
  [`]  = before,
  [|]  = before,
  [~]  = before,
  --
  [)]  = after,
  []]  = after,
  [}]  = after,
  }
 
  languages.hyphenators.traditional.installmethod(url,
  function(dictionary,word,n)
  local t = { }
  for i=1,#word do
  local w = word[i]
  local s = specials[w]
  if s == after then
  s = {
  start  = 1,
  length = 1,
  after  = w,
  left   = false,
  right  = false,
  }
  specials[w] = s
  elseif s == before then
  s = {
  start  = 1,
  length = 1,
  before = w,
  left   = false,
   -- right  = false,
  }
  specials[w] = s
  end
  t[i] = s or false
  end
  return t
  end
  )
 \stopluacode
 
 \startluacode
 
  function document.addfunnyhyphen(tfmdata)
  local underscore = utf.byte(_)
  local char   = tfmdata.characters[underscore]
  tfmdata.characters[0xFE000]   = {
  width= 0,
  height   = 0,
  depth= 0,
  commands = {
  { right, -char.width },
  { down, char.depth },
  { slot, 1, underscore },
  }
  }
  end
 
  
 utilities.sequencers.appendaction(aftercopyingcharacters,after,document.addfunnyhyphen)
 
 \stopluacode
 
 \definehyphenationfeatures
[url]
[characters=all,
 righthyphenchar=FE000,
 alternative=url]
 
 \setuphyphenation[method=traditional]
 
 \unexpanded\def\hyphenatedurl#1%
{\dontleavehmode
 \begingroup
 \tt
 \sethyphenationfeatures[url]%
 #1%
 \endgroup}
 
 \starttext
 
 \hsize5mm
 \hyphenatedurl{http://www.pragma-ade.nl}
 
 \stoptext



-- 
http://www.ousia.tk
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___

[NTG-context] bug in \setupitemize?

2014-12-11 Thread Pablo Rodriguez
Dear list,

I have the following sample:

\showframe\showgrid
\setuppapersize[A6]
\setupitemize[inbetween={\blank[preference,big]}]
\starttext
\dorecurse{3}{\dorecurse{3}{Sometimes is really hard
to place list items. Am I missing something? }\par}

\startitemize
\item \dorecurse{5}{First item that I try. }
\item \dorecurse{15}{Second item that I write. }
\item \dorecurse{5}{Third item that I forgot. }
\stopitemize
\stoptext

Although I ask ConTeXt to try to insert a page break between list items
(which for some strange reason is avoided), the whole first list item is
moved to the next page, leaving a huge blank space in the previous page
(where the first list item would completely).

I have found this before and this is causing me problems when using lists.

Isn’t this a bug? (If not moving a whole first item to the next page
when it fits in the previous one, not obeying
inbetween={\blank[preference,big]} should be a bug.)

Or am I missing something?

Many thanks for your help,


Pablo
-- 
http://www.ousia.tk
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___

[NTG-context] [location=text] breaks setups in \setupnotes

2014-12-11 Thread Pablo Rodriguez
Dear list,

I have the following sample:

\setuppapersize[A6]
\startsetups[setups:footnote]
\setupinterlinespace[line=5ex]
\stopsetups

\setupnote[footnote][way=bytext, location=text,
setups=setups:footnote, style=\itxx]

\starttext
Hi\footnote{\input knuth}.
\placefootnotes
\stoptext

For some strange reason, when location=text is set \setupnote, the
setups option isn’t honored?

Could anyone confirm the bug?

Many thanks for your help,


Pablo
-- 
http://www.ousia.tk
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___

Re: [NTG-context] Paragraph numbering

2014-12-11 Thread Wolfgang Schuster

 Am 11.12.2014 um 11:15 schrieb MANUEL GONZALEZ SUAREZ 
 gonzalezsman...@uniovi.es:
 
 Hello everyone.
 I have a small question about paragraphs numbering. With LaTeX we have the 
 possibility of numbering \paragraph and \subparagraph. With ConTeXt we have 
 commands \subsubject, etc. What I like to do is number one paragraph in 
 middle of the text, with the possibility of making a reference to it, with no 
 spaces before or after. Something like this:
 
 [1] Text of the first paragraph. [2] Text of the second paragraph ...
 
 Should I use the \label or another command?

\starttext
\startitemize[n,text][lefttext={[},righttext={]},stopper=]
\item Text of the first paragraph.
\item Text of the second paragraph
\stopitemize
\stoptext

Wolfgang

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

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___

Re: [NTG-context] [location=text] breaks setups in \setupnotes

2014-12-11 Thread Pablo Rodriguez
On 12/11/2014 08:02 PM, Wolfgang Schuster wrote:
 Am 11.12.2014 um 19:14 schrieb Pablo Rodriguez:
 [...]
 For some strange reason, when location=text is set \setupnote, the
 setups option isn’t honored?

 Could anyone confirm the bug?
 
 It’s not a bug, the setups key is only used when notes are placed at the 
 bottom of the page
 but not when you flush them with the \placenotes command.

Many thanks for your reply. Wolfgang.

Is there no other way to apply setups to a chapter?

Many thanks for your help,


Pablo
-- 
http://www.ousia.tk
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___

Re: [NTG-context] [location=text] breaks setups in \setupnotes

2014-12-11 Thread Wolfgang Schuster

 Am 11.12.2014 um 20:31 schrieb Pablo Rodriguez oi...@gmx.es:
 
 On 12/11/2014 08:02 PM, Wolfgang Schuster wrote:
 Am 11.12.2014 um 19:14 schrieb Pablo Rodriguez:
 [...]
 For some strange reason, when location=text is set \setupnote, the
 setups option isn’t honored?
 
 Could anyone confirm the bug?
 
 It’s not a bug, the setups key is only used when notes are placed at the 
 bottom of the page
 but not when you flush them with the \placenotes command.
 
 Many thanks for your reply. Wolfgang.
 
 Is there no other way to apply setups to a chapter?

You can try to add before=\directsetup{setups:footnote}” to \setupnotes.

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

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___

Re: [NTG-context] [location=text] breaks setups in \setupnotes

2014-12-11 Thread Pablo Rodriguez
On 12/11/2014 08:38 PM, Wolfgang Schuster wrote:
 Am 11.12.2014 um 20:31 schrieb Pablo Rodriguez:
 On 12/11/2014 08:02 PM, Wolfgang Schuster wrote:
 [...]
 It’s not a bug, the setups key is only used when notes are placed
 at the bottom of the page but not when you flush them with the
 \placenotes command.

 Many thanks for your reply. Wolfgang.

 Is there no other way to apply setups to a chapter?
 
 You can try to add before=\directsetup{setups:footnote}” to \setupnotes.

Many thanks for your reply, Wolfgang.

It worked like charm.

Many thanks for your help,


Pablo
-- 
http://www.ousia.tk
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___