Better formatting for interlinears on the ZBB

Discussions worth keeping around later.
Post Reply
chris_notts
Avisaru
Avisaru
Posts: 275
Joined: Wed Dec 15, 2004 9:05 am
Location: Nottingham, England
Contact:

Better formatting for interlinears on the ZBB

Post by chris_notts »

I was wondering if it would be possible to add better support for formatting interlinear glosses to a phpbb board like the ZBB. A while ago I developed a small plugin for the dokuwiki software, that forced the morphemes in interlinear glosses to align by using tables. I've also build something similar into the new version of my blog. There's a page on that here, complete with PHP source code and an example of what it does:

http://www.chrisdb.me.uk/wiki/doku.php? ... oss_plugin

After you've packed everything into tables all you need is to apply some CSS to force the browser to display them inline and remove any borders. When I first looked at this a long time ago, I also looked at using the ruby tags, but a lot of browsers don't support them properly so inlined tables is a better approach.

It seems like this is something that would be pretty useful for something like the ZBB, given that we mostly talk about linguistics. It's a real pain when people do interlinears and the lengths of the morphemes don't line up, so it's hard to figure out which bit is which.

I've googled to find out what support phpBB has for custom tags, and it looks like it basically just done very simple find and replace using regexes. This wouldn't be enough to do the interlinears using tables. Since that's the case, it looks like you're probably have to just tag the interlinears using a span tag or similar, and then use some custom javascript to build the tables on the client-side.

Doing this shouldn't be too difficult. It would involve:

1. setting up custom tags [interlinear] which translate into <span class="interlinear">
2. writing a simple javascript function that scans through a page looking for <span class="interlinear"> and replaces it with the inlined tables, using approximately the algorithm outlined above. Each table needs to have class "interlinear"
3. adding a bit of css to inline tables with class "interlinear" and remove borders / other unwanted formatting

Is anyone else interested in this? Zompist, are you interested?
Try the online version of the HaSC sound change applier: http://chrisdb.dyndns-at-home.com/HaSC

User avatar
Torco
Smeric
Smeric
Posts: 2372
Joined: Thu Aug 30, 2007 10:45 pm
Location: Santiago de Chile

Re: Better formatting for interlinears on the ZBB

Post by Torco »

excellent it would be
Implemented, however, I think not
nevertheless with it best of luck

zompist
Boardlord
Boardlord
Posts: 3368
Joined: Thu Sep 12, 2002 8:26 pm
Location: In the den
Contact:

Re: Better formatting for interlinears on the ZBB

Post by zompist »

If you want to try to do the work, go for it. :)

So long as spinn is hosting, I can change templates and stylesheets; I can't change any PHP files.

The thing is, the changes have to be isolated enough that they can be reapplied with phpbb updates. That is, if you change the code in a hundred places, it's not going to be easy to reapply.

chris_notts
Avisaru
Avisaru
Posts: 275
Joined: Wed Dec 15, 2004 9:05 am
Location: Nottingham, England
Contact:

Re: Better formatting for interlinears on the ZBB

Post by chris_notts »

I guess I'll probably try to code it up in Javascript in the next week or two. When I have something that works I'll post again and ask for volunteers to test it.
Try the online version of the HaSC sound change applier: http://chrisdb.dyndns-at-home.com/HaSC

User avatar
Hakaku
Lebom
Lebom
Posts: 132
Joined: Sat Feb 03, 2007 12:55 pm
Location: 常世

Re: Better formatting for interlinears on the ZBB

Post by Hakaku »

Actually, PhpBB3 possesses the ability to add and create new BBCode through the admin panel, which essentially consists in creating rules to replace [tags][/tags] with appropriately formatted HTML. Though you wouldn't be able to use the php code linked, you could easily find an alternative solution mixing html and css.

http://www.phpbb.com/kb/article/adding- ... in-phpbb3/
Chances are it's Ryukyuan (Resources).

User avatar
Mecislau
Avisaru
Avisaru
Posts: 491
Joined: Thu Jul 24, 2003 2:40 pm
Location: Maryland
Contact:

Re: Better formatting for interlinears on the ZBB

Post by Mecislau »

Instead of tables, might I recommend something like what I did on this page in the Novegradian grammar? The overall appearance is the same, but it has a number of advantages:

1) It wraps correctly. Long tables will need manual breaks or will stretch the page, whereas the method I used using definition tags + some CSS wraps all by itself

2) The code is a bit nicer, since it keeps the words and the glosses for each word together in the code. In a table, you would have a single row of the native language followed by a row of glosses, which for long sentences could mean the original language and gloss are confusingly far about in the HTML.

3) If you care at all, it's a bit more semantic than tables are, since definition lists come a bit closer to glosses than plain old tables do.

In the HTML, it just works as a long series of definition items, like this:

Code: Select all

<div class="glossblock">
	<dl>
    	<dt>Вецераш,</dt>
        <dd>Véceraś,<br>yesterday</dd>
    </dl>
    <dl>
    	<dt>дуадеши</dt>
        <dd>duadéśi<br>twenty</dd>
    </dl>
    <dl>
    	<dt>цедиртий</dt>
        <dd>cedírtij<br>fourth</dd>
    </dl>
    ...
</div>
And the CSS is just:

Code: Select all

.glossblock
{
	clear: both;
	font-size: 12px;
	padding-top: 5px
	padding-bottom: 5px;
}

.glossblock dl
{
	float: left;
    margin: 0 0.5em 0.5em 0;
    text-align: left;
}

.glossblock dt
{
	font-style: italic;
}

.glossblock dd
{
	margin-left: 0cm;
}

chris_notts
Avisaru
Avisaru
Posts: 275
Joined: Wed Dec 15, 2004 9:05 am
Location: Nottingham, England
Contact:

Re: Better formatting for interlinears on the ZBB

Post by chris_notts »

Mecislau wrote:Instead of tables, might I recommend something like what I did on this page in the Novegradian grammar? The overall appearance is the same, but it has a number of advantages:

1) It wraps correctly. Long tables will need manual breaks or will stretch the page, whereas the method I used using definition tags + some CSS wraps all by itself
In fact, what I did before was a table for each word to make the morphemes within the word align properly. The words automatically align properly because they're in different tables. In your example, it doesn't look like the within-word morphemes line up? Although I guess it could be tweaked to do that, although what it can't do is prevent wrapping in the middle of a word if you use a separate definition for each morpheme.
2) The code is a bit nicer, since it keeps the words and the glosses for each word together in the code. In a table, you would have a single row of the native language followed by a row of glosses, which for long sentences could mean the original language and gloss are confusingly far about in the HTML.
That's true.
3) If you care at all, it's a bit more semantic than tables are, since definition lists come a bit closer to glosses than plain old tables do.

In the HTML, it just works as a long series of definition items, like this:

Code: Select all

<div class="glossblock">
	<dl>
    	<dt>Вецераш,</dt>
        <dd>Véceraś,<br>yesterday</dd>
    </dl>
    <dl>
    	<dt>дуадеши</dt>
        <dd>duadéśi<br>twenty</dd>
    </dl>
    <dl>
    	<dt>цедиртий</dt>
        <dd>cedírtij<br>fourth</dd>
    </dl>
    ...
</div>
And the CSS is just:

Code: Select all

.glossblock
{
	clear: both;
	font-size: 12px;
	padding-top: 5px
	padding-bottom: 5px;
}

.glossblock dl
{
	float: left;
    margin: 0 0.5em 0.5em 0;
    text-align: left;
}

.glossblock dt
{
	font-style: italic;
}

.glossblock dd
{
	margin-left: 0cm;
}
Last edited by chris_notts on Wed Oct 19, 2011 2:58 am, edited 2 times in total.
Try the online version of the HaSC sound change applier: http://chrisdb.dyndns-at-home.com/HaSC

chris_notts
Avisaru
Avisaru
Posts: 275
Joined: Wed Dec 15, 2004 9:05 am
Location: Nottingham, England
Contact:

Re: Better formatting for interlinears on the ZBB

Post by chris_notts »

Hakaku wrote:Actually, PhpBB3 possesses the ability to add and create new BBCode through the admin panel, which essentially consists in creating rules to replace [tags][/tags] with appropriately formatted HTML. Though you wouldn't be able to use the php code linked, you could easily find an alternative solution mixing html and css.

http://www.phpbb.com/kb/article/adding- ... in-phpbb3/
I already mentioned that. But I don't believe that the find and replace functionality it offers is powerful enough for what we want to do. I don't want to force users to manually build the tag structure. What should happen is this:

Code: Select all

[interlinear]
hola, como esta-s?
hello, how are-you?
[/interlinear]
And then each line is broken up based on white space and morpheme markers (like -) and turned into the appropriate HTML. As far as I can see, the only way to do it all using the built in functionality is to force the user to use tags to manually specify a lot more of the structure, which is such a pain that no-one will use it.
Try the online version of the HaSC sound change applier: http://chrisdb.dyndns-at-home.com/HaSC

Trailsend
Lebom
Lebom
Posts: 169
Joined: Fri Mar 27, 2009 5:50 pm
Contact:

Re: Better formatting for interlinears on the ZBB

Post by Trailsend »

Mecislau wrote:Instead of tables, might I recommend something like what I did on this page in the Novegradian grammar?
Ooooh now see, I tried to do this on the Feayran site but couldn't figure out a good way to make it work--didn't think to use definition lists. Brilliant!

(Code question: why do you use br tags? Does adding additional dd tags break it?)

Aligning morphemes within the word would be nice, but as Chris says, I'm pretty sure that'd require a good deal of markup to be added to the text. Too much work to do manually, but so long as zompist can add javascript to the page templates, that could work.

Alternatively, Mecislau's system could be implemented pretty easily with some custom bbCode.

chris_notts
Avisaru
Avisaru
Posts: 275
Joined: Wed Dec 15, 2004 9:05 am
Location: Nottingham, England
Contact:

Re: Better formatting for interlinears on the ZBB

Post by chris_notts »

Trailsend wrote:
Mecislau wrote:Instead of tables, might I recommend something like what I did on this page in the Novegradian grammar?
Ooooh now see, I tried to do this on the Feayran site but couldn't figure out a good way to make it work--didn't think to use definition lists. Brilliant!

(Code question: why do you use br tags? Does adding additional dd tags break it?)

Aligning morphemes within the word would be nice, but as Chris says, I'm pretty sure that'd require a good deal of markup to be added to the text. Too much work to do manually, but so long as zompist can add javascript to the page templates, that could work.
I think it can be done easily by the Javascript solution I proposed, whether that's using tables or definition lists. We apply a simple rule on the board that translations [interlinear] to <span class="interlinear"> then include a small Javascript function that scans through and builds the tables / definition lists afterwards on the client side.

Doing it this way also isn't harmful, because if the user for some reason doesn't have javascript enabled, they just get the non-aligned version with a harmless span tag that doesn't really make any difference to formatting.

I think it has to be done this way whether you use tables or definition losts, because otherwise the user has to manually apply a lot of tags to each word/morpheme that will make it too painful to use. Really, the goal has to be that the extent of user intervention required is wrapping their interlinears with [interlinear] and [/interlinear].

That's basically how my home grown blog works, although that's coded up in Haskell on the server side rather than Javascript. See more examples using tables here:

http://chrisdb.dyndns-at-home.com/blog/ ... -agreement
Try the online version of the HaSC sound change applier: http://chrisdb.dyndns-at-home.com/HaSC

Cedh
Sanno
Sanno
Posts: 938
Joined: Tue Nov 14, 2006 10:30 am
Location: Tübingen, Germany
Contact:

Re: Better formatting for interlinears on the ZBB

Post by Cedh »

Trailsend wrote:
Mecislau wrote:Instead of tables, might I recommend something like what I did on this page in the Novegradian grammar?
Ooooh now see, I tried to do this on the Feayran site but couldn't figure out a good way to make it work--didn't think to use definition lists. Brilliant!

(Code question: why do you use br tags? Does adding additional dd tags break it?)
No, it doesn't. HTML syntax supports several definitions for one item, and the CSS for this type of interlinears does so as well. (I've implemented the same thing as a MediaWiki template for use on both AkanaWiki and FrathWiki, using additional dd tags for additional gloss lines.)

User avatar
Mecislau
Avisaru
Avisaru
Posts: 491
Joined: Thu Jul 24, 2003 2:40 pm
Location: Maryland
Contact:

Re: Better formatting for interlinears on the ZBB

Post by Mecislau »

cedh audmanh wrote:
Trailsend wrote:
Mecislau wrote:Instead of tables, might I recommend something like what I did on this page in the Novegradian grammar?
Ooooh now see, I tried to do this on the Feayran site but couldn't figure out a good way to make it work--didn't think to use definition lists. Brilliant!

(Code question: why do you use br tags? Does adding additional dd tags break it?)
No, it doesn't. HTML syntax supports several definitions for one item, and the CSS for this type of interlinears does so as well. (I've implemented the same thing as a MediaWiki template for use on both AkanaWiki and FrathWiki, using additional dd tags for additional gloss lines.)
Oh, hah, whoops. That was just a silly oversight on my part.


And yeah, writing a simple parser in Javascript would not be a problem at all.

Post Reply