Re: [patch] [RFC] \DocumentMetadata

2022-02-11 Thread José Abílio Matos
On Friday, 11 February 2022 13.04.06 WET Jean-Marc Lasgouttes wrote:
> Dear Jürgen,
> 
> I had a quick look and it looks good. Of course, only time will tell of
> the approach was good enough 
> 
> JMarc

Just like Jean-Marc I agree that this seems to fit the declared purpose.

In particular it takes into account the release schedule of both LyX and 
LaTeX.
-- 
José Abílio-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: [patch] [RFC] \DocumentMetadata

2022-02-11 Thread Jean-Marc Lasgouttes

Le 11/02/2022 à 12:42, Jürgen Spitzmüller a écrit :

Dear all

The next LaTeX release (06/2022) will introduce a document metadata
interface [1] which is supposed to be used for all general document
metadata eventually (particularly for those employed in PDF output).
This interface is part of the ongoing long-term effort to integrate PDF
features into the kernel (which will most probably make hyperref and
many other pdf-related packages obsolete eventually, and particularly
allow for generating accessible [tagged] and standard-compliant PDFs,
at long last). See [2].


Dear Jürgen,

I had a quick look and it looks good. Of course, only time will tell of 
the approach was good enough :)


JMarc


--
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


[patch] [RFC] \DocumentMetadata

2022-02-11 Thread Jürgen Spitzmüller
Dear all

The next LaTeX release (06/2022) will introduce a document metadata
interface [1] which is supposed to be used for all general document
metadata eventually (particularly for those employed in PDF output).
This interface is part of the ongoing long-term effort to integrate PDF
features into the kernel (which will most probably make hyperref and
many other pdf-related packages obsolete eventually, and particularly
allow for generating accessible [tagged] and standard-compliant PDFs,
at long last). See [2].

This is all still highly experimental and rudimentary and will probably
only be getting interesting to most users over the next release cycles.
However, given the current long major release cycles we have, and given
the implementation of this \DocumentMetadata interface I propose to add
basic support to 2.4 as:

1. \DocumentMetadata must be inserted at the very beginning of a
document, and particularly _before_ \documentclass. So it is impossible
to use this feature with LyX as it stands. See [1] for a rationale.

2. Given that file format reversion can only delete those metadata,
having it as a Buffer param quite early will mitigate the unavoidable
data loss at version cycling.

The attached patch does the implementation, everything (lyx2lyx,
tex2lyx) included. The GUI is basic, a simple input widget for the key-
vals that are expected by \DocumentMetadata, and I have hidden it in
PDF Settings, as those are the only parameters these metadata currently
seem to concern. After everything has settled and the interface became
more widespread (i.e., taken up by packages), we can think about a more
sophisticated GUI (but this is certainly post-2.4 work).

At LaTeX export, \DocumentMetadata is only output if LaTeX 06/2022 or
newer is available (so it will output nothing at all currently unless
you change the code).

Since this is a very late feature proposal and file format change, I'd
like to hear your opinions before pushing any buttons.

Best,
Jürgen

[1] http://mirrors.ctan.org/macros/latex-dev/base/ltnews.pdf (Issue 35)
[2]
https://www.latex-project.org/publications/2020-tagged-pdf-feasibility.pdf
diff --git a/lib/chkconfig.ltx b/lib/chkconfig.ltx
index fe3ce0d068..e5972e23e9 100644
--- a/lib/chkconfig.ltx
+++ b/lib/chkconfig.ltx
@@ -242,6 +242,8 @@
 \TestLaTeXVersion{2020/10/01}
 % This robustifies LaTeX commands
 \TestLaTeXVersion{2021/06/01}
+% Introduction of \\DocumentMetadata
+\TestLaTeXVersion{2022/06/01}
 
 %%% And now, the list of available languages
 % The trick is to know that \the\everyjob contains something like
diff --git a/lib/lyx2lyx/lyx_2_4.py b/lib/lyx2lyx/lyx_2_4.py
index 3fed7eebd6..9dfaeaea47 100644
--- a/lib/lyx2lyx/lyx_2_4.py
+++ b/lib/lyx2lyx/lyx_2_4.py
@@ -27,11 +27,12 @@ from datetime import (datetime, date, time)
 # Uncomment only what you need to import, please.
 
 from parser_tools import (count_pars_in_inset, del_complete_lines, del_token,
-find_end_of_inset, find_end_of_layout, find_token, find_token_backwards,
-find_token_exact, find_re, get_bool_value, get_containing_inset,
-get_containing_layout, get_option_value, get_value, get_quoted_value)
+ find_end_of, find_end_of_inset, find_end_of_layout, find_token,
+ find_token_backwards, find_token_exact, find_re, get_bool_value,
+ get_containing_inset, get_containing_layout, get_option_value, get_value,
+ get_quoted_value)
 #del_value, 
-#find_complete_lines, find_end_of,
+#find_complete_lines,
 #find_re, find_substring,
 #is_in_inset, set_bool_value
 #find_tokens, check_token
@@ -4413,6 +4414,19 @@ def revert_docbook_mathml_prefix(document):
 return
 del document.header[i]
 
+def revert_document_metadata(document):
+"""Revert document metadata"""
+i = 0
+while True:
+i = find_token(document.header, "\\begin_metadata", i)
+if i == -1:
+return
+j = find_end_of(document.header, i, "\\begin_metadata", "\\end_metadata")
+if j == -1:
+# this should not happen
+break
+document.header[i : j + 1] = []
+
 ##
 # Conversion hub
 #
@@ -4482,10 +4496,12 @@ convert = [
[605, [convert_vcolumns2]],
[606, [convert_koma_frontispiece]],
[607, []],
-   [608, []]
+   [608, []],
+   [609, []]
   ]
 
-revert =  [[607, [revert_docbook_mathml_prefix]],
+revert =  [[608, [revert_document_metadata]],
+   [607, [revert_docbook_mathml_prefix]],
[606, [revert_spellchecker_ignore]],
[605, [revert_koma_frontispiece]],
[604, [revert_vcolumns2]],
diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp
index fc559a4848..95aa9136d2 100644
--- a/src/BufferParams.cpp
+++ b/src/BufferParams.cpp
@@ -807,6 +807,8 @@ string BufferParams::readToken(Lexer & lex, string const & token,
 origin.replace(0, sysdirprefix.length() - 1,
 	package().system_support().absFileName());
 		}
+	} else