Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

strapi-markdown-parser

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

strapi-markdown-parser - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

48

index.js
class StrapiMarkdown {
constructor(model, types, options) {
this.types = {}
constructor(
model,
types = {
standard: ['richtext'],
inline: ['string']
},
options = {
smartypants: true,
headerIds: false,
breaks: true
}
) {
if (types && (types.constructor === Object || Array.isArray(types))) {
this.types = types
}
if (types && types.constructor === Object) {
this.types.standard = types.standard
this.types.inline = types.inline
} else if (types && Array.isArray(types)) {
this.types.standard = types
if (model) {
this.model = this.model.attributes
} else {
this.types.standard = ['richtext']
this.types.inline = ['string']
throw new Error('StrapiMarkdown requires `model`')
}
this.marked = require('marked')
options
? this.marked.setOptions(options)
: this.marked.setOptions({
smartypants: true,
headerIds: false,
breaks: true
})
this.marked.setOptions(options)
}

@@ -28,9 +30,7 @@

for (let key in this.model) {
let out
if (this.types.standard.includes(this.model[key].type)) {
out = this.marked(data[key] || '')
if (this.types.standard && this.types.standard.includes(this.model[key].type)) {
const out = this.marked(data[key] || '')
data[key] = out.length ? out : null
} else if (this.types.inline.includes(this.model[key].type)) {
out = this.marked.parseInline(data[key] || '')
} else if (this.types.inline && this.types.inline.includes(this.model[key].type)) {
const out = this.marked.parseInline(data[key] || '')
data[key] = out.length ? out : null

@@ -44,4 +44,2 @@ }

md(data) {
model = model.attributes
if (Array.isArray(data)) {

@@ -48,0 +46,0 @@ return data.map(obj => this.parse(obj))

{
"name": "strapi-markdown-parser",
"version": "0.0.4",
"version": "0.0.5",
"description": "Strapi controller module to parse Markdown to HTML",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc