kefirfromperm / kefirbb Goto Github PK
View Code? Open in Web Editor NEWA flexible Java text processor. BB, BBCode, BB-code, HTML, Textile, Markdown, parser, translator, converter.
License: GNU Lesser General Public License v3.0
A flexible Java text processor. BB, BBCode, BB-code, HTML, Textile, Markdown, parser, translator, converter.
License: GNU Lesser General Public License v3.0
I tried to add KefirBB to my android project and with the default initializer I got this exception:
FATAL EXCEPTION: main
Process: se.avanzabank.androidapplikation.debug, PID: 488
java.lang.ExceptionInInitializerError
at org.kefirsf.bb.PatternElementFactory.create(PatternElementFactory.java:43)
at org.kefirsf.bb.ProcessorBuilder.createPattern(ProcessorBuilder.java:139)
at org.kefirsf.bb.ProcessorBuilder.createCode(ProcessorBuilder.java:97)
at org.kefirsf.bb.ProcessorBuilder.createScope(ProcessorBuilder.java:67)
at org.kefirsf.bb.ProcessorBuilder.build(ProcessorBuilder.java:33)
at org.kefirsf.bb.BBProcessorFactory.create(BBProcessorFactory.java:52)
at org.kefirsf.bb.BBProcessorFactory.createFromResource(BBProcessorFactory.java:63)
at se.avanzabank.androidapplikation.news.fragment.PlaceraArticleFragment.populateWithArticle(PlaceraArticleFragment.java:226)
at se.avanzabank.androidapplikation.news.fragment.PlaceraArticleFragment.lambda$null$235(PlaceraArticleFragment.java:143)
at se.avanzabank.androidapplikation.news.fragment.PlaceraArticleFragment$$Lambda$4.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Caused by: java.util.regex.PatternSyntaxException: In a character range [x-y], x is greater than y near index 8
#([\w&-=]|(%\p{XDigit}{2}))*
^
at java.util.regex.Pattern.compileImpl(Native Method)
at java.util.regex.Pattern.compile(Pattern.java:1340)
at java.util.regex.Pattern.<init>(Pattern.java:1324)
at java.util.regex.Pattern.compile(Pattern.java:946)
at org.kefirsf.bb.proc.ProcUrl.<clinit>(ProcUrl.java:21)
... 17 more
Any ideas how to fix this?
It is necessary to add the textile configuration. But in the definition of the textile there are constructions which is not allowed in KefirBB.
Is it possible to change my configuration in a way that allows me to convert urls containing reserved chars like '&', '=' or '/'?
Needs more tests for all classes.
A safehtml processor instantiated like this:
TextProcessor safeProcessor = BBProcessorFactory.getInstance().createFromResource("org/kefirsf/bb/safehtml.xml");
gets stuck or runs very slow during the parsing of a string which contains many
s.
Example test case:
safeProcessor.process("<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>");
The issue exists in version 1.0 and 1.2 as well.
After processing a simple [img]
-element, the value of the src
-attribute is null:
TextProcessor processor = BBProcessorFactory.getInstance().create();
String imgFail = processor.process("[img]https://upload.wikimedia.org/wikipedia/commons/9/90/JustAnExample.JPG[/img]");
// imgFail = <img src="null"/>
But if I provide a width and a height the processing is successful:
TextProcessor processor = BBProcessorFactory.getInstance().create();
String imgSuccess = processor.process("[img width:350px height:350px]https://upload.wikimedia.org/wikipedia/commons/9/90/JustAnExample.JPG[/img]");
// imgSuccess = <img src="https://upload.wikimedia.org/wikipedia/commons/9/90/JustAnExample.JPG" style="width:350px; height:350px;"/>
I think it's a bug or do I have to set any configurations?
Add configuration tag junk for unparseable text.
It's needed to create an email tag for parsing emails. It's like url tag.
Add nesting limit on tags for prevent StackOverflowException
Canonical markdown syntax is allowed by the link https://daringfireball.net/projects/markdown/syntax
Add a tag import to import configuration files in configuration.
For example the safe HTML tags are needed in Textile and Markdown.
Create a configuration for filtration of HTML.
I found KefirBB library in stackoverflow but it's only providing converting BBCode to Html.How to convert html to BBCode?
block attributes like (((myclass)
is parsed with error. Must be converted as style="padding-left:2em;" class="myclass"
The following tag definition:
<code name="example">
<pattern>[url]<var name="a" regex="http://example.com"/>/<var name="b"/>[/url]</pattern>
<template>FOUND</template>
</code>
should match http://example.com/hello, but it does not. However, this tag:
<code name="example">
<pattern>[url]<var name="a" regex="example.com"/>/<var name="b"/>[/url]</pattern>
<template>FOUND</template>
</code>
does match example.com/hello. Moreover, this tag:
<code name="example">
<pattern>[url]<var name="a" regex="http://example.com"/>/h<var name="b"/>[/url]</pattern>
<template>FOUND</template>
</code>
will match http://example.com/hello
The issue seems to relate to the existence of a / in both a regular expression and the text. The existence of the second variable also seems to be required to cause this issue, as does the / being the only character between the two variables.
Sometimes simple configuration options are not enough. And at the same time, there is no way to customize the basic project without delving deeply into its architecture. Here, of course, I mean without physical modification of the code of the base artifact.
It would be great to be able to extend parsing capabilities not only with configuration, but also through DI. Even without being tied to a specific DI implementation.
However, allow users of the project to choose how to build certain nodes of the system.
For example, writing custom functions for your own needs (of course, the XSD schema have to allow this).
It's needed to describe new features of new versions of the library.
First, new configurations - safe HTML, Textile, Markdown
Second, new tags - url, if etc.
Stabilize configuration's syntax
Make refactoring
Complete javadoc
Needs refactoring of configuration classes. They must link between directly, not for names.
KefirBB wrongly converts a standard text
Input:
[list] []Entry 1 []Entry 2 [/list]
Expected:
<ul><li>Entry 1</li><li>Entry 2</li></ul>
It's needed to do refactoring of tests. There are to many code duplicates and it is not clear which text was parsed on failure.
It's needed to add "if" expression to templates.
<if name="style"> style="<var name="style"/>"</if>
The value inside the if expression will be appended only if style variable is not null.
It allows reduce configuration complexity and increase capacity. Because it allows to reduce code and pattern values
For example the token[url=http://example.com/dashed-path/index.html]Link name[/url]
does not evaluate to a hyperlink.
[url=http://example.com/nondashedpath/index.html]Link name[/url]
works fine.
Very often an URL is found in markup languages. So this tag will be very useful.
It's needed to create a list of allowed style properties for HTML and Textile.
Needs more comments.
Need to add the OSGi descriptor. And something else, maybe.
I need a logging. It's needed to fix which part of a text recognized as which code. Debugging is very hard now.
Hi,
how i can convert quote with author to html?
Example:
[quote=Jack][quote=John]Some text[/quote]John i can help you ;)[/quote]Thanks Jack, i send you pm...
Thanks for help
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.