Methods parse BBCode?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
97 views
Prompt, what else there are methods of parsing in regular expressions. Earlier this year, as you know, not designed for parsing nested structures. If there are implementation — poke please.
by | 97 views

7 Answers

0 like 0 dislike
Nothing complicated — simply create a state machine... on Habre, by the way, not so long ago there were several articles on the subject (if I am not mistaken was the creation of compilers).
\r
For example:
1) the Existing parser xbb.uz/
\r
2) Own bike:
Code:http://pastebin.mozilla-russia.org/106940
Chart: habrastorage.org/storage/b55a4b42/f4942156/b245ccd6/9426eb87.png
(the original VP-UML, if someone will need — write)
\r
Most likely there are errors (currently just debugging).
by
0 like 0 dislike
> Of the regular season, as you know, not designed for parsing nested structures.
\r
Actually, the theory tells us that the same powerful grammar BBCodes regular season can't win.
But this does not mean that the regular season in this problem generally can not be used.
(have a look at parsers of popular forums, for example)
\r
Briefly, in one passage matchim the most deeply nested tag pair and replace something, they do not contain repeated in a loop until there is a match.
by
0 like 0 dislike
Depends on what language you use. If a PHP that is a PECL bbcode module. Use — convenient, fast, functional at the expense of callbacks and no distortions :)
by
0 like 0 dislike
> The question only in speed of analysis.
Not very fast. Not tested. Would also be interesting to compare to the other options parsers.
\r
> And finite state machines IMHO the jump tables to portray
Possible. But the chart in my opinion more intuitive.
\r
> Especially if the tags had suddenly rabovladelcheskim
When using this parser we can handle at the moment nested unclosed BB code will be forcibly closed ([a][b][/a][/b] => [a][b][/b][/a][/b])
by
0 like 0 dislike
to use a parser-generator and a formal description in RBNF =]
by
0 like 0 dislike
Write another version of*:
— Iterated BB-codes in a loop:
1) find the opening tag "[bbcode"
2) find a "]" (everything between these attributes)
3) if a single parse
4) if you're looking for the first closing tag "[/bbcode]"
5) anything between "[bbcode...]" and "[/bbcode]" this body (it is formatted depending on bbкода)
6) continue;
\r
The main problem is that it is impossible to determine what is the "]" because of this, the result depends on the order of parsing BB codes* IPB to resolve this issue, use shielding "]" in the attributes...
\r
* no need to use it... it is so written parser BB-codes in the IP.Board... it was (and still is) a lot of mistakes due to different order of nested bb-codes and attributes (including XSS and downs of the Apache... a small amount of details can be found on the IBR forum posts Ritsuka)
by
0 like 0 dislike
I use the parser xbb.uz, I just do not like the code that it generates, but after the file everything is OK.
\r
And what do you need haste? I party only once, when saved, then result kichirou and when you need to give from the cache.
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
2 answers
asked Mar 25, 2019 by angelov
0 like 0 dislike
3 answers
0 like 0 dislike
3 answers
asked Mar 21, 2019 by Gangsta
110,608 questions
257,186 answers
0 comments
28,158 users