[Request/idea] Preamble generalization

Richard Kimberly Heck rikiheck at lyx.org
Sun Sep 20 02:57:02 UTC 2020


On 9/19/20 6:36 PM, Lorenzo Bertini wrote:
> Sorry for the old bump, but I managed to make a tabbed menu with
> "LaTeX" and "HTML" as tabs for the "Preamble" section:
>
> What I managed to do:
> 1) Buffer params received a new variable <htmlpreamble> that can be
> written to and read from a LyX file just as old <preamble>;
> 2) "Preamble" section now has two tabs, each with a text box that
> saves what's inside into <params.preamble> and <params.htmlpreamble>
> respectively when the <PreambleModule::apply> function is called;
> 3) "find text" box and button work for the current selected tab;

Well done!


> What I couldn't do:
> 1) find out how to write <params.htmlpreamble> when outputting HTML;
> I've been looking into "output_xhtml" and "output_latex" without luck;
> where should I look?

This should be written during Buffer::writeLyXHTMLSource. As you'll see,
there is a whole section there that outputs the HTML header info.

Probably the cleanest way to do it would be to have a method
BufferParams::writeLyXHTML, parallel to BufferParams::writeLaTeX. Maybe
the code that writes foreground and background colors could be moved there.


> 2) check if <htmlpreamble> contains illegal characters (this should be
> a simple copy-paste from the latex one, I'll look into it later);

I guess the HTML preamble will contain lots of things that we don't want
to escape. Are there encoding issues, as well? I'm not at all sure about
that.


> 3) make it so when the text box for the HTML tab is modified the
> <Apply> button activates, just like the LaTeX tab does; where should I
> look to learn how to notify that "settings have changed" when the tab
> receives text?

Probably you need something parallel to:

    connect(preambleTE, SIGNAL(textChanged()), this, SIGNAL(changed()));

in PreambleModule.


> 4) avoid hardcoding some things: for example to make the "find" work
> in the current tab I have explicitly used tab names; how does one make
> this name or tab independent, in the perspective of adding more
> preamble options? Should one?

There must be some Qt routine that will tell you which tab is active,
but I'd have to see the code. May be worth posting the patch as it is now.


> Thank you in advance, I'm moving my first steps in this codebase and I
> need a little starting kick. I started here because I thought I would
> have been easier that attempting easyfixes, let me know if I'm wrong.

You've made good progress on a very worthwhile enterprise.

Riki





More information about the lyx-devel mailing list