css editor not working correctly?

pviton's picture

SWP 6.0.29 on MS Win

Is the CSS Editor working correctly?

Open the Std Latex Article. Note that the section title
("Standard LaTeX Article") is tagged as |section| |sectiontitle|
[edited: using | for &gt and &lt which don't seem to
show up correctly]

Now open the CSS Editor and expand my.css
Select section>sectiontitle
Under Text > FontSize, type in 12pt
Back in the preceding screen, check Importance
Click Close

In the editing window, the section title is now displayed
in a smaller font, as you'd expect.

Now save and re-open the document.
The section title has reverted to its former size.
In the CSS Editor, under section>sectiontitle there
are no properties defined. In other words, nothing done in the
previous CSS Editor session seems to have had any effect.

(Incidentally, when you checked the Importance box, a little line
appears to the right of the box, suggesting that something
isn't appearing, that should be)

(Also, in the CSS Editor, what is the "Refresh" button
supposed to do? It appears to have no effect).

Am I doing something wrong, or is the CSS Editor not
working?

pviton's picture

George, thank you very much!

George, thank you very much! This is extremely helpful. I'd always been puzzled by how to know which rule(s) were actually in play, and your posting clears that up. Thanks again!

I don't think there's

I don't think there's anything wrong with the CSS Editor, but I do think you weren't able to select the rule that was actually being used to display the font size.

There is a way to get access to the DOM inspector tool that will allow seeing the css rules used for particular objects in a document.  To get access, go to the Preferences dialog, the Advanced icon, and with the Advanced preferences tab selected type "debug" into the Filter field.  Set the swp.debugtools item to be true (double click or right click and then select Toggle).  Use OK to close the open dialogs.  Now, start a new document window.  The Tools menu will now have additional menu items which includes DOM inspector.

Use File, New and start a new document using the Standard_LaTeX_Article shell and close any other document windows.  Select Tools, DOM inspector to open the DOM Inspector program.  From the DOM Inspector you can select File, Inspect Content Document, and then the available item which is the document open in SW.  You can then click on the icon on the left side of the address bar which is "Find a node to inspect by clicking on it" and then click the section heading in the document.  This will show you having selected sectiontitle that is below section that is below body that is below html that is below #document in the structure of the document.  You can now click the menu on the right side nect to the word Ojbect and select CSS Style Rules.  This shows the rules used to format the text.  When using the CSS Editor, you are changing my.css inside the document, but there are other imported rules that are used.  In particular, section>sectiontitle:first-child.  So, changes you were adding using the CSS Editor were probably being saved, but then not used as they were overridden by later rules (the last rule wins).

I wasn't able to figure out how to add a rule using the CSS Editor.  I did edit the document (by opening the .sci file and editing the my.css file inside the css directory, but this could also be done by editing the my.css file in the css directory of the _work directory while the document is open) and add the section>sectiontitle:first-child rules.  I was then able to use the CSS Editor to change the font size and have it retained by the document.

pviton's picture

May I follow up on George's

May I follow up on George's reply?

First, as I read the available options in the CSS Editor
it doesn't seem possible to change section>sectiontitle:first-child.
So if this rule is really being used to over-ride my attempt to
change section>sectiontitle, it seems that there's nothing you
can do about it. If so, this drastically reduces the usefulness
of the CSS Editor.

But second, I'm not sure that that's the whole problem here.
It looks to me as if there's still a problem with the CSS
Editor (though not quite the one I mentioned before).

I opened the Std Latex Article and in the CSS Editor I set
section>sectiontitle to display as 12pt, using the Text tab.
On the General tab I checked "Importance". Exiting the CSS Editor,
the section title was indeed displayed as 12pt. (I understand why:
the css cascade isn't revisited, so there's no way that an
over-ride can take hold).

I than saved and reopened the document. The section title was
in its original (bigger) font size. I opened the CSS Editor
and looked at the section>sectiontitle font-size rule. On the
General tab I could see that it was still marked as 12pt;
however, the Importance box was now unchecked.

At this point I used a text editor to open the my.css file in the
document's working directory on disk. As George said, the
section>sectiontitle entry had been changed. But there was
no indication that checking the Importance box had had
any effect. I added "!important" to this entry and saved my.css.
Back in SWP6 I saved the document, and re-opened it. This time
the section title size had changed. And in the CSS Editor, the
Importance box was now checked.

This suggests that the real problem was that the user's selection
of "Importance" in the CSS Editor is not being remembered.

Final question: I thought that the point of my.css was that it is
processed last, so that the user can modify/over-ride rules in
earlier css files. But I looked at all the lines in the css files
named for section>sectiontitle in the DOM Inspector, and as far
as I can tell, in none of them was the rule marked "important".
So I don't see why I needed to mark my change as "important" for
it to take hold --- unless my.css isn't the last css file read. Is it?