Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Knowls should open above display math #515

Closed
davidfarmer opened this issue Jan 28, 2017 · 25 comments
Closed

Knowls should open above display math #515

davidfarmer opened this issue Jan 28, 2017 · 25 comments

Comments

@davidfarmer
Copy link
Contributor

In a paragraph of the form

words knowl words
display math
more words

the knowl should open above "display math", but currently it opens below "more words".

Even though all of this is actually one true paragraph, the fix is make "words knowl words"
and "more words" into their own p paragraphs in html.

Related to issue #364 .

@rbeezer
Copy link
Collaborator

rbeezer commented Jan 28, 2017

#364 has a different root cause and will get solved by reogranizing structure of the output.

After initial revulsion at the fiddly work necessary for this, I realized it should just be a trivial extension of the very complicated XSL at 92764e2 (lists in paragraphs). That was of necessity, since browsers did not like lists in paragraphs. This is elective to accomodate knowl design/behavior.

If we are going to carve author's logical paragraphs into many HTML p, can we use CSS to preserve that distinction?

Suppose a style indents, or otherwise visually indicates a paragraph start. We want that to happen if, and only if, the new p's are from the start of an author's paragraph. Not a serious suggestion for names, but serious about function: one p.true-paragraph followed optionally by many p.fake-paragraph. If you agree and provide class names, I can incorporate them as part of making this happen.

@davidfarmer
Copy link
Contributor Author

davidfarmer commented Feb 1, 2017 via email

@rbeezer
Copy link
Collaborator

rbeezer commented Feb 1, 2017 via email

@davidfarmer
Copy link
Contributor Author

davidfarmer commented Feb 1, 2017 via email

@rbeezer
Copy link
Collaborator

rbeezer commented Feb 3, 2017

I think I can prevent empty paragraphs from being emitted. But if there is no first paragraph, there needs to be an HTML id there so cross-references (think index entries) have something to land on via an "in-context" link for the original (authored, logical) paragraph.

First thought: drop an empty div with id where first paragraph goes. Problem: no, or minimal, pink flash.

Second thought: wrap entire sequence of HTML elements (p, lists, display math) in one big div that is the logical paragraph. This would carry the id and light up with pink flash. Paragraph spacing CSS could apply to the big div. Still break up the paragaph into pieces withing the big div. "p", etc, within could get less pronounced spacing. Knowls would open below the hext "p", etc, that carve up the paragraph?

Not serious, but for intent: div.logical-paragraph.

Would this be a better plan? Not the motivation, but it would also be easier to skip empty paragraphs if the above features were extracted top an enclosing div.

@davidfarmer
Copy link
Contributor Author

davidfarmer commented Feb 3, 2017 via email

@rbeezer
Copy link
Collaborator

rbeezer commented Feb 3, 2017 via email

@davidfarmer
Copy link
Contributor Author

davidfarmer commented Feb 3, 2017 via email

@rbeezer
Copy link
Collaborator

rbeezer commented Feb 3, 2017 via email

@rbeezer
Copy link
Collaborator

rbeezer commented Feb 5, 2017

Dear David,

Two paragraphs in new Section 12.7. Both have index entries. First paragraph is normal. Second starts with a list and then has some content.

Second becomes three peers. A p with the id of the paragraph, then the li, and then the p with the rest.

Go to index, find "paragraph" entry. Open knowl for each, then use "in-context" for each. First will pink-flash, as it should. Second does not - because there is no there there.

http://mathbook.pugetsound.edu/examples/sample-article/html/section-12.html#subsection-28

Rob

@davidfarmer
Copy link
Contributor Author

davidfarmer commented Feb 5, 2017 via email

@rbeezer
Copy link
Collaborator

rbeezer commented Feb 5, 2017

Dear David,

Yes, I agree the example is not reasonable. But I have seen single lists in paragraphs as their only content. Maybe they should become "named" lists.

The automatic id scheme, which is used for many, many things, reflects source structure, not output structure. So a -c1, -c2, would be a big departure. And deciding how such a paragraph splits up is very complicated in XSL - so probably not something to do repeatedly (which might be necessary).

The lack of an "id" is not the problem. The id of the logical paragraph is on the first carved-up paragraph, which is empty. So the in-context cross-reference goes to the right place, but there is no content for the pink-flash to illuminate. There is nothing in the HTML preserving the author's intent of grouping certain material in a (logical) paragraph.

Let me more carefully suggest the overall div and you can more carefully object.

One new class: div.logical-paragraph

  1. The spacing around the div is identical to that of a regular paragraph (an author's paragraph, that is not carved up).

  2. A "p" within the div gets no extraordinary spacing to set it off. Just enough to transition from lists and display math. Other than a list in a "named list", this is the only place a list or display math can occur. iff. (DTD says so.)

  3. The enclosing div gets the logical paragraph HTML id and the pink-flash works as elsewhere.

  4. div is trivial for me to implement and maintain. And if I don't have to place an id somewhere (first paragraph, maybe empty) than I can comfortably throw out empty stuff (like if a list and display math were consecutive with no carve-up paragraph between).

Seems you get a new class one way or the other, $n-1$ "continuation" paragraphs, or 1 "logical-paragraph". The latter carries more information, and preserves the author's intent.

This decomposition is one of the most complicated things I've put together. I really do not want to over-complicate it. I think the above is an improvement on current code, even for rationally-authored paragraphs.

Rob

@davidfarmer
Copy link
Contributor Author

I (quickly) re-read this thread, and still think that class="continuation" is the preferred solution.

There may be cases where 1 "logical-paragraph" contains more information than $n-1$
"continuation" paragraphs, but in typical use cases they provide the same information.
In terms of styling, they are the same. In terms of the pink flash, it is true that different
amounts of text will flash. I can construct examples where either is preferred, so it seems
reasonable to just flash the minimal amount which contains the reference.

The index example with a reference list needs to be fixed. That beings the separate problem:
does in-context to a list flash one list entry, or the whole list? What if it is a paragraph in
a list item. Those seem independent of this issue.

@rbeezer
Copy link
Collaborator

rbeezer commented May 10, 2017

I will try continuation.

Question 1. What happens if first paragraph is empty. Very bad style, but it happens. I can proceed, but ideas welcome.

Question 2. If additionally, the content of author's logical paragraph is wrapped in a div with no class, but just an id as target for cross-reference, will bad things happen? I might make a test instance.

@rbeezer
Copy link
Collaborator

rbeezer commented May 15, 2017

Splitting paragraphs up in HTML output the same way it was done to accomodate lists (a simple modification of that routine). Testing below applies this to paragraphs where born, but not inside of knowl content (tedious duplication I will do once debugged).

  1. Disclaimer: perhaps not consistent with significant parts of above discussion. Take this as a starting point, not a fait accompli.
  2. Testing example is Subsection 4.8 of beta sample articles below.
  3. Display math is now naked at top-level. In other words it has no extra wrapping and is a child of article or similar. It could be wrapped easily.
  4. "continuation" version has an initial paragraph with the id of the logical paragraph. Subsequent paragraphs have continuation class.
  5. "continuation-div" wraps the whole logical paragraph and places the label of the logical paragraph onto this div, rather than on the initial split-out paragraph. Otherwise identical to above.
  6. Two index entries, which will behave very differently in two beta versions. paragraph!empty target, and paragraph!three pieces
  7. First paragraph of the sequence could easily get a class. And/or all un-split paragraphs could get a class, same or different.
  8. Test has "bad" paragraph with empty paragraph. That's where the id goes. So I can only omit it if the id has some other home.

http://mathbook.pugetsound.edu/beta/continuation-20170515

http://mathbook.pugetsound.edu/beta/continuation-div-20170515

@davidfarmer
Copy link
Contributor Author

davidfarmer commented May 15, 2017 via email

@davidfarmer
Copy link
Contributor Author

davidfarmer commented May 15, 2017 via email

@Alex-Jordan
Copy link
Contributor

Lightly following this, not the details. I will just say that the one place I see display math at the start of a p is when the p is in a list item. For example, in a multi-part exercise (either its statement or its solution).

I could maybe be convinced that this is inappropriate too, and that it should be inline math with \displaystyle, or using \begin{aligned} instead of an md.

I could maybe be convinced that the list item should just have the math content instead of being wrapped in a p, but it has been nice to just consistently use p within list items and not worry about doing one thing sometimes and another thing other times.

@davidfarmer
Copy link
Contributor Author

davidfarmer commented May 15, 2017 via email

@rbeezer
Copy link
Collaborator

rbeezer commented May 15, 2017 via email

@davidfarmer
Copy link
Contributor Author

davidfarmer commented May 15, 2017 via email

@rbeezer
Copy link
Collaborator

rbeezer commented May 15, 2017 via email

@rbeezer
Copy link
Collaborator

rbeezer commented May 15, 2017 via email

@rbeezer
Copy link
Collaborator

rbeezer commented May 15, 2017 via email

@rbeezer
Copy link
Collaborator

rbeezer commented Jul 3, 2017

The bust-up routine for HTML output of PTX paragraphs into HTML paragraphs now accomodates the four types of display mathematics (me, men, md, mdn). At c2d02ee.

There will always be an empty HTML paragraph in output as original content if a PTX paragraph begins with a list or display mathematics. It carries the HTML id for the authored paragraph. Empty paragraphs are not output for duplicate content. It may still be possible to provoke an empty HTML paragraph partway through - an example in the sample article shows that one such attempt will fail. Basically this is due to punctuation post-math migrating into the display and leaving "nothing" behind.

Erring on the side of caution, so that no real content gets ignored.

I would still like to see a div enclosing the entire content of the PTX-authored paragraph, in part as a natural place for the original paragraph's ID, for tracking purposes, and because experience tells me that there may be unanticipated reasons we will be glad we have it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants