Il 11/07/22 00:11, Steve Litt ha scritto:
tush via lyx-users said on Sat, 09 Jul 2022 18:59:53 +0000

I am trying to remove the html attributes assigned by LyXHTML to the
Standard text inserted in the editor.

LyX's default is to render Standard as

<div class="standard" id='magicparlabel-15'>This is text inserted in
Standard</div>

together with

p.standard {

text-align: left;

}

appearing in the header.

What I want is to get the simple html code

<p>This is text inserted in Standard</p>
In order to do that I am writing my Style in a layout file. What I
have at the moment is the following:

(I copied the first rows from stdclass.inc)

Style Standard
        Category              MainText
        Margin                Static
        LatexType             Paragraph
        LatexName             dummy
        ParIndent             MM
        ParSkip               0.4
        Align                 Block
        AlignPossible         Block, Left, Right, Center
        LabelType             No_Label

HTMLAttr " "

End

I think this exchange from lyx-devel will provide some explanation:
On 9/6/21 6:36 PM, Lorenzo Bertini wrote:
Hello list!

LyXHTML outputs standard paragraphs with  a <div>...</div> (as is the
standard for many insets), but i would much prefer <p>...</p>.

I know i can change the tag of other insets by going in the local
layout section of Document->Setting, and write something like
InsetLayout Foot
  HTMLTag p
End

but i cant find anything about the standard paragraph. I don't mean
the "sectioning" paragraph, that is mapped to "HTMLTag h5", but the
piece of text you get after pressing RET in LyX.

It's a paragraph layout: Standard. See stdclass.inc.

But yes, at the moment, that is hardcoded. The reason is that the tag
turns up inside other tags and nested <p>'s are invalid. But it probably
should be made customizable.

RikiRemoval of this hardcoded stuff would require a bit of lyxhtml output
rewrite, which should be under way right now. Unfortunately, I think it's just one dev working on it (Thibaut).


After a lot of trial and error, using the last line I eliminated the
"div class="standard"" from the p element but still LyX assigns to it
an id="some number" which I want to eliminate too.

Any idea about it would be very welcome.

If you're referring to the "magicparlabel", it's hardcoded. I was thinking about making a patch to remove it, but LyX relies on this "magic labels" to do a lot of the referencing (a quick glance at how the TOC is done will give you an idea). I am not that knowlodgeable about HTML referencing, so this will take some time.


Yeahhhhhh, this is one of the reasons I don't use LyX for ePub. Last
time I looked, LyX exports used the deprecated and now with HTML5
eliminated <a name="whatever"/> inside a div specially made to contain
one <p></p>. What could *possibly* go wrong?

If I had to eliminate these redundant <div></div> things, I'd do it
with a postprocessor that corrects LyX' complexifications. It's not
easy, but you can use Python with the "import xml.etree.ElementTree as
ET" library. You'd analyze every DOM element, and for every <div/>
whose only purpose is to encase one <p/>, get rid of the div after
reading metadata from that <div/> and any <a name=> silliness, applying
the information to attributes of the <p/> itself.

Seriously, LyX has failed to export common sense XMLized HTML for 14
years now, and I doubt they ever will. Best you can hope for is to
either switch to another authoring program, or repair LyX' mistakes
post-export. I think trying to repair this stuff from within your LyX
document is walking the highway to heartache.

Also, the good thing about the XML-parsing Python post-processor
approach is that, as time goes on, you can fix any problems newly
discovered and/or newly added by LyX: You're in control as long as they
continue to export well-formed XML HTML, which of course isn't a
for-sure thing.

SteveT

Steve Litt
Summer 2022 featured book: Making Mental Models: Advanced Edition
http://www.troubleshooters.com/mmm

A solution of this kind could work well, but remove the thing that makes LyX so convenient: one click compile and show. We really need a robust LyXHTML output, and I don't think it's that far away.

Right now the devs lack the manpower to tackle LyXHTML problems fully, but I believe it's also a matter of demand. It's nice to see there are people on lyx-users asking about it.

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

Reply via email to