Commit graph

7 commits

Author SHA1 Message Date
Jan Theegarten
0db750805f Update test references 2021-01-07 19:23:20 +01:00
albert-github
88e70b5242 Adding the xml:lang tag to XML and Docbook output
Adding the xml:lang attribute for XNL and Docbook output

Interesting links:
- language codes (different from country codes!): https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry
- example for xml.xsd: http://www.java2s.com/Code/XML/XML-Schema/importanotherXMLschema.htm
2020-06-03 14:55:52 +02:00
Dimitri van Heesch
2ceb8cd074
Merge pull request #624 from mosra/xml-page-briefdescription
Provide page brief in <briefdescription> of XML output
2017-12-24 10:31:24 +01:00
Vladimír Vondruš
bd2cf98e75 Provide page brief in <briefdescription> of XML output.
Until now the brief description of pages was prepended to the
<detaileddescription> element and the <briefdescription> element was
not present at all, which meant there was no easy way to extract the
brief description for purposes of creating a page index, for example.

With this patch, the brief description is included in both
<briefdescription> and <detaileddescription>, thus duplicated, to
avoid backwards compatibility issues.
2017-11-25 19:27:15 +01:00
Vladimír Vondruš
b6a7abf026 Encode invalid XML characters instead of skipping them.
The <sp> element in <programlisting> has a new optional attribute
`value`, which contains value of given invalid ASCII character. In
case of space, the `value` attribute is omitted.

Use cases for this: including snippets of *very esoteric* languages,
markup that makes use of the advanced ASCII formatting characters or
for example highlighting a console output containing ANSI color codes
(which is my case, in fact).

Regarding backwards compatibility -- as files with such ASCII
characters are very rare, I don't expect this minor difference in the
output to be a problem. Besides that, such ASCII characters are often
replaced by a space in many applications anyway.

A test snippet was extended to contain a special character so this
difference in behavior could be verified.
2017-11-25 18:37:26 +01:00
Vladimír Vondruš
eaf8edbac7 Propagate language information to all <programlisting> XML elements.
This is based on work done in 141dbfd5a4
through ed9acb6e1b and makes a few
behavioral changes to it.

There's a new attribute called `filename` and the `language` was removed,
because it could provide misleading information. This allows for more
flexibility on the user side. In particular:

 * For historical reasons, `*.txt` files are marked by Doxygen as C++
   (see https://bugzilla.gnome.org/show_bug.cgi?id=760836 for details).
   In particular, code snippet included from a CMakeLists.txt file would
   be marked and highlighted as C++. So in this case, the language
   attribute would be very misleading.
 * Doxygen is aware only of a very small subset of languages and thus a
   lot of information can be lost when relying on its
   extension-to-language-name conversion -- in particular, all
   extensions that are not recognized are assumed to be C++. On the other
   hand, putting more effort into its language detection algorithms is
   not worth the time, as there will always be new languages that fail to
   detect. So let's leave that on the user of the XML output instead.
 * Using just file extension is not enough, it has to be a full filename.
   For example, `*.txt` can be either a plain text file or a
   `CMakeLists.txt`.
 * The path is not stripped from the filename, as it also may contain
   additional information that helps to detect the language better.

In addition to that, filenames of code snippets included via the \include
command and related are propagated to the <programlisting> element as
well.

With this change, (1) code snippets using simply

    \code
    some code
    \endcode

will not produce any `filename` attribute and it's up to the user what to
do -- assume C++, detect language from contents or not highlight
anything.

    <programlisting>
    some code
    </programlisting>

(2) Code snippets using

    \code{.cmake}
    some code
    \endcode

will produce the following:

    <programlisting filename=".cmake">
    some code
    </programlisting>

(3) And finally, \include, \dontinclude and related \skip, \skipline etc.
commands

    \include path/to/some-file.py

will produce

    <programlisting filename="path/to/some-file.py">
    some code
    </programlisting>

The tests were updated to check all three cases.

On the user side, when using Pygments for example, it's then just a
matter of calling pygments.lexers.find_lexer_class_for_filename() with
value of the `filename` attribute value and optionally also the code
snippet for additional language analysis.
2017-11-19 14:15:14 +01:00
Dimitri van Heesch
5875da6cae Added regression test suite 2013-07-19 21:46:35 +02:00