Live data from Hacker News

Overlapping markup

en.wikipedia.org

11–20 of 48 posts

Re: Overlapping markup

#12
I've frequently wondered why a hierarchical approach is the norm for text formatting. It seems that many problems could be solved trivially using a text buffer and a list of formatting sequences defined by a starting index and a length. The only place I've seen this in practice is in Telegram's TL Schema [1]. Is this method found anywhere else?

Edit to note: there is one obvious advantage to in-band markup such as HTML -- streaming formatted content. Though I wonder if this could be done with a non-hierarchical method, for example using in-band start tags which also encode the length.

Edit 2: looks like Condé Nast maintains a similar technology called atjson [2].

[1]: https://core.telegram.org/api/entities

[2]: https://github.com/CondeNast/atjson

Re: Overlapping markup

#13

I've frequently wondered why a hierarchical approach is the norm for text formatting. It seems that many problems could be solved trivially using a text buffer and a list of formatting sequences defined by a starting index and a length. The only place I've seen this in practice is in Telegram's TL Schema [1]. Is this method found anywhere else? Edit to note: there is one obvious advantage to in-band markup such as HT…

That list of formatting sequences would have to be updated with new indexes when the content of the buffer changed. Keeping the two in sync wouldn't be trivial (for a computer or a human), a tree of nodes fixes that and works for 99.99% of use cases.

Re: Overlapping markup

#14

I've frequently wondered why a hierarchical approach is the norm for text formatting. It seems that many problems could be solved trivially using a text buffer and a list of formatting sequences defined by a starting index and a length. The only place I've seen this in practice is in Telegram's TL Schema [1]. Is this method found anywhere else? Edit to note: there is one obvious advantage to in-band markup such as HT…

I guess because it would be a total pain for humans to read and write without specialised tooling. Imagine trying to add a word at the start of your document.

Re: Overlapping markup

#16

Can someone summarize this? 90% of the content on this page seems like excessively-verbose nonsense.

Many, if not most, computer models represent data as a tree. Some data, however, can't really be represented by a tree, because a "thing" can have multiple parents.

The example in the link:

Example, with lines marked up:

  I, by attorney, bless thee from thy mother,

  Who prays continually for Richmond's good.

  So much for that.—The silent hours steal on,

  And flaky darkness breaks within the east.
With sentences marked up:

  I, by attorney, bless thee from thy mother,
  Who prays continually for Richmond's good.

  So much for that.

  —The silent hours steal on, And flaky darkness breaks within the east.
If you care about lines and sentences, this is difficult to represent as a tree.

Re: Overlapping markup

#17

This Wikipedia article is sorely lacking concrete examples to help aid understanding.. Anyone care to add some examples to the article??

overlapping b and i elements he ll o w or ld contary to the article it can still be represented as a tree, by decomposing the children into their own nodes (so in this case characters become nodes with child nodes expressing what formatting is active, followed by the letter, and then turn of all the active formatting)

No that's just nesting. It's overlapping if the lifetime of a child tag is greater than the lifetime of the parent tag.

Example if you have two paragraphs and bold the end of one and the start of the next

hello world

this is your captain speaking

Obviously bold is a poor example as you can just terminate and start a new bold without penalty. But if these were more semantic elements like "sections" and "verses" and "lines" then it might not be possible.

Re: Overlapping markup

#18

I've frequently wondered why a hierarchical approach is the norm for text formatting. It seems that many problems could be solved trivially using a text buffer and a list of formatting sequences defined by a starting index and a length. The only place I've seen this in practice is in Telegram's TL Schema [1]. Is this method found anywhere else? Edit to note: there is one obvious advantage to in-band markup such as HT…

That list of formatting sequences would have to be updated with new indexes when the content of the buffer changed. Keeping the two in sync wouldn't be trivial (for a computer or a human), a tree of nodes fixes that and works for 99.99% of use cases.

It may not be trivial, but it's a solved problem. Many rich text UI widgets and corresponding backing data structures exist today, based on a tagging system where tags can trivially define regions that overlap with each other. It's tricky and full of corner cases, but not that hard if you put your mind to it, and it's not computationally inefficient either.

Re: Overlapping markup

#19

Change my view: given any data storage medium, the smallest granularity of data must also be the most-child element of any markup language. Given the immense overhead of storing markups on a granular level, processing markup therefore must be a perpetual exercise in recursion. I.e. Poem->Verse->Line-> Book->Page->Chapter->Paragraph->Sentence->Word-> HTML->Body->Div->P-> Therefore, any given letter (here as a type) ca…

Are you claiming the parents will always be unique? Because as the article says, you can easily have this, where going to the right is a parent relationship:

                  -> Line -> Verse -> Poem
    char -> Word
                  -> Clause -> Sentence -> Poem
You can try adding a further constraint that any given property must have only one path, so you can then recurse over the tree and find the one match, but as your model gets richer you will find that breaks.

And it's that last clause that is the killer for pretty much anything: "As your model gets richer you will find that breaks."

Plus the UI experience for that is awful. "I want to add this property to this Line but you're telling me it's a duplicate for some particular character? What the hell does that mean? I'm not adding a property to the character!" etc. etc.

Re: Overlapping markup

#20

This Wikipedia article is sorely lacking concrete examples to help aid understanding.. Anyone care to add some examples to the article??

SGML's CONCUR feature (criticized but not described in that Wikipedia article) allows tags to have optional name groups specifying one or more document type names (that must be declared in the prolog) to which the tag applies, and allows tag pairs with disjoint document type name qualifiers to overlap like this:

bla bla

Traditionally used for poetry and lyrics/drama but could also be useful for postal addresses, lyrics in certain types of musical notation, in translations, and maybe specific text apps such as subtitles/tracks for the hearing impaired. Basically, wherever there's a desire to markup text in more than a single hierarchy.

Post reply on HN