udoprog / c10t

A minecraft cartography tool
Other
225 stars 50 forks source link

JSON output for signs #114

Closed EdGruberman closed 10 years ago

EdGruberman commented 13 years ago

Sometimes signs will be prefixed with the word "Sign" for their text property. I think it's when there is no characters on the first line of the sign. The word "Sign" should not appear if it's not actually text on the sign.

Also, it would be fantastic if you kept all the whitespace(newline characters and spaces) on a sign intact in the text property. Whitespace is used very avidly for spacing characters out on signs. When trying to reduplicate the appearance of a sign on a Google map interface, it's impossible to do accurately without all that information available.

Hawk777 commented 12 years ago

The first part already exists. Use the "--strip-sign-prefix" option. For the second part, newlines at least are preserved, I don't know about extra spaces.

uap-universe commented 12 years ago

The clue is that for keeping the spaces intact they must be converted to   characters. This would look nice in HTML environments as google maps but might not be suitable for other purposes. So we need to think about "where" to inject the conversion algorithm. (It should be as closest to the google maps as possible).

I will have a look at it, but I can't tell when.

Hawk777 commented 12 years ago

Indeed I happen to display the text in a JavaScript message box, so I wouldn't want HTML escapes all over the place. Also, theoretically, there's no reason why JSON output necessarily has to go to a Web browser at all: JSON is just a transport format. If you're putting the text into a Web page, it should be formatted at that point, not before (besides which, if you want to maintain newlines, you'd have to insert BR elements which can't be done in literal text via a DOM text node anyway; you have to insert element nodes). Shouldn't take too much JavaScript to split the string by newlines into individual lines and do the proper DOM manipulation though.