edwardez / bbob_dart Goto Github PK
View Code? Open in Web Editor NEW⚡️Blazing fast port of the BBCode parser and transformer [bbob](https://github.com/JiLiZART/bbob) in dart.
Home Page: https://pub.dev/packages/bbob_dart
License: MIT License
⚡️Blazing fast port of the BBCode parser and transformer [bbob](https://github.com/JiLiZART/bbob) in dart.
Home Page: https://pub.dev/packages/bbob_dart
License: MIT License
Any chance to upgrade this with Null Safety? looks like a great repository and want to try it
Currently when an invalid tag is emitted from the lexer, the parser renders the tag as a text node but strips all attributes.
Example:
parse('[h1 name=value]Foo [Bar=Quz]Quux[/Bar] [/h1]', validTags: {'h1'});
results in the following AST:
[
Element(
'h1',
{'name': 'value'},
[
Text('Foo'),
Text(' '),
Text('[Bar]'),
Text('Quux'),
Text('[/Bar]'),
Text(' '),
],
)
]
Expected result:
[
Element(
'h1',
{'name': 'value'},
[
Text('Foo'),
Text(' '),
Text('[Bar=Quz]'),
Text('Quux'),
Text('[/Bar]'),
Text(' '),
],
)
]
First big thank you to @MartenM and @edwardez for getting this to Null Safety!
I just want to make sure I'm using this correctly before I dive in
Using the sample text: [u][b][i]Sample Text[/i][/b][/u]
and then running it in bbob as follows:
const validTags = {'url', 'b', 'i', 'u'};
var ast = parse(
theString,
onError: (msg) {
print(msg);
},
openTag: '[',
closeTag: ']',
enableEscapeTags: false,
validTags: validTags,
);
for (var node in ast) {
debugPrint(node.textContent);
}
I get:
flutter: [U]
flutter: [B]
flutter: [I]
flutter: Sample Text
flutter: [/I]
flutter: [/B]
flutter: [/U]
I can use this and walk through it and parse it, but it would not consider attributes and nesting might be difficult, so I think I'm going about it incorrectly. From your example documentation you write:
/// Parsed ast. Note that `b` is parsed as text because
/// it's not in [validTags].
///
///[Text{text: 'print'}, Text{text: ' '}, Text{text: '[b]'}, Text{text: 'a'},
///Text{text: '[/b]'}, Text{text: ' '},
///Element{tag: 'url', attributes: '{https://github.com: https://github.com}',
///children: [Text{text: 'hello'}, Text{text: ' '}, Text{text: 'world!'}]},
///Text{text: '
//'}, Text{text: ' '}, Text{text: 'Yes'}, Text{text: ' '},
// Text{text: 'this's'}, Text{text: ' '}, Text{text: 'an'}, Text{text: ' '},
// Text{text: 'exampe'}]
Is there supposed to be a way to retrieve these attributes and actually walk through this to properly deal with nesting?
And if I use var theString2='[url="https://www.google.com"]Test[/url]';
then the output is Test
, none of the URL attribute seem accessible.
I guess the main question is, how do you walk this tree, the var ast
appears to be a plain text string?
Thanks for any guidance..!
Hi, first of all, thank you so much for this wonderful library.
I'm having a small issue where is i try to parse the following bbcode: [img thumbnail]https://imageurl.com[/img]
I doesn't detect the attributes correctly, it believes it's a completely new tag. My current workaround for this is replacing the thumbnail
to thumbnail=true
before parsing the bbcode. That isn't ideal when having to deal with a lot of tags with many attributes.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.