Skip to content
Snippets Groups Projects
Commit e21cbf88 authored by Jürgen Voskuhl's avatar Jürgen Voskuhl
Browse files

Extended markdown parser

parent 2be6b010
No related branches found
No related tags found
1 merge request!86planning#1203: Standards
......@@ -3,7 +3,7 @@ import fs from 'fs'
import path from 'path'
import { remark } from 'remark'
import html from 'remark-html'
import { ChildResource, LabelTag, StatusTag, Tag, TypeTag } from 'types/content/'
import { ChildResource, LabelTag, StatusTag, SlugMasterTag, Tag, TypeTag } from 'types/content/'
export default function loadAndPrepareMarkdown(selectedServiceName: string, folder: string) {
const markdownFileContent: string = loadMarkdown(selectedServiceName, folder)
......@@ -68,13 +68,18 @@ function parseMetadata(metadata: string): ServiceContent {
// Convert line into tupel
const [key, value] = convertLineIntoTuple(line)
//
if (parentKey === 'childResources') {
if (key === '- name') {
if (key === '- name' && value != '') {
content.childResources.push(new ChildResource({ name: value, slug: '' }))
return
}
content.childResources[content.childResources.length - 1].slug = value
return
else {
if (value != '' && startsWithTwoSpaces(line)) {
content.childResources[content.childResources.length - 1].slug = value
}
return
}
}
// Check for explicit keys
......@@ -98,7 +103,9 @@ function parseMetadata(metadata: string): ServiceContent {
}
// Assign simple key value tuple
content[key] = value
if (value != '') {
content[key] = value
}
})
return new ServiceContent(content)
}
......@@ -109,6 +116,8 @@ function createTag(key: string, value: string) {
return new StatusTag(value)
} else if (key.includes('label')) {
return new LabelTag(value)
} else if (key.includes('slugMaster')) {
return new SlugMasterTag(value)
}
}
function convertLineIntoTuple(lineString: string) {
......
import { Tag } from './Tag'
export class SlugMasterTag extends Tag {
type: string
name: string = 'slug_master'
value: string
constructor(type: string) {
super()
this.type = type
this.value = type
}
}
......@@ -4,6 +4,7 @@ import { ContactInformation } from './ContactInformation'
import { Developer } from './Developer'
import { LabelTag } from './LabelTag'
import { StatusTag } from './StatusTag'
import { SlugMasterTag } from './SlugMasterTag'
import { Tag } from './Tag'
import { TypeTag } from './TypeTag'
import { Logo } from './Logo'
......@@ -15,6 +16,7 @@ export {
Developer,
LabelTag,
ProductOwner,
SlugMasterTag,
StatusTag,
Tag,
TypeTag,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment