-
Notifications
You must be signed in to change notification settings - Fork 19
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
Multi-line text blocks #278
Comments
I agree that we need them. I foresee style properties governing their font size, dimensions, borders and padding/margins in a natural way. Ultimately there should be a way of including these elements directly in a <score>
<page>
<system .../>
<text-block .../>
<system .../>
</page>
</score> |
I like this in general. We should say that any element that has String content (not an attribute) should be changed to take a Caveats:
|
Instead of specifying a list of HTML tags like For example, here are two examples of credits from a hymnal. The formatting includes:
|
Apparently, we can have an element that is a block of HTML if we import the XHTML namespace into our schema. That looks quite promising, especially for larger blocks like the ones envisaged by @joeberkovitz above. @mdgood Does that make sense to you? |
I'm still not sure if we should go down this road, but defining If
Note that spans and paragraphs can have a class. Presumably, those could be defined locally or inherited from the Something that's bothering me:
Can I simply assume that the |
I think it would make sense to have something like I'm not sold on the name |
Instead of saying "only these HTML elements are supported," which breaks from the recommendation in the StackExchange link above and prevents us from using the XHTML schema for validation, would it be better to say something like: "Any valid HTML [or XHTML?] content is allowed, but support for rendering complex HTML may vary between applications. Applications that render MNX are expected to support, as a minimum, these common HTML elements inside This leaves the door open for browser-based applications to use the automatic browser rendering of the HTML, instead of having to parse through the HTML and strip it down to the artificially limited list defined by MNX – and at the same time, it allows flexibility for non-browser-based applications that may not want, or may not be able to include a full webview in their app. |
@notator I don't understand this issue. In XML you have multi-line text blocks by including line breaks in the element text. If you want to indicate that applications don't strip them, you can add an The XHTML ideas are interesting for other aspects of styling, but they seem unnecessary for multi-line text. So perhaps that discussion could be moved to a different issue? |
Ah, thanks, I didn't know that. @samuelbradshaw:
Currently, the docs define specialised elements for |
Unfortunately, this isn't always true, and when it is true, it may not be what is intended. Newlines can be stripped with standard XML tools, regardless of the value of Given: <?xml version="1.0" encoding="UTF-8"?>
<p xml:space="preserve" xmlns:xml="http://www.w3.org/XML/1998/namespace">
This is some text
split over several lines
to test whether whitespace is correctly
handled.
</p> An xPath query of
Namely, that a) newlines are stripped but b) indent spaces are preserved. This is likely the opposite of what was intended. Trying another xPath query, <?xml version="1.0" encoding="UTF-8"?>
<root>
<section>
<subsection>
<p xml:space="preserve" xmlns:xml="http://www.w3.org/XML/1998/namespace">
This is some text
split over several lines
to test whether whitespace is correctly
handled.
</p>
</subsection>
</section>
</root> Results in
Trying to normalize spaces, an xPath query of
In this case, the indent spaces are collapsed, but the newlines are still not preserved. A good explanation of the issues are given on this page: http://www.xmlplease.com/xml/xmlspace/ The reason many XML and XML-like schemas (HTML being the main one) even bother with elements like I would be interested in examples to the contrary! |
@ahankinson The string() function is doing exactly what it should, returning all the text, and normalize-space is also working exactly as one would expect. I'm not sure what I would expect text() to do since it's a node test rather than a function. Pretty-printing text content won't work if you are using MusicXML applications have been exchanging exact text content with line breaks for nearly 20 years without problems. The way MusicXML does styling is something that MNX could improve, but line breaks work just fine. |
If I were to rephrase this to try and understand, are you saying that you need to ensure that you have no "non-significant" (e.g., indent spaces) whitespace in your text blocks? So your text blocks should be left-aligned, like an HTML If I take the following literal XML:
And put it in the Atom text editor, set it to XML, and then choose "Beautify language: XML", it becomes:
So although Atom is a pretty standard and widely-used tool, but it's "formatting" behaviour does not assume that newlines have significance. Even If I take a more XML-aware application, like oXygen, and do the same, the first example becomes the following if I choose the 'indent selection' option (having selected the whole file, all other indents are the same): <?xml version="1.0" encoding="UTF-8"?>
<root>
<section>
<subsection>
<p xml:space="preserve">
This is some text
with some whitespace
to test how it works.
</p>
</subsection>
</section>
</root> If I choose "Format and Indent" and have "xml:space="preserve"" that it behaves as expected. While we can argue whether this is correct behaviour, these examples at least show that you cannot necessarily rely on the various transformations that an XML file may go through to preserve the linebreaks and whitespace as intended. MusicXML has had the advantage that most applications that consumed MusicXML used XML only because they wanted to use MusicXML, and few people (other than developers) actually worked with the XML source directly. This is fine as an interchange format, but if you want to use MNX as XML proper, and have it work consistently with a wide range of generic XML tools, then you will likely need additional text formatting elements. Edit: It also occurs to me that there will be problems with long text blocks. Editors, human or software, sometimes impose a limit on line length, after which they wrap the text with a newline for ease of reading in the editor software. If all spaces were preserved then this would mean that text would be flowed according to the line length of the XML source inn the editor, rather than allowing the text to fill the rendered width. |
For exact space you would more likely want:
All your examples seem to fall into the category of "I tell my tool to reformat the text and then it does it" so I don't understand how they are relevant to MNX. I think MNX has similar XML tooling requirements to MusicXML. You want it to work with tools like parsers available in different languages, editors, differencing tools, and databases. All of those work just fine with standard XML line breaks and white space. If you don't want your white space to change, don't tell your tool to change them. |
I provided small examples for clarity; often, when editing large files you won’t have the opportunity to choose what parts it reformats and what parts it doesn’t. The atom example is a fairly naive, but fair one. I open an existing MNX file, insert some XML and then ask the tool to reflow the XML. At this point it will reflow the whole file, and remove any line breaks from text content. I may not even be aware that it changed it as it might be in a different part than I was editing. Again, my point isn’t that this tool is or isn’t “behaving” correctly. My point is that I was, with very little effort, able to come up with several examples of where widely used software tools, in fairly naive usage instances, can remove whitespace characters, and the only way to absolutely guarantee that text formatting is preserved across editors is to encode it with dedicated elements.
What are these tooling requirements? |
Sure, so don't ask your editor to reflow the XML. Most editors will format things just fine as you insert them without having to ask to reformat the whole file. Most MNX text editing will likely be like MusicXML text editing. That usually involves making small edits for testing and debugging new features in your app, or less commonly, doing some hand-editing for features you don't export. The tooling requirements I had in mind are listed right after the sentence you quoted. |
@mdgood said
Its much easier to deal with The problem I had, when opening this issue, was that I didn't know how to define an element containing mixed text and elements in a schema. However, immediately after my last posting, I discovered the "mixed" attribute for the schema language's "complexType", and all was sweetness and light. Our A simple
A more complex one currently looks like this:
We need to discuss precisely which attributes
@joeberkovitz envisions style, and possibly other properties for I've now tested this helloTextBlock.mnx
|
It sounds like there's consensus that multi-line text blocks are needed. The two potential solutions discussed above are 1) just using XML's built-in I also agree that we need "style properties" for these text elements as mentioned by @joeberkovitz. Style properties could be broken out into two categories: Formatting (what the element itself looks like, including its size and padding) and positioning (how the element positions itself on the page relative to sibling elements). Should formatting and positioning be separate issues, or discussed here? |
Multi-line text blocks have been discussed before, but we don't seem to have reached any conclusion. I think we need them, and that they would be of general use.
In #277, I used a temporary strategy that involved defining the following two elements:
<string>
:text
(a String): defines a string of text that will be rendered in a single line.<text-block>
:<string>
elements that define the lines of a multi-line text block.Can this be improved? Is there a better way to do it?
The text was updated successfully, but these errors were encountered: