Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Those who can, do; those who can't, write. Those who can't write work for the Bell Labs Record.


computers / comp.text.tex / Re: Syntax for loading listings languages

SubjectAuthor
* Syntax for loading listings languagesPeter Flynn
`* Re: Syntax for loading listings languagesHolger Schieferdecker
 `- Re: Syntax for loading listings languagesPeter Flynn

1
Syntax for loading listings languages

<l47eq4FngcgU1@mid.individual.net>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=8216&group=comp.text.tex#8216

  copy link   Newsgroups: comp.text.tex
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: peter@silmaril.ie (Peter Flynn)
Newsgroups: comp.text.tex
Subject: Syntax for loading listings languages
Date: Wed, 28 Feb 2024 00:58:44 +0000
Lines: 30
Message-ID: <l47eq4FngcgU1@mid.individual.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net EuO47yaet0CNecWcaClTKAiIpmWdwMTQoLqMvSYU0ZC9oO0gHZ
Cancel-Lock: sha1:2ZlZAryjOnsvM2m+pkd9LAi0nHg= sha256:s3O1f+NJJaXoj+aF4U8CKzJZY2ng8FeuqMRapP1TJlA=
User-Agent: Mozilla Thunderbird
Content-Language: en-GB
 by: Peter Flynn - Wed, 28 Feb 2024 00:58 UTC

Using the listings package. I am curious as to why the LaTeX language
has to be loaded and used as [LaTeX]TeX, but a language or dialect I
define myself can be both loaded and used by simple name alone.

===================================================================
\documentclass{article}

\usepackage{listings}
\lstdefinelanguage{DocBook}[]{XML}{morekeywords={chapter,para}}
\lstdefinelanguage{LaTeXe}[LaTeX]{TeX}{morekeywords={DeclareLanguageMapping}}
\lstloadlanguages{DocBook,[LaTeX]TeX,LaTeXe}

\begin{document}

\begin{lstlisting}[language={[LaTeX]TeX}]
\tableofcontents
\end{lstlisting}

\begin{lstlisting}[language=DocBook]
<chapter><para>
\end{lstlisting}

\begin{lstlisting}[language=LaTeXe]
\DeclareLanguageMapping
\end{lstlisting}

\end{document}
===================================================================

Peter

Re: Syntax for loading listings languages

<urn6dhUt2ipL1@usenet.in-ulm.de>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=8223&group=comp.text.tex#8223

  copy link   Newsgroups: comp.text.tex
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.bawue.net!newsfeed.in-ulm.de!.POSTED!not-for-mail
From: spamless@gmx.de (Holger Schieferdecker)
Newsgroups: comp.text.tex
Subject: Re: Syntax for loading listings languages
Date: Wed, 28 Feb 2024 12:45:57 +0100
Organization: [ posted via ] IN-Ulm
Message-ID: <urn6dhUt2ipL1@usenet.in-ulm.de>
References: <l47eq4FngcgU1@mid.individual.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.in-ulm.de F6A5DE88DACD285E695F3FDDDF98ED18
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101
Thunderbird/52.9.1
In-Reply-To: <l47eq4FngcgU1@mid.individual.net>
 by: Holger Schieferdecke - Wed, 28 Feb 2024 11:45 UTC

Am 28.02.2024 um 01:58 schrieb Peter Flynn:
> Using the listings package. I am curious as to why the LaTeX language
> has to be loaded and used as [LaTeX]TeX, but a language or dialect I
> define myself can be both loaded and used by simple name alone.

Maybe I don't get your point, but I want to share my thoughts on that
issue. Let me add that I'm not an expert with listings.

As far as I understand the manual there are single languages and
languages with one or more dialects. In the former case you can load the
language by using its name. For languages with dialects you need to
specify which dialect you want to use. But it is possible to define a
default dialect for a language. In that case you can load the language
with that dialect by simply using the language name. According to the
manual for TeX the default dialect is plain. So just loading TeX as
language would invoke plain TeX.

In your example below you define a new language called LaTeXe based on
[LaTeX]{TeX}. Now LaTeXe is a language without dialects and can be
loaded without specifying one.

If I understand you correctly you would like to load [LaTeX]{TeX} by
just specifying LaTeX. Which doesn't work.

Now I tried something which presumably doesn't make sense, but it works.

\lstdefinelanguage[Peter]{MyHTML}[]{HTML}{...}
\lstdefinelanguage[Peter]{MyXML}[]{XML}{...}

You can define several languages with the same dialect name. So
specifying just the dialect is not distinct.

%%%%%
\documentclass{article}
\usepackage{listings}
\usepackage{xcolor}
\lstdefinelanguage[Peter]{MyHTML}[]{HTML}{morekeywords={Peter}}
\lstdefinelanguage[Peter]{MyXML}[]{XML}{morekeywords={Peter}}

\begin{document}

\begin{lstlisting}[language={[Peter]{MyHTML}}]
Hallo Peter
\end{lstlisting}

\begin{lstlisting}[language={[Peter]{MyXML}}]
Hallo Peter
\end{lstlisting}

\end{document}
%%%%%

I hope this helps a bit.

Holger

Re: Syntax for loading listings languages

<l495efFs4hU1@mid.individual.net>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=8224&group=comp.text.tex#8224

  copy link   Newsgroups: comp.text.tex
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: peter@silmaril.ie (Peter Flynn)
Newsgroups: comp.text.tex
Subject: Re: Syntax for loading listings languages
Date: Wed, 28 Feb 2024 16:31:11 +0000
Lines: 56
Message-ID: <l495efFs4hU1@mid.individual.net>
References: <l47eq4FngcgU1@mid.individual.net>
<urn6dhUt2ipL1@usenet.in-ulm.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net 5JGag67l2fLHPopMC49nAw0NrtNegnd7gCg+2nUAwVm4+c0P4O
Cancel-Lock: sha1:WM/mVJ5z1X/0qXLrRqkMNGRjvJA= sha256:7LtHBpFGQRX6l4Q2rhQRwoPK2BdguQL1Jlw9d4Jca/Q=
User-Agent: Mozilla Thunderbird
Content-Language: en-GB
In-Reply-To: <urn6dhUt2ipL1@usenet.in-ulm.de>
 by: Peter Flynn - Wed, 28 Feb 2024 16:31 UTC

On 28/02/2024 11:45, Holger Schieferdecker wrote:
> Am 28.02.2024 um 01:58 schrieb Peter Flynn:
>> Using the listings package. I am curious as to why the LaTeX
>> language has to be loaded and used as [LaTeX]TeX, but a language or
>> dialect I define myself can be both loaded and used by simple name
>> alone.
>
> Maybe I don't get your point,

I explained it badly. I should have written "a language or dialect I
define myself, either completely new or based on an existing dialect of
an existing language".

> As far as I understand the manual there are single languages and
> languages with one or more dialects. In the former case you can load
> the language by using its name. For languages with dialects you need
> to specify which dialect you want to use. But it is possible to
> define a default dialect for a language. In that case you can load
> the language with that dialect by simply using the language name.

As I understand it, you can invoke the default dialect by loading
[]{lang} (ie empty square brackets).

> According to the manual for TeX the default dialect is plain. So just
> loading TeX as language would invoke plain TeX.

Right.

> In your example below you define a new language called LaTeXe based
> on [LaTeX]{TeX}. Now LaTeXe is a language without dialects and can be
> loaded without specifying one.

OK. That's what I hoped. I need to define some extra commands not in the
[LaTeX] dialect.

> If I understand you correctly you would like to load [LaTeX]{TeX} by
> just specifying LaTeX. Which doesn't work.

No, I just wanted to make sure of the rules.

> Now I tried something which presumably doesn't make sense, but it
> works.
> \lstdefinelanguage[Peter]{MyHTML}[]{HTML}{...}
> \lstdefinelanguage[Peter]{MyXML}[]{XML}{...}
> You can define several languages with the same dialect name. So
> specifying just the dialect is not distinct.

Right, because they are dialects of a different base language.

> I hope this helps a bit.

Yes, thank you. In effect, for my purposes the *only* language to load
that requires a dialect is [LaTeX]{TeX}, as far as I can see.

Peter

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor