New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Request] (I know it's an outdated language, but) BBcode #2592
Comments
This should be enough to get started 😉 hljs.registerLanguage('bbcode', function(hljs) {
return {
contains: [
{
className: 'template-tag',
begin: /\[/, end: /\]/
},
{
className: 'symbol',
begin: /[:;]'?\-?[\)\(SPD]/i
},
{
className: 'symbol',
begin: /:/, end: /:/,
illegal: /\s/
}
]
};
}); |
A 3rd party language module for BBCode would be pretty cool! From our documentation: This is a general answer to requests for adding new languages that appear from
If you might be interested in contributing a 3rd party language grammar you can start at: https://github.com/highlightjs/highlight.js/blob/master/extra/3RD_PARTY_QUICK_START.md |
Closing per provided explanation. If someone wants to work on a 3rd party grammar we'd be happy to add a link to it to supported languages. |
@yyyc514 - The link to "3RD_PARTY_QUICK_START" returns a 404. |
Fixed. |
I would consider making it official repository if I have the chance.
If it is the color of the HTML tag, I’m afraid it doesn’t conform to the purpose of the HTML class in Highlight.js. BBCode symbols are more inclined to template syntax like Twig and Handlebars compared to HTML markup. Let’s see… |
I meant that the equals sign and the value should be highlighted separately... |
I made one, but I don't know how to add it (I'm new to GitHub). hljs.registerLanguage('bbcode', function (hljs) {
return {
case_insensitive: true,
contains: [
{
className: 'name',
begin: /\[[^=\s\]]*/
},
{
className: 'name',
begin: ']'
},
{
className: 'attribute',
begin: /(?<==)[^\]\s]*/
},
{
className: 'attr',
begin: /(?<=\[[^\]]* )[^\s=\]]*/
},
{
className: 'string',
begin: /[=;:8]'?\-?[\)\(3SPDO>@$|/]/
},
{
className: 'string',
begin: /:[\w]*:/
}
]
};
});
hljs.initHighlightingOnLoad(); |
https://github.com/highlightjs/highlight.js/blob/master/extra/3RD_PARTY_QUICK_START.md Or you can just leave it right here and anyone who googles will probably find this thread and then they could include the source code in their project if they wanted to. We currently don’t add new languages to the core library so if you want this out in the world you can either leave it right here or you can publish it to your own repository as a third-party grammar which people can choose to use if they want. |
i made a repo, is this good? https://github.com/RedGuy12/highlightjs-bbcode |
It's a little unconventional (layout of the files, etc)... but it works. :-) If you want to make a PR and add a link to SUPPORTED_LANGUAGES please do so! |
Added with #2867 |
Is your request related to a specific problem you're having?
I'm here from Discord, and I had to describe how to do something on a bulletin board site using BBcode. I noticed that starting the code block with
```bbcode
did nothing.The solution you'd prefer / feature you'd like to see added...
I'd like basic syntax highlighting added for BBcode.
The main (only?) components of BBcode that I want highlighted are tags and emotes.
Regex for tags (just a guess):
\[(\w+|\*)(=[.]+)?\]
Tags that don’t support a parameter:
b
,i
,u
,s
,center
,spoiler
,youtube
Tags that require a parameter:
img
,font
,color
,size
Tags with an optional parameter:
url
,quote
,box
(found on osu! forums)Regex for board-defined emotes (also a guess):
:[\w_]+:
Common emotes:
=>
,:D
,:S
,:cool:
,:'(
,:eek:
,:evil:
,:!:
,:(
,:idea:
,:lol:
,:@
,:green:
,:|
,:?:
,:P
,:$
,8-)
,:)
,:o
,:devil:
,:wink:
,:hehe:
,¬_¬
,x_x
,^_^
,:XD:
,:-3
,:vhappy:
,:doh:
, in addition to unbroken text surrounded within two:
sThe text was updated successfully, but these errors were encountered: