Re: How to mark a programlisting non-translatable

Norm Tovey-Walsh <[email protected]> Fri, 19 May 2023 09:23:38 +0100
Newsgroups gmane.text.docbook.misc
Message-ID <[email protected]>
--=-=-=
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

> I need that the result should look like the following to turn on
> syntax highlighting and more importantly to prevent automatic
> translation of meaningful strings in the listing (say comments) from
> happening:
>
> <pre class=3D"programlisting highlight-shell notranslate">
> some program lines
> </pre>

Depending on which stylesheets you=E2=80=99re using, you may be able to ach=
ieve
this by simply changing your programlisting, for example:

  <programlisting role=3D"highlight-shell notranslate">
  some program lines
  </programlisting>

> This basically does what I need but a stray xmlns attribute appears in
> pre:
>
> <pre xmlns=3D"http://www.w3.org/TR/xhtml1/transitional"
> class=3D"programlisting highlight-shell notranslate">
> some program lines
> </pre>

Namespaces can be a bit tricky to get right.

You probably have that namespace declaration at the top of your
stylesheet. If you don=E2=80=99t want the elements output to be in that
namespace, remove the declaration.

If you can=E2=80=99t do that for some reason, then you can put the pre elem=
ent
in no namespace:

<xsl:template match=3D"programlisting">
  <pre xmlns=3D"" class=3D"programlisting highlight-shell notranslate">
    <xsl:apply-templates/>
  </pre>
</xsl:template>

That declaration won=E2=80=99t be output if the rest of the document is alr=
eady
in no namespace. If the rest of the document is in some other namespace,
then you can change the xmlns declaration at the top of your stylesheet
to that namespace or change the binding on the pre element to that
namespace, depending on which makes more sense.

                                        Be seeing you,
                                          norm

=2D-
Norm Tovey-Walsh <[email protected]>
https://norm.tovey-walsh.com/

> He that shuns trifles must shun the world.--George Chapman

--=-=-=
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iHUEARYKAB0WIQSEJUqRvjpp8yLt8uKDEiZHbwv9OwUCZGc0UwAKCRCDEiZHbwv9
O/7YAP42ILs8Xq/IzvTIv0a7XmmJNHjJTuWNzqwf6olD95CokQD/cILPY9X/9j++
PVK3xOX9wzN1K2YHgm13gT6m1kId7gc=
=K935
-----END PGP SIGNATURE-----
--=-=-=--