Comments (3)
Same issue!
My BBCode: [url]http://dantri.com.vn/.../20180724072628474.htm[/url]
And i receive tag: <a >http://dantri.com.vn/.../20180724072628474.htm</a>
without href
attrs.
But BBCode has type [url=http://dantri.com.vn/..../20180724072628474.htm]content....[/url]
, it return <a href="http://dantri.com.vn/..../20180724072628474.htm">content....</a>
with href
attrs!
Here is my code:
import bbob from '@bbob/core'
import { createPreset } from '@bbob/preset'
import { render } from '@bbob/html'
import _ from 'lodash'
const reduceAttr = (attrs) => {
return _.reduce(
attrs,
(result, value, key) => {
(result['attr'] || (result['attr'] = [])).push(value)
return result.attr
},
{}
)
}
const preset = createPreset({
url: (node, { render }) => {
return {
tag: 'a',
attrs: {
href: reduceAttr(node.attrs) !== {}
? reduceAttr(node.attrs)[0]
: render(node.content),
},
content: node.content
}
}
})
export default {
convertBBCode (content) {
if (content) {
const result = bbob(preset()).process(content, { render }).html.replace(/(?:\r\n|\r|\n)/g, '<br>')
return result
} else {
return ''
}
}
}
from bbob.
Thanks for reporting! I take a look on this problem soon.
PS: You can use
import BBCode from '@bbob/react/es/Component'
instead of using html-react-parser
from bbob.
I have a similar problem.
From the readme at bbob-parser. trying the example will parse into
instead of
[
{
"tag": "url",
"attrs": {
"url": "https://github.com"
},
"content": ["hello", " ", "world!"]
}
]
The URL attribute is nowhere to be found, and a new attribute with the name of the url has appeared.
As a temporary fix, reverting back to version 1.3.2 works (but this breaks other things, such as the ability to use the enableEscapeTags
option)
from bbob.
Related Issues (20)
- Warning: Component: Support for defaultProps will be removed from function components in a future major release. Use JavaScript default parameters instead. HOT 3
- Lost content if there is missing close tag in middle HOT 1
- color tag in HTML5 preset HOT 1
- onlyAllowTags doesn't support case insensitive tags HOT 3
- escape does not seem to work inside of attributes
- Sanitize `file:` protocol in escapeHTML
- Flawed getUniqAttr Parsing May Corrupt HTML Output HOT 3
- Misleading name/behavior for `escapeHTML`: Should denote "use for attribute values" HOT 1
- Parser has Issues with Blanks and Quotes in Unique Attributes HOT 2
- RangeError: Maximum call stack size exceeded - Document Workaround? HOT 1
- TagNode: Subtle Difference between content = null and content = [] causes <img></img> instead of <img/>
- Vue3 Warn. default slot HOT 1
- Parser is unaware of system-dependent newlines
- Error after upgrading to latest version in React: presetHTML5.extend is not a function HOT 4
- Screen reader reads React rendered content as if there's no space between the words. HOT 1
- Screen reader reads React rendered content as if there's no space between the words.
- ContextFreeTags are not case insensitive HOT 1
- core is not a function HOT 9
- Invalid path to TypeScript types in package.json (4.0.1) HOT 3
- Can this be used in reverse? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bbob.