Site Update » BBCode updates · 5:08pm Dec 21st, 2018
Performance improvements
Over the last few days I've been working on improving the performance of the BBCode parser. I've managed to implement a few major optimizations, reducing the run time in common cases to around 1/4th to 1/20th compared to the older version. This has reduced total server-side render times on some of the more complicated test pages I've been using to around 50ms–70ms, which should be a noticeable improvement.
New features
Opacity
The [opacity]
tag is similar to [color]
, except it controls the transparency of text. This is primarily intended as an alternative to setting text to gray to make it "fade out" that works on both dark and light background colors. Keep in mind that fading the text out will reduce the contrast, which may make it difficult for some users to read, so this should be using sparingly. The opacity can be specified as either a percentage or a decimal between 0.0
and 1.0
.
This is 75%
This is 50%
This is 25%
[opacity=75%]This is 75%[/opacity]
[opacity=.5]This is 50%[/opacity]
[opacity=25%]This is 25%[/opacity]
Footnotes
There's also a somewhat incomplete feature: [footnote]
. This allows you to declare footnotes inline with your text, which will then be placed in a list at the bottom. This feature still needs a bit of work, the appearance of the list will be adjusted, some issues with formatting tags will be corrected1, and the placement and numbering rules may be adjusted.
The feature should still work for simple cases however, as long as you don't try to do anything too fancy.
This feature still needs a bit of work, the appearance of the list will be adjusted, some issues with formatting tags will be corrected[footnote]Mostly related to inline formatting tags like [code=bbcode][b][/code] being active across the start or end tag.[/footnote], and the placement and numbering rules may be adjusted.
- Mostly related to inline formatting tags like
[b]
being active across the start or end tag.
I can see potential with the opacity feature, having dialogue fade out or hiding pieces of text. Interested to see what comes out of these new additions.
Nice! I'll have to test this with fimdic2epub! :D
i will admit i have little to no understanding of the coding you have done, but i do know you have helped make my favorite site on the internet better. thank you.
4983780
People were already doing things like that with
[color]
, but it didn't work very well if you had a different background color from what the author expected...Thank you based Xaquseg!
>footnotes
gifimage.net/wp-content/uploads/2018/06/we-are-not-worthy-gif-2.gif
Footnotes, eh?
I have a feeling Terry Pratchett fans will love that early Christmas present.
Thanks
Good features. Thanks for all you do!
Neat! Although this may require iisaw and Kris Overstreet to completely reformat their stories unless they like where their “footnotes” currently are.... Also, it seems more like they’re endnotes rather than footnotes, if they go at the very bottom of the post, rather than a page/section as in a print book, unless it’s possible to code them to appear right above or below the next
While you’re fixing things, can you fix the comments counter issue (at least in the desktop browser version) where it says there are currently 1-50 of 10 comments, or 51-100 of 73, rather than the correct count?
NIce
Why do websites insist on translating a zillion different variations of BBCode and Markdown into HTML and CSS for the reader, instead of just making the author use HTML and CSS in the first place??
4983807
...Because that's a security risk?
...Okay, after rewatching, I realized the video is only tangentally related, but it's still a fun watch so I'll leave it in.
Thanks much, Xaquseg, for the optimizations as well as the new tags, they're much appreciated!
I gave the footnote tag a test-drive, and it works great. One question: can the footnote number be made a link to the footnote itself? That way the reader can jump to the footnote, and then back to where they were in the text.
4983780
Hiding text was still possible if you changed the font color to white, although this new feature will make it much easier to hide it in dark mode.
4983814
That'll be coming
4983814
We plan to add that, that falls under "somewhat incomplete"
4983794
Positioning footnotes in a more complex way than "all at the end" is a possible improvement, yes, that's why the position of the notes might change.
Woo, footnotes!1
Now we just need to get them working properly with my browser's find function...
I've never even thought about needing them before, but now, Celestia damn it I want to find a way to use footnotes.
Thanks Xaquseg! 1 Nice work! 2
Awesome additions! Thank you for your hard work!
images.gr-assets.com/hostedimages/1380912811ra/3205200.gif
Having specific support for footnotes is great, although mostly as a step towards more functional display of footnotes than we have right now - the lack of pagination really makes footnotes a pain to read. Personally I'd most like to see them displayed in a pop-up upon clicking the little number, although having links back and forth is a close second best.
4983794
I'm not really sure what the point of zero-opacity text is...
4983892
To write secret messages, duh!
4983892
Yeah, I brought this up in Discord. It's to do evil things, naturally.
Time for some Infinity War memes.
Motherfucker
Neat.
I'm going to walk away.
4983812
4983807
Here's a better one:
Thank you so much for your work! Looks great!
There is a site update post that doesn't contain things that make everything go up in flames, for once?
I know at least one story that makes heavy use of footnotes, but I don't think these would work for them. Partly because the chapters are very, very long and the footnotes at the bottom have turned out to be too faraway to be useful. So they mostly end up before the next section break. They are also numbered from the start of the story on, so being able to set that as part of the footnote would be helpful.
Automatically putting the footnotes at the next section break would be good for this story. Another choice would be to have a special tag for where to put the footnotes, so every footnote before that would be placed there (allowing for more then one in a given chapter).
Are footnotes gonna be hash links in both sides? Or they're gonna be popping-out boxes on hover, like in some wikis?
4983807
Some sites use so-called "limited HTML", and it's just as inconsistent as BBCode. Not to mention all implementations are very inconsistent with html special characters, and some even either eat "<" and ">", or do double-escaping, which result in them display as < and >. Some implementation print out incorrectly typed tags as text, and some hide them instead. Etc, etc.
At least BBCode thousand times better than textile and markdown, where you can accidentally strike-out fifteen paragraphs, and sometimes you can't use spaces, or have to use spaces.
4983812
4983935
You do realize that as long as you use parser, and not filter, it doesn't matter security-wise if you use square brackets
[b]
or angle brackets<b>
.Cautiously excited about the footnotes! But sharing 4984065's caveat:
I'll be happy to start using the feature when it doesn't break my readers' experience by making them manually scroll halfway up and down a page to a tiny, arbitrary target in order to read optional content in-line. They work at the bottom of the page in books because there's no scrolling and the bottom is actually the bottom (as opposed to sitting on top of a stack of comments). But having the tag in place is an awesome start to making it useful, and I can tell you're already mindful of the other issues involved, so thank you for moving this forward!
I now wonder what support for text opacity the various epub viewers have. I was reading a story the other day which annoyingly used different colored text in place of grammar, to distinguish thoughts from different personalities residing in a character's head. The viewer doesn't handle text color ideally, in my opinion, for its dark background viewing mode; it just over-writes the color of all text to make it white. Luckily, it leaves color unaltered in the normal white-background viewing mode. But if I could program, and were writing an ebook reader, I would make it convert all text color styles to a linear-HSB colorspace1, then invert the brightness value, then either use that if the display component of the program could understand it, or convert it all again to the sRGB color space (probably in hexadecimal format to save a smidgeon of space). Or maybe “generating an alternative style sheet” for an entire ebook would be an impractical thing to do for an ebook reader, or there's some more practical solution that hasn't crossed the mind of the person who designed the program I use to read my reading collection. Anyway… The point I wanted to originally make, was that ebook readers don't always work ideally. Although I really do like the idea of having the option for opacity.
As for the footnote tag. I could see that coming in really useful for a lot of stories. Although I do have an idea that could improve it a little… Suppose you want a specific footnote to go to a list in the author's notes section at the bottom or top of your chapter. Suppose, even, that no author' notes section exists for that chapter. Could an optional flag be added to the footnote tag, that signals where you want it to be placed? (at the end of story text|at the authors notes at the beginning of the chapter|at the author's notes at the end of the chapter) And if there is no author's note existing already, then create one to hold the footnotes section? Maybe this is a silly suggestion… But maybe it's not?
Is anyone else having trouble with their views counter? I updated one of my stories and people are commenting on the story, however the views is still the amount it had before the update.
4983892
The downside is that you can't even read it by highlighting the text. Or even see that there is any text, because the text-highlight will ALSO become transparent.
additional linebreak
Further linebreak which would otherwise just be replaced by a single linebreak, which is terrible for formatting.
Good for circumventing some of fimfiction's formatting bugs though.
But... where's my meme function?
4984065
Changeling space program?
4984199
Yeah. My favourite solution for that issue with HTML and footnotes is how Sphinx implemented it.
It hyperlinks the footnote markers to the footnotes and vice-versa and even supports referencing the same footnote from multiple places, which will result in multiple reverse links on the same footnote.
4983935
You don't need BBcode for that. In fact, Markdown (as used on GitHub, StackExchange, and so on) is explicitly designed to not be a security sandbox and supports embedding <html>...</html> chunks in among the lightweight markup.
BBcode is basically a holdover from before developers had easy access to good HTML sanitizers and needed a hack to make "escape all literal HTML, then translate special markup into the accepted subset of it" their alternative.
The proper solution (which is what you're supposed to stick on the output end of a Markdown renderer) is to use a whitelist-based HTML sanitizer built on top of a proper HTML parser. For example:
That way, the markup has nothing to do with your site's security and is purely a matter of user convenience independent from the whitelist you feed into the sanitizer. (And it makes WYSIWYG post editors easy to offer to users who prefer them.)
Then, for belt-and-suspenders safety, design your site so none of the CSS or JavaScript which powers it is declared inline or attached by modifying the DOM, and then declare a Content Security Policy to instruct CSP-supporting browsers to ignore any CSS or JavaScript that's either declared inline within the HTML or served from domains you don't control.
Yay, footnotes!
Doesn't look like the opacity tag works on images. Works with colors, tho'. I'll have to play around with it!
--Sweetie Belle
4983819
If it's of any interest, I just whipped up a POC for footnote tooltips: https://gist.github.com/chall8908/93892e1abd437dbae5052c60be62e1cf
Nice; I used to set my text to just a few hexadecimal values short of pure white to hide stuff in my comments. This opacity tag sounds quite useful, especially if it's added the the comment box toolbar (likely under the "Show More" option, or next to the colour wheel) to made it more obvious and readily-accessible.
The footnote feature could be used to show translations, should a different language (real or fictional) be used in a story. It would also likely differentiate that kind of information from the Author's Note stuff, where miscellaneous information is sometimes placed. It might be primitive now, but I do see it potentially becoming quite useful.
So, there's a feature I've been wanting for a while. Would it be possible to implement a tag that converts whatever is in the tag to the username of a logged in user, or if no one is logged in it displays whatever text is in the tagged area instead? It would make second person stories much more enjoyable to read and far more fun to write if we could have "Anon" read as "Meep the Changeling" if I read it while logged in. I know that DOS can do that with the %username% variable, so I dont' see why BB code can't.
this will probably never be noticed, but can we please get something to filter for already read stories?