PDA

View Full Version : A comic-link parser?



Capt Spanner
2010-10-17, 09:19 PM
How tricky would it be to add a BBCode tag that parsed this:

123

to this:

123 (http://www.giantitp.com/comics/oots0123.html)?


If my very vague knowledge of BBCode is correct, it would be easier than the dice roller, and would probably be a very welcome addition.

I believe adding the following to the parser should work (assuming the parser works something like this one (http://www.php.net/manual/en/function.bbcode-create.php#93349):


case 'comic' :
$url_num = str_pad($innertext,4,'0',STR_PAD_LEFT);
$replacement = "<a href=http://www.giantitp.com/comics/oots".$url_num.".html>".$innertext."</a>";


Else adding this to your arrayBBcode:



'comic'=> array('type'=>BBCODE_TYPE_OPTARG,'open tag'=>'<a href=http://www.giantitp.com/comics/oots'.str_pad("{PARAM}",4,'0',STR_PAD_LEFT).'.html>"{PARAM}"','close tag'=>'</a>','default arg'=>'{CONTENT}','childs'=>'b,i'),

Cealocanth
2010-10-17, 09:26 PM
I think that's an exellent idea, although i'm not quite sure how the mods would go about doing this.

Let's see how it turns out.

tassaron
2010-10-18, 12:20 AM
Editing the BBCode parser is not something that can be done through the forum software itself (unless it's changed a lot since I last saw it). Implementing this would require a site administrator, not just a quick mod-job.

Also, your script pads the URL out with the leftmost 0, meaning it will go out of date when we reach comic #1000 (not incredibly far off anymore). Further, old comics would require manual insertion of zeros (025 for #25). Your example can't be used as-is and would require slightly more work to implement.

It doesn't seem especially like a good use of the staff's time. Citing a certain comic usually involves going to that comic's page anyway.

Prime32
2010-10-18, 04:53 AM
Seems like a good idea.

Shhalahr Windrider
2010-10-18, 07:25 AM
It doesn't seem especially like a good use of the staff's time. Citing a certain comic usually involves going to that comic's page anyway.
Only if you don’t already know the number. :smalltongue:

NerfTW
2010-10-18, 09:31 AM
Also, your script pads the URL out with the leftmost 0, meaning it will go out of date when we reach comic #1000 (not incredibly far off anymore). Further, old comics would require manual insertion of zeros (025 for #25). Your example can't be used as-is and would require slightly more work to implement.

And so once more the laws of the universe are laid bare, in that whenever someone says "It's easy", they are bound to mess something up, no matter how trivial the code.

Capt Spanner
2010-10-18, 12:07 PM
Also, your script pads the URL out with the leftmost 0, meaning it will go out of date when we reach comic #1000 (not incredibly far off anymore). Further, old comics would require manual insertion of zeros (025 for #25). Your example can't be used as-is and would require slightly more work to implement.

Nope. As written, #25 becomes 0025, 1234 becomes 1234, etc...

Whatever is written in the tag would be left alone if four characters, trimmed to four characters if more than four characters (can't remember if they're from start or end, though) and have 0s added to the left if less that four characters, to make it four characters.

It would therefore work with current format up to comic 10000.

The Giant
2010-10-18, 12:34 PM
It's an interesting idea, but I'm not going to ask my people to spend any time on it. It's not as important as other things waiting to be done.

Rawhide
2010-10-18, 06:16 PM
assuming the parser works something like this one:

It doesn't. Completely different system, sorry.