From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/98471 Path: news.gmane.org!.POSTED!not-for-mail From: Aditya Mahajan Newsgroups: gmane.comp.tex.context Subject: Re: t-vim module: math in "normal" code and background color Date: Wed, 19 Jul 2017 19:56:40 -0400 (EDT) Message-ID: References: <2045783.Ocy15AQZ2X@gump> <2316403.2IsKS5fdyP@gump> <1500496751.2522.44.camel@gmail.com> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; BOUNDARY="8323328-1569387982-1500508602=:1695" X-Trace: blaine.gmane.org 1500508629 12606 195.159.176.226 (19 Jul 2017 23:57:09 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 19 Jul 2017 23:57:09 +0000 (UTC) User-Agent: Alpine 2.20 (LNX 67 2015-01-07) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Thu Jul 20 01:57:03 2017 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from zapf.boekplan.nl ([5.39.185.232] helo=zapf.ntg.nl) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dXypy-0002u7-Ez for gctc-ntg-context-518@m.gmane.org; Thu, 20 Jul 2017 01:57:03 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id CF9C51049CC; Thu, 20 Jul 2017 01:56:58 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id fopTtuMK0Cgl; Thu, 20 Jul 2017 01:56:57 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [IPv6:::1]) by zapf.ntg.nl (Postfix) with ESMTP id AC8CB1049C7; Thu, 20 Jul 2017 01:56:57 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id D30B81049C7 for ; Thu, 20 Jul 2017 01:56:56 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id uCsUSiLSKdjR for ; Thu, 20 Jul 2017 01:56:54 +0200 (CEST) Original-Received: from maleficent.mr.itd.umich.edu (smtp.mail.umich.edu [141.211.125.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id 40CBB1049C6 for ; Thu, 20 Jul 2017 01:56:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=umich.edu; s=relay-2016-05-12; t=1500508602; bh=G1a40XP+Dnmn0E++AMQOxKtv5XSifOdM9W6rQVXJSow=; h=Date:From:To:Subject:In-Reply-To:References; b=GTSBcG3qP+DmiXmRiMxtKR1H6z6thXuLWEai6kR5T/ZJlFSiGQc/RT5o+v7C1aI1m BfJqQK7oSkdvCRUeG10/qtsMeRRB0oEewspBwFLaMYWeCJpklpAg+z6svQblA9yZtp BoZe1MiT3XgCFr1UO9dFuTd2xRCQOg2nQnpLeqyXZG7pgWRzNcirN1v4+wj0noo+WT SvuflgePpa64b/W2lPo7pwKRQmcT/JA5Br5BcrFoo7x5wQ/uxvPfH32sp4bZU3ODv7 vUF3hIL5HDbR4RSPa6u92CgFXstMAUUXTa69JsNDJu6QfdyhCMiwR1UW5dOlw4h4yt jzgVxWh/DltbQ== Authentication-Results: maleficent.mr.itd.umich.edu; iprev=pass policy.iprev=132.206.69.142 (Decentralized.ECE.McGill.CA); auth=pass smtp.auth=adityam Original-Received: FROM decentralized (Decentralized.ECE.McGill.CA [132.206.69.142]) By maleficent.mr.itd.umich.edu ID 596FF1BA.2ADD2.28891; Authuser adityam; Wed, 19 Jul 2017 19:56:42 -0400 In-Reply-To: <1500496751.2522.44.camel@gmail.com> X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.16 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: "ntg-context" Xref: news.gmane.org gmane.comp.tex.context:98471 Archived-At: --8323328-1569387982-1500508602=:1695 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE On Thu, 20 Jul 2017, Henri Menke wrote: > On Wed, 2017-07-19 at 15:07 -0400, Aditya Mahajan wrote: >> On Wed, 19 Jul 2017, Gerion Entrup wrote: >>=20 >> >=20 >> > Am Dienstag, 18. Juli 2017, 04:04:51 CEST schrieb Aditya Mahajan: >> > >=20 >> > > On Mon, 17 Jul 2017, Gerion Entrup wrote: >> > >=20 >> > > >=20 >> > > > Hi, >> > > >=20 >> > > > I have two questions with the vim module. >> > > >=20 >> > > > 1. I want to use the math mode inside the code. I've seen the esca= pe option, >> > > > e.g. here [1], but this seems to work only with comments. Is there= a >> > > > possibility to use it directly in the code, too? >> > > Short answer. No. >> > >=20 >> > > Long answer. t-vim relies on vim to syntax highlight the code. Since= the >> > > code is not valid python, the default python syntax highlighting wil= l not >> > > work. In principle, it is possible to write a vim syntax highlightin= g >> > > script for a derivative of python where math terms are allowed, but = that >> > > requires a lot of work for each language. The whole point of t-vim m= odule >> > > was that I am lazy and don't want to write the parser for each langu= age >> > > :-) >> > I've invested some time and rewrote parts of the vimscript file of t-v= im. >> > Now one or more escapechars can be defined, that helps vim to not inte= rpret >> > the text: >> I'll look at this later.... >>=20 >> >=20 >> > Another point I saw is, that highlight together with TeX-code is not r= eally usable: >> > ``` >> > \usemodule[vim] >> > \definevimtyping[python][syntax=3Dpython, escape=3Don] >> >=20 >> > \starttext >> > \startpython[highlight=3D1] >> > # Returns \m{\sum_{i=3D1}^{n}i \in F \int_i f} >> > \stoppython >> > \stoptext >> > ``` >> By default, the highlighting is done using the bars mechanism. It works= =C2=A0 >> for simple cases but fails with math mode (the spaces are not covered).= =C2=A0 >> One option is to highlight using the textbackground mechanism: >>=20 >> \definetextbackground[texthighlight] >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0[ >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0background=3Dcolor, >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0backgroundcolor=3Dgray, >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0frame=3Doff, >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0] >>=20 >> \define[1]\texthighlight{\starttexthighlight#1\stoptexthighlight} >>=20 >> \usemodule[vim] >> \definevimtyping[python][syntax=3Dpython, escape=3Don, highlightcommand= =3D\texthighlight] >>=20 >> \starttext >>=20 >> \startpython[highlight=3D3] >> for x in 1:n >> =C2=A0=C2=A0=C2=A0print(x) >> # Returns \m{\sum_{i=3D1}^{n}i \in F \int_i f} >> for x in 1:n >> =C2=A0=C2=A0=C2=A0print(x) >> \stoppython >> \stoptext >>=20 >> The spacing in math mode is bad. What is happening is the following. To= =C2=A0 >> make sure that spaces are obeyed in the code listing, I set (a modified= =C2=A0 >> version of) \activatespacehandler{on}, so the output that you get is the= =C2=A0 >> following: >>=20 >> {\obeyspaces >> =C2=A0 \def\obeyedspace{\hskip\interwordspace\relax} >> \m{\sum_{i=3D1}^{n}i \in F \int_i f}} >>=20 >> The simplest way to fix this is to define a new command: >>=20 >> \define[1]\MATH{\bgroup\activatespacehandler{off}\m{\rescan{#1}}\egroup} > > Why not just this? > > \def\obeyedspace{\ifmmode\else\hskip\interwordspace\relax\fi} That's a good suggestion and will be easier to incorporate in t-vim. Thanks, Aditya --8323328-1569387982-1500508602=:1695 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX18KSWYgeW91ciBxdWVzdGlvbiBpcyBvZiBpbnRlcmVz dCB0byBvdGhlcnMgYXMgd2VsbCwgcGxlYXNlIGFkZCBhbiBlbnRyeSB0byB0aGUgV2lraSEKCm1h aWxsaXN0IDogbnRnLWNvbnRleHRAbnRnLm5sIC8gaHR0cDovL3d3dy5udGcubmwvbWFpbG1hbi9s aXN0aW5mby9udGctY29udGV4dAp3ZWJwYWdlICA6IGh0dHA6Ly93d3cucHJhZ21hLWFkZS5ubCAv IGh0dHA6Ly9jb250ZXh0LmFhbmhldC5uZXQKYXJjaGl2ZSAgOiBodHRwczovL2JpdGJ1Y2tldC5v cmcvcGhnL2NvbnRleHQtbWlycm9yL2NvbW1pdHMvCndpa2kgICAgIDogaHR0cDovL2NvbnRleHRn YXJkZW4ubmV0Cl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f --8323328-1569387982-1500508602=:1695--