ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Andreas Schneider <aksdb@gmx.de>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: XML Processing with Verbatim (VIM-Typing)
Date: Tue, 10 Feb 2015 17:59:17 +0100	[thread overview]
Message-ID: <d16be8336a6d8370ddfe14b0f95a0bd4@aksdb.homeip.net> (raw)

Hello,

as a few other topics on this Mailing List already discussed, it's not 
(easily?) possible to use \starttyping\stoptyping within XML setups. If 
it was "simple" verbatim, there would be a few workarounds.
However, I want to provide formatted verbatim (i.e. \startJSON 
\stopJSON, after having \definevimtyping[JSON][syntax=javascript]). That 
typing environment will be further customized (by adding text background 
with border, etc.).

I don't see a simple way to work around this without manually 
typesetting the code highlighting (which I don't want. I simply want 
<json>{someCode}</json> inside the XML file).

Is there anything I can do to make this work? Maybe with preparing a 
buffer? (with Lua?)

Thanks in advance, for any help you can provide :-)

-- Minimal Example:
\usemodule[vim]
\definevimtyping[JSON][syntax=javascript]

\starttext

\startluacode
   function xml.functions.processJSON(t)
     lxml.verbatim(t, "\\startJSON", "\\stopJSON")
   end
\stopluacode

\startbuffer[demo]
<test>
   <description>
     <json>{somecode}</json>
   </description>
</test>
\stopbuffer

\startxmlsetups xml:initialize
   \xmlsetsetup{#1}{test|description|json}{xml:*}
\stopxmlsetups

\xmlregistersetup{xml:initialize}

\startxmlsetups xml:test
   \xmlflush{#1}
\stopxmlsetups

\startxmlsetups xml:description
   %\xmlsetsetup{xml}{json}{xml:*}
   \xmlflush{#1}
\stopxmlsetups

\startxmlsetups xml:json
   \xmlfunction{#1}{processJSON}
\stopxmlsetups

\xmlprocessbuffer{main}{demo}{}

\stoptext
___________________________________________________________________________________
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
___________________________________________________________________________________

             reply	other threads:[~2015-02-10 16:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-10 16:59 Andreas Schneider [this message]
2015-02-10 21:45 ` Hans Hagen
2015-02-11 11:15   ` Andreas Schneider
2015-02-12 14:44     ` Hans Hagen
2015-02-13  0:00       ` Aditya Mahajan
2015-02-13  8:13       ` Andreas Schneider

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d16be8336a6d8370ddfe14b0f95a0bd4@aksdb.homeip.net \
    --to=aksdb@gmx.de \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).